documentation.d.ts 3.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864928659286692867928689286992870928719287292873928749287592876928779287892879928809288192882928839288492885928869288792888928899289092891928929289392894928959289692897928989289992900929019290292903929049290592906929079290892909929109291192912929139291492915929169291792918929199292092921929229292392924929259292692927929289292992930929319293292933929349293592936929379293892939929409294192942929439294492945929469294792948929499295092951929529295392954929559295692957929589295992960929619296292963929649296592966929679296892969929709297192972929739297492975929769297792978929799298092981929829298392984929859298692987929889298992990929919299292993929949299592996929979299892999930009300193002930039300493005930069300793008930099301093011930129301393014930159301693017930189301993020930219302293023930249302593026930279302893029930309303193032930339303493035930369303793038930399304093041930429304393044930459304693047930489304993050930519305293053930549305593056930579305893059930609306193062930639306493065930669306793068930699307093071930729307393074930759307693077930789307993080930819308293083930849308593086930879308893089930909309193092930939309493095930969309793098930999310093101931029310393104931059310693107931089310993110931119311293113931149311593116931179311893119931209312193122931239312493125931269312793128931299313093131931329313393134931359313693137931389313993140931419314293143931449314593146931479314893149931509315193152931539315493155931569315793158931599316093161931629316393164931659316693167931689316993170931719317293173931749317593176931779317893179931809318193182931839318493185931869318793188931899319093191931929319393194931959319693197931989319993200932019320293203932049320593206932079320893209932109321193212932139321493215932169321793218932199322093221932229322393224932259322693227932289322993230932319323293233932349323593236932379323893239932409324193242932439324493245932469324793248932499325093251932529325393254932559325693257932589325993260932619326293263932649326593266932679326893269932709327193272932739327493275932769327793278932799328093281932829328393284932859328693287932889328993290932919329293293932949329593296932979329893299933009330193302933039330493305933069330793308933099331093311933129331393314933159331693317933189331993320933219332293323933249332593326933279332893329933309333193332933339333493335933369333793338933399334093341933429334393344933459334693347933489334993350933519335293353933549335593356933579335893359933609336193362933639336493365933669336793368933699337093371933729337393374933759337693377933789337993380933819338293383933849338593386933879338893389933909339193392933939339493395933969339793398933999340093401934029340393404934059340693407934089340993410934119341293413934149341593416
  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. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4663. * @param yaw defines the rotation around Y axis
  4664. * @param pitch defines the rotation around X axis
  4665. * @param roll defines the rotation around Z axis
  4666. * @returns the new quaternion
  4667. */
  4668. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4669. /**
  4670. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  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. * @param result defines the target quaternion
  4675. */
  4676. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4677. /**
  4678. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4679. * @param alpha defines the rotation around first axis
  4680. * @param beta defines the rotation around second axis
  4681. * @param gamma defines the rotation around third axis
  4682. * @returns the new quaternion
  4683. */
  4684. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4685. /**
  4686. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  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. * @param result defines the target quaternion
  4691. */
  4692. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4693. /**
  4694. * 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)
  4695. * @param axis1 defines the first axis
  4696. * @param axis2 defines the second axis
  4697. * @param axis3 defines the third axis
  4698. * @returns the new quaternion
  4699. */
  4700. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4701. /**
  4702. * 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
  4703. * @param axis1 defines the first axis
  4704. * @param axis2 defines the second axis
  4705. * @param axis3 defines the third axis
  4706. * @param ref defines the target quaternion
  4707. */
  4708. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4709. /**
  4710. * Interpolates between two quaternions
  4711. * @param left defines first quaternion
  4712. * @param right defines second quaternion
  4713. * @param amount defines the gradient to use
  4714. * @returns the new interpolated quaternion
  4715. */
  4716. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4717. /**
  4718. * Interpolates between two quaternions and stores it into a target quaternion
  4719. * @param left defines first quaternion
  4720. * @param right defines second quaternion
  4721. * @param amount defines the gradient to use
  4722. * @param result defines the target quaternion
  4723. */
  4724. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4725. /**
  4726. * Interpolate between two quaternions using Hermite interpolation
  4727. * @param value1 defines first quaternion
  4728. * @param tangent1 defines the incoming tangent
  4729. * @param value2 defines second quaternion
  4730. * @param tangent2 defines the outgoing tangent
  4731. * @param amount defines the target quaternion
  4732. * @returns the new interpolated quaternion
  4733. */
  4734. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4735. }
  4736. /**
  4737. * Class used to store matrix data (4x4)
  4738. */
  4739. export class Matrix {
  4740. /**
  4741. * Gets the precision of matrix computations
  4742. */
  4743. static get Use64Bits(): boolean;
  4744. private static _updateFlagSeed;
  4745. private static _identityReadOnly;
  4746. private _isIdentity;
  4747. private _isIdentityDirty;
  4748. private _isIdentity3x2;
  4749. private _isIdentity3x2Dirty;
  4750. /**
  4751. * Gets the update flag of the matrix which is an unique number for the matrix.
  4752. * It will be incremented every time the matrix data change.
  4753. * You can use it to speed the comparison between two versions of the same matrix.
  4754. */
  4755. updateFlag: number;
  4756. private readonly _m;
  4757. /**
  4758. * Gets the internal data of the matrix
  4759. */
  4760. get m(): DeepImmutable<Float32Array | Array<number>>;
  4761. /** @hidden */
  4762. _markAsUpdated(): void;
  4763. /** @hidden */
  4764. private _updateIdentityStatus;
  4765. /**
  4766. * Creates an empty matrix (filled with zeros)
  4767. */
  4768. constructor();
  4769. /**
  4770. * Check if the current matrix is identity
  4771. * @returns true is the matrix is the identity matrix
  4772. */
  4773. isIdentity(): boolean;
  4774. /**
  4775. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4776. * @returns true is the matrix is the identity matrix
  4777. */
  4778. isIdentityAs3x2(): boolean;
  4779. /**
  4780. * Gets the determinant of the matrix
  4781. * @returns the matrix determinant
  4782. */
  4783. determinant(): number;
  4784. /**
  4785. * Returns the matrix as a Float32Array or Array<number>
  4786. * @returns the matrix underlying array
  4787. */
  4788. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4789. /**
  4790. * Returns the matrix as a Float32Array or Array<number>
  4791. * @returns the matrix underlying array.
  4792. */
  4793. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4794. /**
  4795. * Inverts the current matrix in place
  4796. * @returns the current inverted matrix
  4797. */
  4798. invert(): Matrix;
  4799. /**
  4800. * Sets all the matrix elements to zero
  4801. * @returns the current matrix
  4802. */
  4803. reset(): Matrix;
  4804. /**
  4805. * Adds the current matrix with a second one
  4806. * @param other defines the matrix to add
  4807. * @returns a new matrix as the addition of the current matrix and the given one
  4808. */
  4809. add(other: DeepImmutable<Matrix>): Matrix;
  4810. /**
  4811. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4812. * @param other defines the matrix to add
  4813. * @param result defines the target matrix
  4814. * @returns the current matrix
  4815. */
  4816. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4817. /**
  4818. * Adds in place the given matrix to the current matrix
  4819. * @param other defines the second operand
  4820. * @returns the current updated matrix
  4821. */
  4822. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Sets the given matrix to the current inverted Matrix
  4825. * @param other defines the target matrix
  4826. * @returns the unmodified current matrix
  4827. */
  4828. invertToRef(other: Matrix): Matrix;
  4829. /**
  4830. * add a value at the specified position in the current Matrix
  4831. * @param index the index of the value within the matrix. between 0 and 15.
  4832. * @param value the value to be added
  4833. * @returns the current updated matrix
  4834. */
  4835. addAtIndex(index: number, value: number): Matrix;
  4836. /**
  4837. * mutiply the specified position in the current Matrix by a value
  4838. * @param index the index of the value within the matrix. between 0 and 15.
  4839. * @param value the value to be added
  4840. * @returns the current updated matrix
  4841. */
  4842. multiplyAtIndex(index: number, value: number): Matrix;
  4843. /**
  4844. * Inserts the translation vector (using 3 floats) in the current matrix
  4845. * @param x defines the 1st component of the translation
  4846. * @param y defines the 2nd component of the translation
  4847. * @param z defines the 3rd component of the translation
  4848. * @returns the current updated matrix
  4849. */
  4850. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4851. /**
  4852. * Adds 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. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4859. /**
  4860. * Inserts the translation vector in the current matrix
  4861. * @param vector3 defines the translation to insert
  4862. * @returns the current updated matrix
  4863. */
  4864. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4865. /**
  4866. * Gets the translation value of the current matrix
  4867. * @returns a new Vector3 as the extracted translation from the matrix
  4868. */
  4869. getTranslation(): Vector3;
  4870. /**
  4871. * Fill a Vector3 with the extracted translation from the matrix
  4872. * @param result defines the Vector3 where to store the translation
  4873. * @returns the current matrix
  4874. */
  4875. getTranslationToRef(result: Vector3): Matrix;
  4876. /**
  4877. * Remove rotation and scaling part from the matrix
  4878. * @returns the updated matrix
  4879. */
  4880. removeRotationAndScaling(): Matrix;
  4881. /**
  4882. * Multiply two matrices
  4883. * @param other defines the second operand
  4884. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4885. */
  4886. multiply(other: DeepImmutable<Matrix>): Matrix;
  4887. /**
  4888. * Copy the current matrix from the given one
  4889. * @param other defines the source matrix
  4890. * @returns the current updated matrix
  4891. */
  4892. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4893. /**
  4894. * Populates the given array from the starting index with the current matrix values
  4895. * @param array defines the target array
  4896. * @param offset defines the offset in the target array where to start storing values
  4897. * @returns the current matrix
  4898. */
  4899. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4900. /**
  4901. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4902. * @param other defines the second operand
  4903. * @param result defines the matrix where to store the multiplication
  4904. * @returns the current matrix
  4905. */
  4906. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4907. /**
  4908. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4909. * @param other defines the second operand
  4910. * @param result defines the array where to store the multiplication
  4911. * @param offset defines the offset in the target array where to start storing values
  4912. * @returns the current matrix
  4913. */
  4914. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4915. /**
  4916. * Check equality between this matrix and a second one
  4917. * @param value defines the second matrix to compare
  4918. * @returns true is the current matrix and the given one values are strictly equal
  4919. */
  4920. equals(value: DeepImmutable<Matrix>): boolean;
  4921. /**
  4922. * Clone the current matrix
  4923. * @returns a new matrix from the current matrix
  4924. */
  4925. clone(): Matrix;
  4926. /**
  4927. * Returns the name of the current matrix class
  4928. * @returns the string "Matrix"
  4929. */
  4930. getClassName(): string;
  4931. /**
  4932. * Gets the hash code of the current matrix
  4933. * @returns the hash code
  4934. */
  4935. getHashCode(): number;
  4936. /**
  4937. * Decomposes the current Matrix into a translation, rotation and scaling components
  4938. * @param scale defines the scale vector3 given as a reference to update
  4939. * @param rotation defines the rotation quaternion given as a reference to update
  4940. * @param translation defines the translation vector3 given as a reference to update
  4941. * @returns true if operation was successful
  4942. */
  4943. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4944. /**
  4945. * Gets specific row of the matrix
  4946. * @param index defines the number of the row to get
  4947. * @returns the index-th row of the current matrix as a new Vector4
  4948. */
  4949. getRow(index: number): Nullable<Vector4>;
  4950. /**
  4951. * Sets the index-th row of the current matrix to the vector4 values
  4952. * @param index defines the number of the row to set
  4953. * @param row defines the target vector4
  4954. * @returns the updated current matrix
  4955. */
  4956. setRow(index: number, row: Vector4): Matrix;
  4957. /**
  4958. * Compute the transpose of the matrix
  4959. * @returns the new transposed matrix
  4960. */
  4961. transpose(): Matrix;
  4962. /**
  4963. * Compute the transpose of the matrix and store it in a given matrix
  4964. * @param result defines the target matrix
  4965. * @returns the current matrix
  4966. */
  4967. transposeToRef(result: Matrix): Matrix;
  4968. /**
  4969. * Sets the index-th row of the current matrix with the given 4 x float values
  4970. * @param index defines the row index
  4971. * @param x defines the x component to set
  4972. * @param y defines the y component to set
  4973. * @param z defines the z component to set
  4974. * @param w defines the w component to set
  4975. * @returns the updated current matrix
  4976. */
  4977. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4978. /**
  4979. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4980. * @param scale defines the scale factor
  4981. * @returns a new matrix
  4982. */
  4983. scale(scale: number): Matrix;
  4984. /**
  4985. * Scale the current matrix values by a factor to a given result matrix
  4986. * @param scale defines the scale factor
  4987. * @param result defines the matrix to store the result
  4988. * @returns the current matrix
  4989. */
  4990. scaleToRef(scale: number, result: Matrix): Matrix;
  4991. /**
  4992. * Scale the current matrix values by a factor and add the result to a given matrix
  4993. * @param scale defines the scale factor
  4994. * @param result defines the Matrix to store the result
  4995. * @returns the current matrix
  4996. */
  4997. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4998. /**
  4999. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5000. * @param ref matrix to store the result
  5001. */
  5002. toNormalMatrix(ref: Matrix): void;
  5003. /**
  5004. * Gets only rotation part of the current matrix
  5005. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5006. */
  5007. getRotationMatrix(): Matrix;
  5008. /**
  5009. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5010. * @param result defines the target matrix to store data to
  5011. * @returns the current matrix
  5012. */
  5013. getRotationMatrixToRef(result: Matrix): Matrix;
  5014. /**
  5015. * Toggles model matrix from being right handed to left handed in place and vice versa
  5016. */
  5017. toggleModelMatrixHandInPlace(): void;
  5018. /**
  5019. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5020. */
  5021. toggleProjectionMatrixHandInPlace(): void;
  5022. /**
  5023. * Creates a matrix from an array
  5024. * @param array defines the source array
  5025. * @param offset defines an offset in the source array
  5026. * @returns a new Matrix set from the starting index of the given array
  5027. */
  5028. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5029. /**
  5030. * Copy the content of an array into a given matrix
  5031. * @param array defines the source array
  5032. * @param offset defines an offset in the source array
  5033. * @param result defines the target matrix
  5034. */
  5035. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5036. /**
  5037. * Stores an array into a matrix after having multiplied each component by a given factor
  5038. * @param array defines the source array
  5039. * @param offset defines the offset in the source array
  5040. * @param scale defines the scaling factor
  5041. * @param result defines the target matrix
  5042. */
  5043. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5044. /**
  5045. * Gets an identity matrix that must not be updated
  5046. */
  5047. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5048. /**
  5049. * Stores a list of values (16) inside a given matrix
  5050. * @param initialM11 defines 1st value of 1st row
  5051. * @param initialM12 defines 2nd value of 1st row
  5052. * @param initialM13 defines 3rd value of 1st row
  5053. * @param initialM14 defines 4th value of 1st row
  5054. * @param initialM21 defines 1st value of 2nd row
  5055. * @param initialM22 defines 2nd value of 2nd row
  5056. * @param initialM23 defines 3rd value of 2nd row
  5057. * @param initialM24 defines 4th value of 2nd row
  5058. * @param initialM31 defines 1st value of 3rd row
  5059. * @param initialM32 defines 2nd value of 3rd row
  5060. * @param initialM33 defines 3rd value of 3rd row
  5061. * @param initialM34 defines 4th value of 3rd row
  5062. * @param initialM41 defines 1st value of 4th row
  5063. * @param initialM42 defines 2nd value of 4th row
  5064. * @param initialM43 defines 3rd value of 4th row
  5065. * @param initialM44 defines 4th value of 4th row
  5066. * @param result defines the target matrix
  5067. */
  5068. 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;
  5069. /**
  5070. * Creates new matrix from a list of values (16)
  5071. * @param initialM11 defines 1st value of 1st row
  5072. * @param initialM12 defines 2nd value of 1st row
  5073. * @param initialM13 defines 3rd value of 1st row
  5074. * @param initialM14 defines 4th value of 1st row
  5075. * @param initialM21 defines 1st value of 2nd row
  5076. * @param initialM22 defines 2nd value of 2nd row
  5077. * @param initialM23 defines 3rd value of 2nd row
  5078. * @param initialM24 defines 4th value of 2nd row
  5079. * @param initialM31 defines 1st value of 3rd row
  5080. * @param initialM32 defines 2nd value of 3rd row
  5081. * @param initialM33 defines 3rd value of 3rd row
  5082. * @param initialM34 defines 4th value of 3rd row
  5083. * @param initialM41 defines 1st value of 4th row
  5084. * @param initialM42 defines 2nd value of 4th row
  5085. * @param initialM43 defines 3rd value of 4th row
  5086. * @param initialM44 defines 4th value of 4th row
  5087. * @returns the new matrix
  5088. */
  5089. 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;
  5090. /**
  5091. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5092. * @param scale defines the scale vector3
  5093. * @param rotation defines the rotation quaternion
  5094. * @param translation defines the translation vector3
  5095. * @returns a new matrix
  5096. */
  5097. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5098. /**
  5099. * Sets a matrix to a value 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. * @param result defines the target matrix
  5104. */
  5105. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5106. /**
  5107. * Creates a new identity matrix
  5108. * @returns a new identity matrix
  5109. */
  5110. static Identity(): Matrix;
  5111. /**
  5112. * Creates a new identity matrix and stores the result in a given matrix
  5113. * @param result defines the target matrix
  5114. */
  5115. static IdentityToRef(result: Matrix): void;
  5116. /**
  5117. * Creates a new zero matrix
  5118. * @returns a new zero matrix
  5119. */
  5120. static Zero(): Matrix;
  5121. /**
  5122. * Creates a new rotation matrix for "angle" radians around the X axis
  5123. * @param angle defines the angle (in radians) to use
  5124. * @return the new matrix
  5125. */
  5126. static RotationX(angle: number): Matrix;
  5127. /**
  5128. * Creates a new matrix as the invert of a given matrix
  5129. * @param source defines the source matrix
  5130. * @returns the new matrix
  5131. */
  5132. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5133. /**
  5134. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5135. * @param angle defines the angle (in radians) to use
  5136. * @param result defines the target matrix
  5137. */
  5138. static RotationXToRef(angle: number, result: Matrix): void;
  5139. /**
  5140. * Creates a new rotation matrix for "angle" radians around the Y axis
  5141. * @param angle defines the angle (in radians) to use
  5142. * @return the new matrix
  5143. */
  5144. static RotationY(angle: number): Matrix;
  5145. /**
  5146. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5147. * @param angle defines the angle (in radians) to use
  5148. * @param result defines the target matrix
  5149. */
  5150. static RotationYToRef(angle: number, result: Matrix): void;
  5151. /**
  5152. * Creates a new rotation matrix for "angle" radians around the Z axis
  5153. * @param angle defines the angle (in radians) to use
  5154. * @return the new matrix
  5155. */
  5156. static RotationZ(angle: number): Matrix;
  5157. /**
  5158. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5159. * @param angle defines the angle (in radians) to use
  5160. * @param result defines the target matrix
  5161. */
  5162. static RotationZToRef(angle: number, result: Matrix): void;
  5163. /**
  5164. * Creates a new rotation matrix for "angle" radians around the given axis
  5165. * @param axis defines the axis to use
  5166. * @param angle defines the angle (in radians) to use
  5167. * @return the new matrix
  5168. */
  5169. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5170. /**
  5171. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5172. * @param axis defines the axis to use
  5173. * @param angle defines the angle (in radians) to use
  5174. * @param result defines the target matrix
  5175. */
  5176. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5177. /**
  5178. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5179. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5180. * @param from defines the vector to align
  5181. * @param to defines the vector to align to
  5182. * @param result defines the target matrix
  5183. */
  5184. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5185. /**
  5186. * Creates a rotation matrix
  5187. * @param yaw defines the yaw angle in radians (Y axis)
  5188. * @param pitch defines the pitch angle in radians (X axis)
  5189. * @param roll defines the roll angle in radians (Z axis)
  5190. * @returns the new rotation matrix
  5191. */
  5192. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5193. /**
  5194. * Creates a rotation matrix and stores it in a given 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. * @param result defines the target matrix
  5199. */
  5200. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5201. /**
  5202. * Creates a scaling matrix
  5203. * @param x defines the scale factor on X axis
  5204. * @param y defines the scale factor on Y axis
  5205. * @param z defines the scale factor on Z axis
  5206. * @returns the new matrix
  5207. */
  5208. static Scaling(x: number, y: number, z: number): Matrix;
  5209. /**
  5210. * Creates a scaling matrix and stores it in a given 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. * @param result defines the target matrix
  5215. */
  5216. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5217. /**
  5218. * Creates a translation matrix
  5219. * @param x defines the translation on X axis
  5220. * @param y defines the translation on Y axis
  5221. * @param z defines the translationon Z axis
  5222. * @returns the new matrix
  5223. */
  5224. static Translation(x: number, y: number, z: number): Matrix;
  5225. /**
  5226. * Creates a translation matrix and stores it in a given 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. * @param result defines the target matrix
  5231. */
  5232. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5233. /**
  5234. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5235. * @param startValue defines the start value
  5236. * @param endValue defines the end value
  5237. * @param gradient defines the gradient factor
  5238. * @returns the new matrix
  5239. */
  5240. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5241. /**
  5242. * Set the given matrix "result" as 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. * @param result defines the Matrix object where to store data
  5247. */
  5248. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5249. /**
  5250. * Builds a new matrix whose values are computed by:
  5251. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5252. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5253. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5254. * @param startValue defines the first matrix
  5255. * @param endValue defines the second matrix
  5256. * @param gradient defines the gradient between the two matrices
  5257. * @returns the new matrix
  5258. */
  5259. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5260. /**
  5261. * Update a matrix to values which are computed by:
  5262. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5263. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5264. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5265. * @param startValue defines the first matrix
  5266. * @param endValue defines the second matrix
  5267. * @param gradient defines the gradient between the two matrices
  5268. * @param result defines the target matrix
  5269. */
  5270. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5271. /**
  5272. * 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"
  5273. * This function works in left handed mode
  5274. * @param eye defines the final position of the entity
  5275. * @param target defines where the entity should look at
  5276. * @param up defines the up vector for the entity
  5277. * @returns the new matrix
  5278. */
  5279. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5280. /**
  5281. * 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".
  5282. * This function works in left handed mode
  5283. * @param eye defines the final position of the entity
  5284. * @param target defines where the entity should look at
  5285. * @param up defines the up vector for the entity
  5286. * @param result defines the target matrix
  5287. */
  5288. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5289. /**
  5290. * 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"
  5291. * This function works in right handed mode
  5292. * @param eye defines the final position of the entity
  5293. * @param target defines where the entity should look at
  5294. * @param up defines the up vector for the entity
  5295. * @returns the new matrix
  5296. */
  5297. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5298. /**
  5299. * 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".
  5300. * This function works in right handed mode
  5301. * @param eye defines the final position of the entity
  5302. * @param target defines where the entity should look at
  5303. * @param up defines the up vector for the entity
  5304. * @param result defines the target matrix
  5305. */
  5306. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5307. /**
  5308. * Create a left-handed orthographic projection matrix
  5309. * @param width defines the viewport width
  5310. * @param height defines the viewport height
  5311. * @param znear defines the near clip plane
  5312. * @param zfar defines the far clip plane
  5313. * @returns a new matrix as a left-handed orthographic projection matrix
  5314. */
  5315. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5316. /**
  5317. * Store a left-handed orthographic projection to a given matrix
  5318. * @param width defines the viewport width
  5319. * @param height defines the viewport height
  5320. * @param znear defines the near clip plane
  5321. * @param zfar defines the far clip plane
  5322. * @param result defines the target matrix
  5323. */
  5324. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5325. /**
  5326. * Create a left-handed orthographic projection matrix
  5327. * @param left defines the viewport left coordinate
  5328. * @param right defines the viewport right coordinate
  5329. * @param bottom defines the viewport bottom coordinate
  5330. * @param top defines the viewport top coordinate
  5331. * @param znear defines the near clip plane
  5332. * @param zfar defines the far clip plane
  5333. * @returns a new matrix as a left-handed orthographic projection matrix
  5334. */
  5335. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5336. /**
  5337. * Stores a left-handed orthographic projection into a given matrix
  5338. * @param left defines the viewport left coordinate
  5339. * @param right defines the viewport right coordinate
  5340. * @param bottom defines the viewport bottom coordinate
  5341. * @param top defines the viewport top coordinate
  5342. * @param znear defines the near clip plane
  5343. * @param zfar defines the far clip plane
  5344. * @param result defines the target matrix
  5345. */
  5346. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5347. /**
  5348. * Creates a right-handed orthographic projection matrix
  5349. * @param left defines the viewport left coordinate
  5350. * @param right defines the viewport right coordinate
  5351. * @param bottom defines the viewport bottom coordinate
  5352. * @param top defines the viewport top coordinate
  5353. * @param znear defines the near clip plane
  5354. * @param zfar defines the far clip plane
  5355. * @returns a new matrix as a right-handed orthographic projection matrix
  5356. */
  5357. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5358. /**
  5359. * Stores a right-handed orthographic projection into a given matrix
  5360. * @param left defines the viewport left coordinate
  5361. * @param right defines the viewport right coordinate
  5362. * @param bottom defines the viewport bottom coordinate
  5363. * @param top defines the viewport top coordinate
  5364. * @param znear defines the near clip plane
  5365. * @param zfar defines the far clip plane
  5366. * @param result defines the target matrix
  5367. */
  5368. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5369. /**
  5370. * Creates a left-handed perspective projection matrix
  5371. * @param width defines the viewport width
  5372. * @param height defines the viewport height
  5373. * @param znear defines the near clip plane
  5374. * @param zfar defines the far clip plane
  5375. * @returns a new matrix as a left-handed perspective projection matrix
  5376. */
  5377. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5378. /**
  5379. * Creates a left-handed perspective projection matrix
  5380. * @param fov defines the horizontal field of view
  5381. * @param aspect defines the aspect ratio
  5382. * @param znear defines the near clip plane
  5383. * @param zfar defines the far clip plane
  5384. * @returns a new matrix as a left-handed perspective projection matrix
  5385. */
  5386. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5387. /**
  5388. * Stores a left-handed perspective projection into a given matrix
  5389. * @param fov defines the horizontal field of view
  5390. * @param aspect defines the aspect ratio
  5391. * @param znear defines the near clip plane
  5392. * @param zfar defines the far clip plane
  5393. * @param result defines the target matrix
  5394. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5395. */
  5396. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5397. /**
  5398. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5399. * @param fov defines the horizontal field of view
  5400. * @param aspect defines the aspect ratio
  5401. * @param znear defines the near clip plane
  5402. * @param zfar not used as infinity is used as far clip
  5403. * @param result defines the target matrix
  5404. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5405. */
  5406. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5407. /**
  5408. * Creates a right-handed perspective projection matrix
  5409. * @param fov defines the horizontal field of view
  5410. * @param aspect defines the aspect ratio
  5411. * @param znear defines the near clip plane
  5412. * @param zfar defines the far clip plane
  5413. * @returns a new matrix as a right-handed perspective projection matrix
  5414. */
  5415. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5416. /**
  5417. * Stores a right-handed perspective projection into a given matrix
  5418. * @param fov defines the horizontal field of view
  5419. * @param aspect defines the aspect ratio
  5420. * @param znear defines the near clip plane
  5421. * @param zfar defines the far clip plane
  5422. * @param result defines the target matrix
  5423. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5424. */
  5425. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5426. /**
  5427. * Stores a right-handed perspective projection into a given matrix
  5428. * @param fov defines the horizontal field of view
  5429. * @param aspect defines the aspect ratio
  5430. * @param znear defines the near clip plane
  5431. * @param zfar not used as infinity is used as far clip
  5432. * @param result defines the target matrix
  5433. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5434. */
  5435. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5436. /**
  5437. * Stores a perspective projection for WebVR info a given matrix
  5438. * @param fov defines the field of view
  5439. * @param znear defines the near clip plane
  5440. * @param zfar defines the far clip plane
  5441. * @param result defines the target matrix
  5442. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5443. */
  5444. static PerspectiveFovWebVRToRef(fov: {
  5445. upDegrees: number;
  5446. downDegrees: number;
  5447. leftDegrees: number;
  5448. rightDegrees: number;
  5449. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5450. /**
  5451. * Computes a complete transformation matrix
  5452. * @param viewport defines the viewport to use
  5453. * @param world defines the world matrix
  5454. * @param view defines the view matrix
  5455. * @param projection defines the projection matrix
  5456. * @param zmin defines the near clip plane
  5457. * @param zmax defines the far clip plane
  5458. * @returns the transformation matrix
  5459. */
  5460. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5461. /**
  5462. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5463. * @param matrix defines the matrix to use
  5464. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5465. */
  5466. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5467. /**
  5468. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5469. * @param matrix defines the matrix to use
  5470. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5471. */
  5472. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5473. /**
  5474. * Compute the transpose of a given matrix
  5475. * @param matrix defines the matrix to transpose
  5476. * @returns the new matrix
  5477. */
  5478. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5479. /**
  5480. * Compute the transpose of a matrix and store it in a target matrix
  5481. * @param matrix defines the matrix to transpose
  5482. * @param result defines the target matrix
  5483. */
  5484. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5485. /**
  5486. * Computes a reflection matrix from a plane
  5487. * @param plane defines the reflection plane
  5488. * @returns a new matrix
  5489. */
  5490. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5491. /**
  5492. * Computes a reflection matrix from a plane
  5493. * @param plane defines the reflection plane
  5494. * @param result defines the target matrix
  5495. */
  5496. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5497. /**
  5498. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5499. * @param xaxis defines the value of the 1st axis
  5500. * @param yaxis defines the value of the 2nd axis
  5501. * @param zaxis defines the value of the 3rd axis
  5502. * @param result defines the target matrix
  5503. */
  5504. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5505. /**
  5506. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5507. * @param quat defines the quaternion to use
  5508. * @param result defines the target matrix
  5509. */
  5510. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5511. }
  5512. /**
  5513. * @hidden
  5514. */
  5515. export class TmpVectors {
  5516. static Vector2: Vector2[];
  5517. static Vector3: Vector3[];
  5518. static Vector4: Vector4[];
  5519. static Quaternion: Quaternion[];
  5520. static Matrix: Matrix[];
  5521. }
  5522. }
  5523. declare module BABYLON {
  5524. /**
  5525. * Defines potential orientation for back face culling
  5526. */
  5527. export enum Orientation {
  5528. /**
  5529. * Clockwise
  5530. */
  5531. CW = 0,
  5532. /** Counter clockwise */
  5533. CCW = 1
  5534. }
  5535. /** Class used to represent a Bezier curve */
  5536. export class BezierCurve {
  5537. /**
  5538. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5539. * @param t defines the time
  5540. * @param x1 defines the left coordinate on X axis
  5541. * @param y1 defines the left coordinate on Y axis
  5542. * @param x2 defines the right coordinate on X axis
  5543. * @param y2 defines the right coordinate on Y axis
  5544. * @returns the interpolated value
  5545. */
  5546. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5547. }
  5548. /**
  5549. * Defines angle representation
  5550. */
  5551. export class Angle {
  5552. private _radians;
  5553. /**
  5554. * Creates an Angle object of "radians" radians (float).
  5555. * @param radians the angle in radians
  5556. */
  5557. constructor(radians: number);
  5558. /**
  5559. * Get value in degrees
  5560. * @returns the Angle value in degrees (float)
  5561. */
  5562. degrees(): number;
  5563. /**
  5564. * Get value in radians
  5565. * @returns the Angle value in radians (float)
  5566. */
  5567. radians(): number;
  5568. /**
  5569. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5570. * @param a defines first point as the origin
  5571. * @param b defines point
  5572. * @returns a new Angle
  5573. */
  5574. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5575. /**
  5576. * Gets a new Angle object from the given float in radians
  5577. * @param radians defines the angle value in radians
  5578. * @returns a new Angle
  5579. */
  5580. static FromRadians(radians: number): Angle;
  5581. /**
  5582. * Gets a new Angle object from the given float in degrees
  5583. * @param degrees defines the angle value in degrees
  5584. * @returns a new Angle
  5585. */
  5586. static FromDegrees(degrees: number): Angle;
  5587. }
  5588. /**
  5589. * This represents an arc in a 2d space.
  5590. */
  5591. export class Arc2 {
  5592. /** Defines the start point of the arc */
  5593. startPoint: Vector2;
  5594. /** Defines the mid point of the arc */
  5595. midPoint: Vector2;
  5596. /** Defines the end point of the arc */
  5597. endPoint: Vector2;
  5598. /**
  5599. * Defines the center point of the arc.
  5600. */
  5601. centerPoint: Vector2;
  5602. /**
  5603. * Defines the radius of the arc.
  5604. */
  5605. radius: number;
  5606. /**
  5607. * Defines the angle of the arc (from mid point to end point).
  5608. */
  5609. angle: Angle;
  5610. /**
  5611. * Defines the start angle of the arc (from start point to middle point).
  5612. */
  5613. startAngle: Angle;
  5614. /**
  5615. * Defines the orientation of the arc (clock wise/counter clock wise).
  5616. */
  5617. orientation: Orientation;
  5618. /**
  5619. * Creates an Arc object from the three given points : start, middle and end.
  5620. * @param startPoint Defines the start point of the arc
  5621. * @param midPoint Defines the midlle point of the arc
  5622. * @param endPoint Defines the end point of the arc
  5623. */
  5624. constructor(
  5625. /** Defines the start point of the arc */
  5626. startPoint: Vector2,
  5627. /** Defines the mid point of the arc */
  5628. midPoint: Vector2,
  5629. /** Defines the end point of the arc */
  5630. endPoint: Vector2);
  5631. }
  5632. /**
  5633. * Represents a 2D path made up of multiple 2D points
  5634. */
  5635. export class Path2 {
  5636. private _points;
  5637. private _length;
  5638. /**
  5639. * If the path start and end point are the same
  5640. */
  5641. closed: boolean;
  5642. /**
  5643. * Creates a Path2 object from the starting 2D coordinates x and y.
  5644. * @param x the starting points x value
  5645. * @param y the starting points y value
  5646. */
  5647. constructor(x: number, y: number);
  5648. /**
  5649. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5650. * @param x the added points x value
  5651. * @param y the added points y value
  5652. * @returns the updated Path2.
  5653. */
  5654. addLineTo(x: number, y: number): Path2;
  5655. /**
  5656. * 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.
  5657. * @param midX middle point x value
  5658. * @param midY middle point y value
  5659. * @param endX end point x value
  5660. * @param endY end point y value
  5661. * @param numberOfSegments (default: 36)
  5662. * @returns the updated Path2.
  5663. */
  5664. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5665. /**
  5666. * Closes the Path2.
  5667. * @returns the Path2.
  5668. */
  5669. close(): Path2;
  5670. /**
  5671. * Gets the sum of the distance between each sequential point in the path
  5672. * @returns the Path2 total length (float).
  5673. */
  5674. length(): number;
  5675. /**
  5676. * Gets the points which construct the path
  5677. * @returns the Path2 internal array of points.
  5678. */
  5679. getPoints(): Vector2[];
  5680. /**
  5681. * Retreives the point at the distance aways from the starting point
  5682. * @param normalizedLengthPosition the length along the path to retreive the point from
  5683. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5684. */
  5685. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5686. /**
  5687. * Creates a new path starting from an x and y position
  5688. * @param x starting x value
  5689. * @param y starting y value
  5690. * @returns a new Path2 starting at the coordinates (x, y).
  5691. */
  5692. static StartingAt(x: number, y: number): Path2;
  5693. }
  5694. /**
  5695. * Represents a 3D path made up of multiple 3D points
  5696. */
  5697. export class Path3D {
  5698. /**
  5699. * an array of Vector3, the curve axis of the Path3D
  5700. */
  5701. path: Vector3[];
  5702. private _curve;
  5703. private _distances;
  5704. private _tangents;
  5705. private _normals;
  5706. private _binormals;
  5707. private _raw;
  5708. private _alignTangentsWithPath;
  5709. private readonly _pointAtData;
  5710. /**
  5711. * new Path3D(path, normal, raw)
  5712. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5713. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5714. * @param path an array of Vector3, the curve axis of the Path3D
  5715. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5716. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5717. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5718. */
  5719. constructor(
  5720. /**
  5721. * an array of Vector3, the curve axis of the Path3D
  5722. */
  5723. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5724. /**
  5725. * Returns the Path3D array of successive Vector3 designing its curve.
  5726. * @returns the Path3D array of successive Vector3 designing its curve.
  5727. */
  5728. getCurve(): Vector3[];
  5729. /**
  5730. * Returns the Path3D array of successive Vector3 designing its curve.
  5731. * @returns the Path3D array of successive Vector3 designing its curve.
  5732. */
  5733. getPoints(): Vector3[];
  5734. /**
  5735. * @returns the computed length (float) of the path.
  5736. */
  5737. length(): number;
  5738. /**
  5739. * Returns an array populated with tangent vectors on each Path3D curve point.
  5740. * @returns an array populated with tangent vectors on each Path3D curve point.
  5741. */
  5742. getTangents(): Vector3[];
  5743. /**
  5744. * Returns an array populated with normal vectors on each Path3D curve point.
  5745. * @returns an array populated with normal vectors on each Path3D curve point.
  5746. */
  5747. getNormals(): Vector3[];
  5748. /**
  5749. * Returns an array populated with binormal vectors on each Path3D curve point.
  5750. * @returns an array populated with binormal vectors on each Path3D curve point.
  5751. */
  5752. getBinormals(): Vector3[];
  5753. /**
  5754. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5755. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5756. */
  5757. getDistances(): number[];
  5758. /**
  5759. * Returns an interpolated point along this path
  5760. * @param position the position of the point along this path, from 0.0 to 1.0
  5761. * @returns a new Vector3 as the point
  5762. */
  5763. getPointAt(position: number): Vector3;
  5764. /**
  5765. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5766. * @param position the position of the point along this path, from 0.0 to 1.0
  5767. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5768. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5769. */
  5770. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5771. /**
  5772. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5773. * @param position the position of the point along this path, from 0.0 to 1.0
  5774. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5775. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5776. */
  5777. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5778. /**
  5779. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5780. * @param position the position of the point along this path, from 0.0 to 1.0
  5781. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5782. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5783. */
  5784. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5785. /**
  5786. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5787. * @param position the position of the point along this path, from 0.0 to 1.0
  5788. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5789. */
  5790. getDistanceAt(position: number): number;
  5791. /**
  5792. * Returns the array index of the previous point of an interpolated point along this path
  5793. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5794. * @returns the array index
  5795. */
  5796. getPreviousPointIndexAt(position: number): number;
  5797. /**
  5798. * 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)
  5799. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5800. * @returns the sub position
  5801. */
  5802. getSubPositionAt(position: number): number;
  5803. /**
  5804. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5805. * @param target the vector of which to get the closest position to
  5806. * @returns the position of the closest virtual point on this path to the target vector
  5807. */
  5808. getClosestPositionTo(target: Vector3): number;
  5809. /**
  5810. * Returns a sub path (slice) of this path
  5811. * @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
  5812. * @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
  5813. * @returns a sub path (slice) of this path
  5814. */
  5815. slice(start?: number, end?: number): Path3D;
  5816. /**
  5817. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5818. * @param path path which all values are copied into the curves points
  5819. * @param firstNormal which should be projected onto the curve
  5820. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5821. * @returns the same object updated.
  5822. */
  5823. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5824. private _compute;
  5825. private _getFirstNonNullVector;
  5826. private _getLastNonNullVector;
  5827. private _normalVector;
  5828. /**
  5829. * Updates the point at data for an interpolated point along this curve
  5830. * @param position the position of the point along this curve, from 0.0 to 1.0
  5831. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5832. * @returns the (updated) point at data
  5833. */
  5834. private _updatePointAtData;
  5835. /**
  5836. * Updates the point at data from the specified parameters
  5837. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5838. * @param point the interpolated point
  5839. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5840. */
  5841. private _setPointAtData;
  5842. /**
  5843. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5844. */
  5845. private _updateInterpolationMatrix;
  5846. }
  5847. /**
  5848. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5849. * A Curve3 is designed from a series of successive Vector3.
  5850. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5851. */
  5852. export class Curve3 {
  5853. private _points;
  5854. private _length;
  5855. /**
  5856. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5857. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5858. * @param v1 (Vector3) the control point
  5859. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5860. * @param nbPoints (integer) the wanted number of points in the curve
  5861. * @returns the created Curve3
  5862. */
  5863. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5864. /**
  5865. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5866. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5867. * @param v1 (Vector3) the first control point
  5868. * @param v2 (Vector3) the second control point
  5869. * @param v3 (Vector3) the end point of the Cubic Bezier
  5870. * @param nbPoints (integer) the wanted number of points in the curve
  5871. * @returns the created Curve3
  5872. */
  5873. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5874. /**
  5875. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5876. * @param p1 (Vector3) the origin point of the Hermite Spline
  5877. * @param t1 (Vector3) the tangent vector at the origin point
  5878. * @param p2 (Vector3) the end point of the Hermite Spline
  5879. * @param t2 (Vector3) the tangent vector at the end point
  5880. * @param nbPoints (integer) the wanted number of points in the curve
  5881. * @returns the created Curve3
  5882. */
  5883. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5884. /**
  5885. * Returns a Curve3 object along a CatmullRom Spline curve :
  5886. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5887. * @param nbPoints (integer) the wanted number of points between each curve control points
  5888. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5889. * @returns the created Curve3
  5890. */
  5891. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5892. /**
  5893. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5894. * A Curve3 is designed from a series of successive Vector3.
  5895. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5896. * @param points points which make up the curve
  5897. */
  5898. constructor(points: Vector3[]);
  5899. /**
  5900. * @returns the Curve3 stored array of successive Vector3
  5901. */
  5902. getPoints(): Vector3[];
  5903. /**
  5904. * @returns the computed length (float) of the curve.
  5905. */
  5906. length(): number;
  5907. /**
  5908. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5909. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5910. * curveA and curveB keep unchanged.
  5911. * @param curve the curve to continue from this curve
  5912. * @returns the newly constructed curve
  5913. */
  5914. continue(curve: DeepImmutable<Curve3>): Curve3;
  5915. private _computeLength;
  5916. }
  5917. }
  5918. declare module BABYLON {
  5919. /**
  5920. * This represents the main contract an easing function should follow.
  5921. * Easing functions are used throughout the animation system.
  5922. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5923. */
  5924. export interface IEasingFunction {
  5925. /**
  5926. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5927. * of the easing function.
  5928. * The link below provides some of the most common examples of easing functions.
  5929. * @see https://easings.net/
  5930. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5931. * @returns the corresponding value on the curve defined by the easing function
  5932. */
  5933. ease(gradient: number): number;
  5934. }
  5935. /**
  5936. * Base class used for every default easing function.
  5937. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5938. */
  5939. export class EasingFunction implements IEasingFunction {
  5940. /**
  5941. * Interpolation follows the mathematical formula associated with the easing function.
  5942. */
  5943. static readonly EASINGMODE_EASEIN: number;
  5944. /**
  5945. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5946. */
  5947. static readonly EASINGMODE_EASEOUT: number;
  5948. /**
  5949. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5950. */
  5951. static readonly EASINGMODE_EASEINOUT: number;
  5952. private _easingMode;
  5953. /**
  5954. * Sets the easing mode of the current function.
  5955. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5956. */
  5957. setEasingMode(easingMode: number): void;
  5958. /**
  5959. * Gets the current easing mode.
  5960. * @returns the easing mode
  5961. */
  5962. getEasingMode(): number;
  5963. /**
  5964. * @hidden
  5965. */
  5966. easeInCore(gradient: number): number;
  5967. /**
  5968. * Given an input gradient between 0 and 1, this returns the corresponding value
  5969. * of the easing function.
  5970. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5971. * @returns the corresponding value on the curve defined by the easing function
  5972. */
  5973. ease(gradient: number): number;
  5974. }
  5975. /**
  5976. * Easing function with a circle shape (see link below).
  5977. * @see https://easings.net/#easeInCirc
  5978. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5979. */
  5980. export class CircleEase extends EasingFunction implements IEasingFunction {
  5981. /** @hidden */
  5982. easeInCore(gradient: number): number;
  5983. }
  5984. /**
  5985. * Easing function with a ease back shape (see link below).
  5986. * @see https://easings.net/#easeInBack
  5987. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5988. */
  5989. export class BackEase extends EasingFunction implements IEasingFunction {
  5990. /** Defines the amplitude of the function */
  5991. amplitude: number;
  5992. /**
  5993. * Instantiates a back ease easing
  5994. * @see https://easings.net/#easeInBack
  5995. * @param amplitude Defines the amplitude of the function
  5996. */
  5997. constructor(
  5998. /** Defines the amplitude of the function */
  5999. amplitude?: number);
  6000. /** @hidden */
  6001. easeInCore(gradient: number): number;
  6002. }
  6003. /**
  6004. * Easing function with a bouncing shape (see link below).
  6005. * @see https://easings.net/#easeInBounce
  6006. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6007. */
  6008. export class BounceEase extends EasingFunction implements IEasingFunction {
  6009. /** Defines the number of bounces */
  6010. bounces: number;
  6011. /** Defines the amplitude of the bounce */
  6012. bounciness: number;
  6013. /**
  6014. * Instantiates a bounce easing
  6015. * @see https://easings.net/#easeInBounce
  6016. * @param bounces Defines the number of bounces
  6017. * @param bounciness Defines the amplitude of the bounce
  6018. */
  6019. constructor(
  6020. /** Defines the number of bounces */
  6021. bounces?: number,
  6022. /** Defines the amplitude of the bounce */
  6023. bounciness?: number);
  6024. /** @hidden */
  6025. easeInCore(gradient: number): number;
  6026. }
  6027. /**
  6028. * Easing function with a power of 3 shape (see link below).
  6029. * @see https://easings.net/#easeInCubic
  6030. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6031. */
  6032. export class CubicEase extends EasingFunction implements IEasingFunction {
  6033. /** @hidden */
  6034. easeInCore(gradient: number): number;
  6035. }
  6036. /**
  6037. * Easing function with an elastic shape (see link below).
  6038. * @see https://easings.net/#easeInElastic
  6039. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6040. */
  6041. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6042. /** Defines the number of oscillations*/
  6043. oscillations: number;
  6044. /** Defines the amplitude of the oscillations*/
  6045. springiness: number;
  6046. /**
  6047. * Instantiates an elastic easing function
  6048. * @see https://easings.net/#easeInElastic
  6049. * @param oscillations Defines the number of oscillations
  6050. * @param springiness Defines the amplitude of the oscillations
  6051. */
  6052. constructor(
  6053. /** Defines the number of oscillations*/
  6054. oscillations?: number,
  6055. /** Defines the amplitude of the oscillations*/
  6056. springiness?: number);
  6057. /** @hidden */
  6058. easeInCore(gradient: number): number;
  6059. }
  6060. /**
  6061. * Easing function with an exponential shape (see link below).
  6062. * @see https://easings.net/#easeInExpo
  6063. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6064. */
  6065. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6066. /** Defines the exponent of the function */
  6067. exponent: number;
  6068. /**
  6069. * Instantiates an exponential easing function
  6070. * @see https://easings.net/#easeInExpo
  6071. * @param exponent Defines the exponent of the function
  6072. */
  6073. constructor(
  6074. /** Defines the exponent of the function */
  6075. exponent?: number);
  6076. /** @hidden */
  6077. easeInCore(gradient: number): number;
  6078. }
  6079. /**
  6080. * Easing function with a power shape (see link below).
  6081. * @see https://easings.net/#easeInQuad
  6082. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6083. */
  6084. export class PowerEase extends EasingFunction implements IEasingFunction {
  6085. /** Defines the power of the function */
  6086. power: number;
  6087. /**
  6088. * Instantiates an power base easing function
  6089. * @see https://easings.net/#easeInQuad
  6090. * @param power Defines the power of the function
  6091. */
  6092. constructor(
  6093. /** Defines the power of the function */
  6094. power?: number);
  6095. /** @hidden */
  6096. easeInCore(gradient: number): number;
  6097. }
  6098. /**
  6099. * Easing function with a power of 2 shape (see link below).
  6100. * @see https://easings.net/#easeInQuad
  6101. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6102. */
  6103. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6104. /** @hidden */
  6105. easeInCore(gradient: number): number;
  6106. }
  6107. /**
  6108. * Easing function with a power of 4 shape (see link below).
  6109. * @see https://easings.net/#easeInQuart
  6110. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6111. */
  6112. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6113. /** @hidden */
  6114. easeInCore(gradient: number): number;
  6115. }
  6116. /**
  6117. * Easing function with a power of 5 shape (see link below).
  6118. * @see https://easings.net/#easeInQuint
  6119. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6120. */
  6121. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6122. /** @hidden */
  6123. easeInCore(gradient: number): number;
  6124. }
  6125. /**
  6126. * Easing function with a sin shape (see link below).
  6127. * @see https://easings.net/#easeInSine
  6128. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6129. */
  6130. export class SineEase extends EasingFunction implements IEasingFunction {
  6131. /** @hidden */
  6132. easeInCore(gradient: number): number;
  6133. }
  6134. /**
  6135. * Easing function with a bezier shape (see link below).
  6136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6137. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6138. */
  6139. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6140. /** Defines the x component of the start tangent in the bezier curve */
  6141. x1: number;
  6142. /** Defines the y component of the start tangent in the bezier curve */
  6143. y1: number;
  6144. /** Defines the x component of the end tangent in the bezier curve */
  6145. x2: number;
  6146. /** Defines the y component of the end tangent in the bezier curve */
  6147. y2: number;
  6148. /**
  6149. * Instantiates a bezier function
  6150. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6151. * @param x1 Defines the x component of the start tangent in the bezier curve
  6152. * @param y1 Defines the y component of the start tangent in the bezier curve
  6153. * @param x2 Defines the x component of the end tangent in the bezier curve
  6154. * @param y2 Defines the y component of the end tangent in the bezier curve
  6155. */
  6156. constructor(
  6157. /** Defines the x component of the start tangent in the bezier curve */
  6158. x1?: number,
  6159. /** Defines the y component of the start tangent in the bezier curve */
  6160. y1?: number,
  6161. /** Defines the x component of the end tangent in the bezier curve */
  6162. x2?: number,
  6163. /** Defines the y component of the end tangent in the bezier curve */
  6164. y2?: number);
  6165. /** @hidden */
  6166. easeInCore(gradient: number): number;
  6167. }
  6168. }
  6169. declare module BABYLON {
  6170. /**
  6171. * Class used to hold a RGB color
  6172. */
  6173. export class Color3 {
  6174. /**
  6175. * Defines the red component (between 0 and 1, default is 0)
  6176. */
  6177. r: number;
  6178. /**
  6179. * Defines the green component (between 0 and 1, default is 0)
  6180. */
  6181. g: number;
  6182. /**
  6183. * Defines the blue component (between 0 and 1, default is 0)
  6184. */
  6185. b: number;
  6186. /**
  6187. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6188. * @param r defines the red component (between 0 and 1, default is 0)
  6189. * @param g defines the green component (between 0 and 1, default is 0)
  6190. * @param b defines the blue component (between 0 and 1, default is 0)
  6191. */
  6192. constructor(
  6193. /**
  6194. * Defines the red component (between 0 and 1, default is 0)
  6195. */
  6196. r?: number,
  6197. /**
  6198. * Defines the green component (between 0 and 1, default is 0)
  6199. */
  6200. g?: number,
  6201. /**
  6202. * Defines the blue component (between 0 and 1, default is 0)
  6203. */
  6204. b?: number);
  6205. /**
  6206. * Creates a string with the Color3 current values
  6207. * @returns the string representation of the Color3 object
  6208. */
  6209. toString(): string;
  6210. /**
  6211. * Returns the string "Color3"
  6212. * @returns "Color3"
  6213. */
  6214. getClassName(): string;
  6215. /**
  6216. * Compute the Color3 hash code
  6217. * @returns an unique number that can be used to hash Color3 objects
  6218. */
  6219. getHashCode(): number;
  6220. /**
  6221. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6222. * @param array defines the array where to store the r,g,b components
  6223. * @param index defines an optional index in the target array to define where to start storing values
  6224. * @returns the current Color3 object
  6225. */
  6226. toArray(array: FloatArray, index?: number): Color3;
  6227. /**
  6228. * Update the current color with values stored in an array from the starting index of the given array
  6229. * @param array defines the source array
  6230. * @param offset defines an offset in the source array
  6231. * @returns the current Color3 object
  6232. */
  6233. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6234. /**
  6235. * Returns a new Color4 object from the current Color3 and the given alpha
  6236. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6237. * @returns a new Color4 object
  6238. */
  6239. toColor4(alpha?: number): Color4;
  6240. /**
  6241. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6242. * @returns the new array
  6243. */
  6244. asArray(): number[];
  6245. /**
  6246. * Returns the luminance value
  6247. * @returns a float value
  6248. */
  6249. toLuminance(): number;
  6250. /**
  6251. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6252. * @param otherColor defines the second operand
  6253. * @returns the new Color3 object
  6254. */
  6255. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6256. /**
  6257. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6258. * @param otherColor defines the second operand
  6259. * @param result defines the Color3 object where to store the result
  6260. * @returns the current Color3
  6261. */
  6262. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6263. /**
  6264. * Determines equality between Color3 objects
  6265. * @param otherColor defines the second operand
  6266. * @returns true if the rgb values are equal to the given ones
  6267. */
  6268. equals(otherColor: DeepImmutable<Color3>): boolean;
  6269. /**
  6270. * Determines equality between the current Color3 object and a set of r,b,g values
  6271. * @param r defines the red component to check
  6272. * @param g defines the green component to check
  6273. * @param b defines the blue component to check
  6274. * @returns true if the rgb values are equal to the given ones
  6275. */
  6276. equalsFloats(r: number, g: number, b: number): boolean;
  6277. /**
  6278. * Multiplies in place each rgb value by scale
  6279. * @param scale defines the scaling factor
  6280. * @returns the updated Color3
  6281. */
  6282. scale(scale: number): Color3;
  6283. /**
  6284. * Multiplies the rgb values by scale and stores the result into "result"
  6285. * @param scale defines the scaling factor
  6286. * @param result defines the Color3 object where to store the result
  6287. * @returns the unmodified current Color3
  6288. */
  6289. scaleToRef(scale: number, result: Color3): Color3;
  6290. /**
  6291. * Scale the current Color3 values by a factor and add the result to a given Color3
  6292. * @param scale defines the scale factor
  6293. * @param result defines color to store the result into
  6294. * @returns the unmodified current Color3
  6295. */
  6296. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6297. /**
  6298. * Clamps the rgb values by the min and max values and stores the result into "result"
  6299. * @param min defines minimum clamping value (default is 0)
  6300. * @param max defines maximum clamping value (default is 1)
  6301. * @param result defines color to store the result into
  6302. * @returns the original Color3
  6303. */
  6304. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6305. /**
  6306. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6307. * @param otherColor defines the second operand
  6308. * @returns the new Color3
  6309. */
  6310. add(otherColor: DeepImmutable<Color3>): Color3;
  6311. /**
  6312. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6313. * @param otherColor defines the second operand
  6314. * @param result defines Color3 object to store the result into
  6315. * @returns the unmodified current Color3
  6316. */
  6317. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6318. /**
  6319. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6320. * @param otherColor defines the second operand
  6321. * @returns the new Color3
  6322. */
  6323. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6324. /**
  6325. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6326. * @param otherColor defines the second operand
  6327. * @param result defines Color3 object to store the result into
  6328. * @returns the unmodified current Color3
  6329. */
  6330. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6331. /**
  6332. * Copy the current object
  6333. * @returns a new Color3 copied the current one
  6334. */
  6335. clone(): Color3;
  6336. /**
  6337. * Copies the rgb values from the source in the current Color3
  6338. * @param source defines the source Color3 object
  6339. * @returns the updated Color3 object
  6340. */
  6341. copyFrom(source: DeepImmutable<Color3>): Color3;
  6342. /**
  6343. * Updates the Color3 rgb values from the given floats
  6344. * @param r defines the red component to read from
  6345. * @param g defines the green component to read from
  6346. * @param b defines the blue component to read from
  6347. * @returns the current Color3 object
  6348. */
  6349. copyFromFloats(r: number, g: number, b: number): 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. set(r: number, g: number, b: number): Color3;
  6358. /**
  6359. * Compute the Color3 hexadecimal code as a string
  6360. * @returns a string containing the hexadecimal representation of the Color3 object
  6361. */
  6362. toHexString(): string;
  6363. /**
  6364. * Computes a new Color3 converted from the current one to linear space
  6365. * @returns a new Color3 object
  6366. */
  6367. toLinearSpace(): Color3;
  6368. /**
  6369. * Converts current color in rgb space to HSV values
  6370. * @returns a new color3 representing the HSV values
  6371. */
  6372. toHSV(): Color3;
  6373. /**
  6374. * Converts current color in rgb space to HSV values
  6375. * @param result defines the Color3 where to store the HSV values
  6376. */
  6377. toHSVToRef(result: Color3): void;
  6378. /**
  6379. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6380. * @param convertedColor defines the Color3 object where to store the linear space version
  6381. * @returns the unmodified Color3
  6382. */
  6383. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6384. /**
  6385. * Computes a new Color3 converted from the current one to gamma space
  6386. * @returns a new Color3 object
  6387. */
  6388. toGammaSpace(): Color3;
  6389. /**
  6390. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6391. * @param convertedColor defines the Color3 object where to store the gamma space version
  6392. * @returns the unmodified Color3
  6393. */
  6394. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6395. private static _BlackReadOnly;
  6396. /**
  6397. * Convert Hue, saturation and value to a Color3 (RGB)
  6398. * @param hue defines the hue
  6399. * @param saturation defines the saturation
  6400. * @param value defines the value
  6401. * @param result defines the Color3 where to store the RGB values
  6402. */
  6403. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6404. /**
  6405. * Creates a new Color3 from the string containing valid hexadecimal values
  6406. * @param hex defines a string containing valid hexadecimal values
  6407. * @returns a new Color3 object
  6408. */
  6409. static FromHexString(hex: string): Color3;
  6410. /**
  6411. * Creates a new Color3 from the starting index of the given array
  6412. * @param array defines the source array
  6413. * @param offset defines an offset in the source array
  6414. * @returns a new Color3 object
  6415. */
  6416. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6417. /**
  6418. * Creates a new Color3 from the starting index element of the given array
  6419. * @param array defines the source array to read from
  6420. * @param offset defines the offset in the source array
  6421. * @param result defines the target Color3 object
  6422. */
  6423. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6424. /**
  6425. * Creates a new Color3 from integer values (< 256)
  6426. * @param r defines the red component to read from (value between 0 and 255)
  6427. * @param g defines the green component to read from (value between 0 and 255)
  6428. * @param b defines the blue component to read from (value between 0 and 255)
  6429. * @returns a new Color3 object
  6430. */
  6431. static FromInts(r: number, g: number, b: number): Color3;
  6432. /**
  6433. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6434. * @param start defines the start Color3 value
  6435. * @param end defines the end Color3 value
  6436. * @param amount defines the gradient value between start and end
  6437. * @returns a new Color3 object
  6438. */
  6439. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6440. /**
  6441. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6442. * @param left defines the start value
  6443. * @param right defines the end value
  6444. * @param amount defines the gradient factor
  6445. * @param result defines the Color3 object where to store the result
  6446. */
  6447. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6448. /**
  6449. * Returns a Color3 value containing a red color
  6450. * @returns a new Color3 object
  6451. */
  6452. static Red(): Color3;
  6453. /**
  6454. * Returns a Color3 value containing a green color
  6455. * @returns a new Color3 object
  6456. */
  6457. static Green(): Color3;
  6458. /**
  6459. * Returns a Color3 value containing a blue color
  6460. * @returns a new Color3 object
  6461. */
  6462. static Blue(): Color3;
  6463. /**
  6464. * Returns a Color3 value containing a black color
  6465. * @returns a new Color3 object
  6466. */
  6467. static Black(): Color3;
  6468. /**
  6469. * Gets a Color3 value containing a black color that must not be updated
  6470. */
  6471. static get BlackReadOnly(): DeepImmutable<Color3>;
  6472. /**
  6473. * Returns a Color3 value containing a white color
  6474. * @returns a new Color3 object
  6475. */
  6476. static White(): Color3;
  6477. /**
  6478. * Returns a Color3 value containing a purple color
  6479. * @returns a new Color3 object
  6480. */
  6481. static Purple(): Color3;
  6482. /**
  6483. * Returns a Color3 value containing a magenta color
  6484. * @returns a new Color3 object
  6485. */
  6486. static Magenta(): Color3;
  6487. /**
  6488. * Returns a Color3 value containing a yellow color
  6489. * @returns a new Color3 object
  6490. */
  6491. static Yellow(): Color3;
  6492. /**
  6493. * Returns a Color3 value containing a gray color
  6494. * @returns a new Color3 object
  6495. */
  6496. static Gray(): Color3;
  6497. /**
  6498. * Returns a Color3 value containing a teal color
  6499. * @returns a new Color3 object
  6500. */
  6501. static Teal(): Color3;
  6502. /**
  6503. * Returns a Color3 value containing a random color
  6504. * @returns a new Color3 object
  6505. */
  6506. static Random(): Color3;
  6507. }
  6508. /**
  6509. * Class used to hold a RBGA color
  6510. */
  6511. export class Color4 {
  6512. /**
  6513. * Defines the red component (between 0 and 1, default is 0)
  6514. */
  6515. r: number;
  6516. /**
  6517. * Defines the green component (between 0 and 1, default is 0)
  6518. */
  6519. g: number;
  6520. /**
  6521. * Defines the blue component (between 0 and 1, default is 0)
  6522. */
  6523. b: number;
  6524. /**
  6525. * Defines the alpha component (between 0 and 1, default is 1)
  6526. */
  6527. a: number;
  6528. /**
  6529. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6530. * @param r defines the red component (between 0 and 1, default is 0)
  6531. * @param g defines the green component (between 0 and 1, default is 0)
  6532. * @param b defines the blue component (between 0 and 1, default is 0)
  6533. * @param a defines the alpha component (between 0 and 1, default is 1)
  6534. */
  6535. constructor(
  6536. /**
  6537. * Defines the red component (between 0 and 1, default is 0)
  6538. */
  6539. r?: number,
  6540. /**
  6541. * Defines the green component (between 0 and 1, default is 0)
  6542. */
  6543. g?: number,
  6544. /**
  6545. * Defines the blue component (between 0 and 1, default is 0)
  6546. */
  6547. b?: number,
  6548. /**
  6549. * Defines the alpha component (between 0 and 1, default is 1)
  6550. */
  6551. a?: number);
  6552. /**
  6553. * Adds in place the given Color4 values to the current Color4 object
  6554. * @param right defines the second operand
  6555. * @returns the current updated Color4 object
  6556. */
  6557. addInPlace(right: DeepImmutable<Color4>): Color4;
  6558. /**
  6559. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6560. * @returns the new array
  6561. */
  6562. asArray(): number[];
  6563. /**
  6564. * Stores from the starting index in the given array the Color4 successive values
  6565. * @param array defines the array where to store the r,g,b components
  6566. * @param index defines an optional index in the target array to define where to start storing values
  6567. * @returns the current Color4 object
  6568. */
  6569. toArray(array: number[], index?: number): Color4;
  6570. /**
  6571. * Update the current color with values stored in an array from the starting index of the given array
  6572. * @param array defines the source array
  6573. * @param offset defines an offset in the source array
  6574. * @returns the current Color4 object
  6575. */
  6576. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6577. /**
  6578. * Determines equality between Color4 objects
  6579. * @param otherColor defines the second operand
  6580. * @returns true if the rgba values are equal to the given ones
  6581. */
  6582. equals(otherColor: DeepImmutable<Color4>): boolean;
  6583. /**
  6584. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6585. * @param right defines the second operand
  6586. * @returns a new Color4 object
  6587. */
  6588. add(right: DeepImmutable<Color4>): Color4;
  6589. /**
  6590. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6591. * @param right defines the second operand
  6592. * @returns a new Color4 object
  6593. */
  6594. subtract(right: DeepImmutable<Color4>): Color4;
  6595. /**
  6596. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6597. * @param right defines the second operand
  6598. * @param result defines the Color4 object where to store the result
  6599. * @returns the current Color4 object
  6600. */
  6601. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6602. /**
  6603. * Creates a new Color4 with the current Color4 values multiplied by scale
  6604. * @param scale defines the scaling factor to apply
  6605. * @returns a new Color4 object
  6606. */
  6607. scale(scale: number): Color4;
  6608. /**
  6609. * Multiplies the current Color4 values by scale and stores the result in "result"
  6610. * @param scale defines the scaling factor to apply
  6611. * @param result defines the Color4 object where to store the result
  6612. * @returns the current unmodified Color4
  6613. */
  6614. scaleToRef(scale: number, result: Color4): Color4;
  6615. /**
  6616. * Scale the current Color4 values by a factor and add the result to a given Color4
  6617. * @param scale defines the scale factor
  6618. * @param result defines the Color4 object where to store the result
  6619. * @returns the unmodified current Color4
  6620. */
  6621. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6622. /**
  6623. * Clamps the rgb values by the min and max values and stores the result into "result"
  6624. * @param min defines minimum clamping value (default is 0)
  6625. * @param max defines maximum clamping value (default is 1)
  6626. * @param result defines color to store the result into.
  6627. * @returns the cuurent Color4
  6628. */
  6629. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6630. /**
  6631. * Multipy an Color4 value by another and return a new Color4 object
  6632. * @param color defines the Color4 value to multiply by
  6633. * @returns a new Color4 object
  6634. */
  6635. multiply(color: Color4): Color4;
  6636. /**
  6637. * Multipy a Color4 value by another and push the result in a reference value
  6638. * @param color defines the Color4 value to multiply by
  6639. * @param result defines the Color4 to fill the result in
  6640. * @returns the result Color4
  6641. */
  6642. multiplyToRef(color: Color4, result: Color4): Color4;
  6643. /**
  6644. * Creates a string with the Color4 current values
  6645. * @returns the string representation of the Color4 object
  6646. */
  6647. toString(): string;
  6648. /**
  6649. * Returns the string "Color4"
  6650. * @returns "Color4"
  6651. */
  6652. getClassName(): string;
  6653. /**
  6654. * Compute the Color4 hash code
  6655. * @returns an unique number that can be used to hash Color4 objects
  6656. */
  6657. getHashCode(): number;
  6658. /**
  6659. * Creates a new Color4 copied from the current one
  6660. * @returns a new Color4 object
  6661. */
  6662. clone(): Color4;
  6663. /**
  6664. * Copies the given Color4 values into the current one
  6665. * @param source defines the source Color4 object
  6666. * @returns the current updated Color4 object
  6667. */
  6668. copyFrom(source: Color4): Color4;
  6669. /**
  6670. * Copies the given float values into the current one
  6671. * @param r defines the red component to read from
  6672. * @param g defines the green component to read from
  6673. * @param b defines the blue component to read from
  6674. * @param a defines the alpha component to read from
  6675. * @returns the current updated Color4 object
  6676. */
  6677. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6678. /**
  6679. * Copies the given float values into the current one
  6680. * @param r defines the red component to read from
  6681. * @param g defines the green component to read from
  6682. * @param b defines the blue component to read from
  6683. * @param a defines the alpha component to read from
  6684. * @returns the current updated Color4 object
  6685. */
  6686. set(r: number, g: number, b: number, a: number): Color4;
  6687. /**
  6688. * Compute the Color4 hexadecimal code as a string
  6689. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6690. * @returns a string containing the hexadecimal representation of the Color4 object
  6691. */
  6692. toHexString(returnAsColor3?: boolean): string;
  6693. /**
  6694. * Computes a new Color4 converted from the current one to linear space
  6695. * @returns a new Color4 object
  6696. */
  6697. toLinearSpace(): Color4;
  6698. /**
  6699. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6700. * @param convertedColor defines the Color4 object where to store the linear space version
  6701. * @returns the unmodified Color4
  6702. */
  6703. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6704. /**
  6705. * Computes a new Color4 converted from the current one to gamma space
  6706. * @returns a new Color4 object
  6707. */
  6708. toGammaSpace(): Color4;
  6709. /**
  6710. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6711. * @param convertedColor defines the Color4 object where to store the gamma space version
  6712. * @returns the unmodified Color4
  6713. */
  6714. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6715. /**
  6716. * Creates a new Color4 from the string containing valid hexadecimal values
  6717. * @param hex defines a string containing valid hexadecimal values
  6718. * @returns a new Color4 object
  6719. */
  6720. static FromHexString(hex: string): Color4;
  6721. /**
  6722. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6723. * @param left defines the start value
  6724. * @param right defines the end value
  6725. * @param amount defines the gradient factor
  6726. * @returns a new Color4 object
  6727. */
  6728. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6729. /**
  6730. * Set the given "result" 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. * @param result defines the Color4 object where to store data
  6735. */
  6736. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6737. /**
  6738. * Creates a new Color4 from a Color3 and an alpha value
  6739. * @param color3 defines the source Color3 to read from
  6740. * @param alpha defines the alpha component (1.0 by default)
  6741. * @returns a new Color4 object
  6742. */
  6743. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6744. /**
  6745. * Creates a new Color4 from the starting index element of the given array
  6746. * @param array defines the source array to read from
  6747. * @param offset defines the offset in the source array
  6748. * @returns a new Color4 object
  6749. */
  6750. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6751. /**
  6752. * Creates a new Color4 from the starting index element of the given array
  6753. * @param array defines the source array to read from
  6754. * @param offset defines the offset in the source array
  6755. * @param result defines the target Color4 object
  6756. */
  6757. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6758. /**
  6759. * Creates a new Color3 from integer values (< 256)
  6760. * @param r defines the red component to read from (value between 0 and 255)
  6761. * @param g defines the green component to read from (value between 0 and 255)
  6762. * @param b defines the blue component to read from (value between 0 and 255)
  6763. * @param a defines the alpha component to read from (value between 0 and 255)
  6764. * @returns a new Color3 object
  6765. */
  6766. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6767. /**
  6768. * Check the content of a given array and convert it to an array containing RGBA data
  6769. * If the original array was already containing count * 4 values then it is returned directly
  6770. * @param colors defines the array to check
  6771. * @param count defines the number of RGBA data to expect
  6772. * @returns an array containing count * 4 values (RGBA)
  6773. */
  6774. static CheckColors4(colors: number[], count: number): number[];
  6775. }
  6776. /**
  6777. * @hidden
  6778. */
  6779. export class TmpColors {
  6780. static Color3: Color3[];
  6781. static Color4: Color4[];
  6782. }
  6783. }
  6784. declare module BABYLON {
  6785. /**
  6786. * Defines an interface which represents an animation key frame
  6787. */
  6788. export interface IAnimationKey {
  6789. /**
  6790. * Frame of the key frame
  6791. */
  6792. frame: number;
  6793. /**
  6794. * Value at the specifies key frame
  6795. */
  6796. value: any;
  6797. /**
  6798. * The input tangent for the cubic hermite spline
  6799. */
  6800. inTangent?: any;
  6801. /**
  6802. * The output tangent for the cubic hermite spline
  6803. */
  6804. outTangent?: any;
  6805. /**
  6806. * The animation interpolation type
  6807. */
  6808. interpolation?: AnimationKeyInterpolation;
  6809. }
  6810. /**
  6811. * Enum for the animation key frame interpolation type
  6812. */
  6813. export enum AnimationKeyInterpolation {
  6814. /**
  6815. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6816. */
  6817. STEP = 1
  6818. }
  6819. }
  6820. declare module BABYLON {
  6821. /**
  6822. * Represents the range of an animation
  6823. */
  6824. export class AnimationRange {
  6825. /**The name of the animation range**/
  6826. name: string;
  6827. /**The starting frame of the animation */
  6828. from: number;
  6829. /**The ending frame of the animation*/
  6830. to: number;
  6831. /**
  6832. * Initializes the range of an animation
  6833. * @param name The name of the animation range
  6834. * @param from The starting frame of the animation
  6835. * @param to The ending frame of the animation
  6836. */
  6837. constructor(
  6838. /**The name of the animation range**/
  6839. name: string,
  6840. /**The starting frame of the animation */
  6841. from: number,
  6842. /**The ending frame of the animation*/
  6843. to: number);
  6844. /**
  6845. * Makes a copy of the animation range
  6846. * @returns A copy of the animation range
  6847. */
  6848. clone(): AnimationRange;
  6849. }
  6850. }
  6851. declare module BABYLON {
  6852. /**
  6853. * Composed of a frame, and an action function
  6854. */
  6855. export class AnimationEvent {
  6856. /** The frame for which the event is triggered **/
  6857. frame: number;
  6858. /** The event to perform when triggered **/
  6859. action: (currentFrame: number) => void;
  6860. /** Specifies if the event should be triggered only once**/
  6861. onlyOnce?: boolean | undefined;
  6862. /**
  6863. * Specifies if the animation event is done
  6864. */
  6865. isDone: boolean;
  6866. /**
  6867. * Initializes the animation event
  6868. * @param frame The frame for which the event is triggered
  6869. * @param action The event to perform when triggered
  6870. * @param onlyOnce Specifies if the event should be triggered only once
  6871. */
  6872. constructor(
  6873. /** The frame for which the event is triggered **/
  6874. frame: number,
  6875. /** The event to perform when triggered **/
  6876. action: (currentFrame: number) => void,
  6877. /** Specifies if the event should be triggered only once**/
  6878. onlyOnce?: boolean | undefined);
  6879. /** @hidden */
  6880. _clone(): AnimationEvent;
  6881. }
  6882. }
  6883. declare module BABYLON {
  6884. /**
  6885. * Interface used to define a behavior
  6886. */
  6887. export interface Behavior<T> {
  6888. /** gets or sets behavior's name */
  6889. name: string;
  6890. /**
  6891. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6892. */
  6893. init(): void;
  6894. /**
  6895. * Called when the behavior is attached to a target
  6896. * @param target defines the target where the behavior is attached to
  6897. */
  6898. attach(target: T): void;
  6899. /**
  6900. * Called when the behavior is detached from its target
  6901. */
  6902. detach(): void;
  6903. }
  6904. /**
  6905. * Interface implemented by classes supporting behaviors
  6906. */
  6907. export interface IBehaviorAware<T> {
  6908. /**
  6909. * Attach a behavior
  6910. * @param behavior defines the behavior to attach
  6911. * @returns the current host
  6912. */
  6913. addBehavior(behavior: Behavior<T>): T;
  6914. /**
  6915. * Remove a behavior from the current object
  6916. * @param behavior defines the behavior to detach
  6917. * @returns the current host
  6918. */
  6919. removeBehavior(behavior: Behavior<T>): T;
  6920. /**
  6921. * Gets a behavior using its name to search
  6922. * @param name defines the name to search
  6923. * @returns the behavior or null if not found
  6924. */
  6925. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6926. }
  6927. }
  6928. declare module BABYLON {
  6929. /**
  6930. * Class used to store data that will be store in GPU memory
  6931. */
  6932. export class Buffer {
  6933. private _engine;
  6934. private _buffer;
  6935. /** @hidden */
  6936. _data: Nullable<DataArray>;
  6937. private _updatable;
  6938. private _instanced;
  6939. private _divisor;
  6940. private _isAlreadyOwned;
  6941. /**
  6942. * Gets the byte stride.
  6943. */
  6944. readonly byteStride: number;
  6945. /**
  6946. * Constructor
  6947. * @param engine the engine
  6948. * @param data the data to use for this buffer
  6949. * @param updatable whether the data is updatable
  6950. * @param stride the stride (optional)
  6951. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6952. * @param instanced whether the buffer is instanced (optional)
  6953. * @param useBytes set to true if the stride in in bytes (optional)
  6954. * @param divisor sets an optional divisor for instances (1 by default)
  6955. */
  6956. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6957. /**
  6958. * Create a new VertexBuffer based on the current buffer
  6959. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6960. * @param offset defines offset in the buffer (0 by default)
  6961. * @param size defines the size in floats of attributes (position is 3 for instance)
  6962. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6963. * @param instanced defines if the vertex buffer contains indexed data
  6964. * @param useBytes defines if the offset and stride are in bytes *
  6965. * @param divisor sets an optional divisor for instances (1 by default)
  6966. * @returns the new vertex buffer
  6967. */
  6968. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6969. /**
  6970. * Gets a boolean indicating if the Buffer is updatable?
  6971. * @returns true if the buffer is updatable
  6972. */
  6973. isUpdatable(): boolean;
  6974. /**
  6975. * Gets current buffer's data
  6976. * @returns a DataArray or null
  6977. */
  6978. getData(): Nullable<DataArray>;
  6979. /**
  6980. * Gets underlying native buffer
  6981. * @returns underlying native buffer
  6982. */
  6983. getBuffer(): Nullable<DataBuffer>;
  6984. /**
  6985. * Gets the stride in float32 units (i.e. byte stride / 4).
  6986. * May not be an integer if the byte stride is not divisible by 4.
  6987. * @returns the stride in float32 units
  6988. * @deprecated Please use byteStride instead.
  6989. */
  6990. getStrideSize(): number;
  6991. /**
  6992. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6993. * @param data defines the data to store
  6994. */
  6995. create(data?: Nullable<DataArray>): void;
  6996. /** @hidden */
  6997. _rebuild(): void;
  6998. /**
  6999. * Update current buffer data
  7000. * @param data defines the data to store
  7001. */
  7002. update(data: DataArray): void;
  7003. /**
  7004. * Updates the data directly.
  7005. * @param data the new data
  7006. * @param offset the new offset
  7007. * @param vertexCount the vertex count (optional)
  7008. * @param useBytes set to true if the offset is in bytes
  7009. */
  7010. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7011. /** @hidden */
  7012. _increaseReferences(): void;
  7013. /**
  7014. * Release all resources
  7015. */
  7016. dispose(): void;
  7017. }
  7018. /**
  7019. * Specialized buffer used to store vertex data
  7020. */
  7021. export class VertexBuffer {
  7022. private static _Counter;
  7023. /** @hidden */
  7024. _buffer: Buffer;
  7025. private _kind;
  7026. private _size;
  7027. private _ownsBuffer;
  7028. private _instanced;
  7029. private _instanceDivisor;
  7030. /**
  7031. * The byte type.
  7032. */
  7033. static readonly BYTE: number;
  7034. /**
  7035. * The unsigned byte type.
  7036. */
  7037. static readonly UNSIGNED_BYTE: number;
  7038. /**
  7039. * The short type.
  7040. */
  7041. static readonly SHORT: number;
  7042. /**
  7043. * The unsigned short type.
  7044. */
  7045. static readonly UNSIGNED_SHORT: number;
  7046. /**
  7047. * The integer type.
  7048. */
  7049. static readonly INT: number;
  7050. /**
  7051. * The unsigned integer type.
  7052. */
  7053. static readonly UNSIGNED_INT: number;
  7054. /**
  7055. * The float type.
  7056. */
  7057. static readonly FLOAT: number;
  7058. /**
  7059. * Gets or sets the instance divisor when in instanced mode
  7060. */
  7061. get instanceDivisor(): number;
  7062. set instanceDivisor(value: number);
  7063. /**
  7064. * Gets the byte stride.
  7065. */
  7066. readonly byteStride: number;
  7067. /**
  7068. * Gets the byte offset.
  7069. */
  7070. readonly byteOffset: number;
  7071. /**
  7072. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7073. */
  7074. readonly normalized: boolean;
  7075. /**
  7076. * Gets the data type of each component in the array.
  7077. */
  7078. readonly type: number;
  7079. /**
  7080. * Gets the unique id of this vertex buffer
  7081. */
  7082. readonly uniqueId: number;
  7083. /**
  7084. * Constructor
  7085. * @param engine the engine
  7086. * @param data the data to use for this vertex buffer
  7087. * @param kind the vertex buffer kind
  7088. * @param updatable whether the data is updatable
  7089. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7090. * @param stride the stride (optional)
  7091. * @param instanced whether the buffer is instanced (optional)
  7092. * @param offset the offset of the data (optional)
  7093. * @param size the number of components (optional)
  7094. * @param type the type of the component (optional)
  7095. * @param normalized whether the data contains normalized data (optional)
  7096. * @param useBytes set to true if stride and offset are in bytes (optional)
  7097. * @param divisor defines the instance divisor to use (1 by default)
  7098. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7099. */
  7100. 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);
  7101. /** @hidden */
  7102. _rebuild(): void;
  7103. /**
  7104. * Returns the kind of the VertexBuffer (string)
  7105. * @returns a string
  7106. */
  7107. getKind(): string;
  7108. /**
  7109. * Gets a boolean indicating if the VertexBuffer is updatable?
  7110. * @returns true if the buffer is updatable
  7111. */
  7112. isUpdatable(): boolean;
  7113. /**
  7114. * Gets current buffer's data
  7115. * @returns a DataArray or null
  7116. */
  7117. getData(): Nullable<DataArray>;
  7118. /**
  7119. * Gets underlying native buffer
  7120. * @returns underlying native buffer
  7121. */
  7122. getBuffer(): Nullable<DataBuffer>;
  7123. /**
  7124. * Gets the stride in float32 units (i.e. byte stride / 4).
  7125. * May not be an integer if the byte stride is not divisible by 4.
  7126. * @returns the stride in float32 units
  7127. * @deprecated Please use byteStride instead.
  7128. */
  7129. getStrideSize(): number;
  7130. /**
  7131. * Returns the offset as a multiple of the type byte length.
  7132. * @returns the offset in bytes
  7133. * @deprecated Please use byteOffset instead.
  7134. */
  7135. getOffset(): number;
  7136. /**
  7137. * Returns the number of components per vertex attribute (integer)
  7138. * @returns the size in float
  7139. */
  7140. getSize(): number;
  7141. /**
  7142. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7143. * @returns true if this buffer is instanced
  7144. */
  7145. getIsInstanced(): boolean;
  7146. /**
  7147. * Returns the instancing divisor, zero for non-instanced (integer).
  7148. * @returns a number
  7149. */
  7150. getInstanceDivisor(): number;
  7151. /**
  7152. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7153. * @param data defines the data to store
  7154. */
  7155. create(data?: DataArray): void;
  7156. /**
  7157. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7158. * This function will create a new buffer if the current one is not updatable
  7159. * @param data defines the data to store
  7160. */
  7161. update(data: DataArray): void;
  7162. /**
  7163. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7164. * Returns the directly updated WebGLBuffer.
  7165. * @param data the new data
  7166. * @param offset the new offset
  7167. * @param useBytes set to true if the offset is in bytes
  7168. */
  7169. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7170. /**
  7171. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7172. */
  7173. dispose(): void;
  7174. /**
  7175. * Enumerates each value of this vertex buffer as numbers.
  7176. * @param count the number of values to enumerate
  7177. * @param callback the callback function called for each value
  7178. */
  7179. forEach(count: number, callback: (value: number, index: number) => void): void;
  7180. /**
  7181. * Positions
  7182. */
  7183. static readonly PositionKind: string;
  7184. /**
  7185. * Normals
  7186. */
  7187. static readonly NormalKind: string;
  7188. /**
  7189. * Tangents
  7190. */
  7191. static readonly TangentKind: string;
  7192. /**
  7193. * Texture coordinates
  7194. */
  7195. static readonly UVKind: string;
  7196. /**
  7197. * Texture coordinates 2
  7198. */
  7199. static readonly UV2Kind: string;
  7200. /**
  7201. * Texture coordinates 3
  7202. */
  7203. static readonly UV3Kind: string;
  7204. /**
  7205. * Texture coordinates 4
  7206. */
  7207. static readonly UV4Kind: string;
  7208. /**
  7209. * Texture coordinates 5
  7210. */
  7211. static readonly UV5Kind: string;
  7212. /**
  7213. * Texture coordinates 6
  7214. */
  7215. static readonly UV6Kind: string;
  7216. /**
  7217. * Colors
  7218. */
  7219. static readonly ColorKind: string;
  7220. /**
  7221. * Matrix indices (for bones)
  7222. */
  7223. static readonly MatricesIndicesKind: string;
  7224. /**
  7225. * Matrix weights (for bones)
  7226. */
  7227. static readonly MatricesWeightsKind: string;
  7228. /**
  7229. * Additional matrix indices (for bones)
  7230. */
  7231. static readonly MatricesIndicesExtraKind: string;
  7232. /**
  7233. * Additional matrix weights (for bones)
  7234. */
  7235. static readonly MatricesWeightsExtraKind: string;
  7236. /**
  7237. * Deduces the stride given a kind.
  7238. * @param kind The kind string to deduce
  7239. * @returns The deduced stride
  7240. */
  7241. static DeduceStride(kind: string): number;
  7242. /**
  7243. * Gets the byte length of the given type.
  7244. * @param type the type
  7245. * @returns the number of bytes
  7246. */
  7247. static GetTypeByteLength(type: number): number;
  7248. /**
  7249. * Enumerates each value of the given parameters as numbers.
  7250. * @param data the data to enumerate
  7251. * @param byteOffset the byte offset of the data
  7252. * @param byteStride the byte stride of the data
  7253. * @param componentCount the number of components per element
  7254. * @param componentType the type of the component
  7255. * @param count the number of values to enumerate
  7256. * @param normalized whether the data is normalized
  7257. * @param callback the callback function called for each value
  7258. */
  7259. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7260. private static _GetFloatValue;
  7261. }
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * @hidden
  7266. */
  7267. export class IntersectionInfo {
  7268. bu: Nullable<number>;
  7269. bv: Nullable<number>;
  7270. distance: number;
  7271. faceId: number;
  7272. subMeshId: number;
  7273. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /**
  7278. * Class used to store bounding sphere information
  7279. */
  7280. export class BoundingSphere {
  7281. /**
  7282. * Gets the center of the bounding sphere in local space
  7283. */
  7284. readonly center: Vector3;
  7285. /**
  7286. * Radius of the bounding sphere in local space
  7287. */
  7288. radius: number;
  7289. /**
  7290. * Gets the center of the bounding sphere in world space
  7291. */
  7292. readonly centerWorld: Vector3;
  7293. /**
  7294. * Radius of the bounding sphere in world space
  7295. */
  7296. radiusWorld: number;
  7297. /**
  7298. * Gets the minimum vector in local space
  7299. */
  7300. readonly minimum: Vector3;
  7301. /**
  7302. * Gets the maximum vector in local space
  7303. */
  7304. readonly maximum: Vector3;
  7305. private _worldMatrix;
  7306. private static readonly TmpVector3;
  7307. /**
  7308. * Creates a new bounding sphere
  7309. * @param min defines the minimum vector (in local space)
  7310. * @param max defines the maximum vector (in local space)
  7311. * @param worldMatrix defines the new world matrix
  7312. */
  7313. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7314. /**
  7315. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7316. * @param min defines the new minimum vector (in local space)
  7317. * @param max defines the new maximum vector (in local space)
  7318. * @param worldMatrix defines the new world matrix
  7319. */
  7320. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7321. /**
  7322. * Scale the current bounding sphere by applying a scale factor
  7323. * @param factor defines the scale factor to apply
  7324. * @returns the current bounding box
  7325. */
  7326. scale(factor: number): BoundingSphere;
  7327. /**
  7328. * Gets the world matrix of the bounding box
  7329. * @returns a matrix
  7330. */
  7331. getWorldMatrix(): DeepImmutable<Matrix>;
  7332. /** @hidden */
  7333. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7334. /**
  7335. * Tests if the bounding sphere is intersecting the frustum planes
  7336. * @param frustumPlanes defines the frustum planes to test
  7337. * @returns true if there is an intersection
  7338. */
  7339. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7340. /**
  7341. * Tests if the bounding sphere center is in between the frustum planes.
  7342. * Used for optimistic fast inclusion.
  7343. * @param frustumPlanes defines the frustum planes to test
  7344. * @returns true if the sphere center is in between the frustum planes
  7345. */
  7346. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7347. /**
  7348. * Tests if a point is inside the bounding sphere
  7349. * @param point defines the point to test
  7350. * @returns true if the point is inside the bounding sphere
  7351. */
  7352. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7353. /**
  7354. * Checks if two sphere intersct
  7355. * @param sphere0 sphere 0
  7356. * @param sphere1 sphere 1
  7357. * @returns true if the speres intersect
  7358. */
  7359. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7360. }
  7361. }
  7362. declare module BABYLON {
  7363. /**
  7364. * Class used to store bounding box information
  7365. */
  7366. export class BoundingBox implements ICullable {
  7367. /**
  7368. * Gets the 8 vectors representing the bounding box in local space
  7369. */
  7370. readonly vectors: Vector3[];
  7371. /**
  7372. * Gets the center of the bounding box in local space
  7373. */
  7374. readonly center: Vector3;
  7375. /**
  7376. * Gets the center of the bounding box in world space
  7377. */
  7378. readonly centerWorld: Vector3;
  7379. /**
  7380. * Gets the extend size in local space
  7381. */
  7382. readonly extendSize: Vector3;
  7383. /**
  7384. * Gets the extend size in world space
  7385. */
  7386. readonly extendSizeWorld: Vector3;
  7387. /**
  7388. * Gets the OBB (object bounding box) directions
  7389. */
  7390. readonly directions: Vector3[];
  7391. /**
  7392. * Gets the 8 vectors representing the bounding box in world space
  7393. */
  7394. readonly vectorsWorld: Vector3[];
  7395. /**
  7396. * Gets the minimum vector in world space
  7397. */
  7398. readonly minimumWorld: Vector3;
  7399. /**
  7400. * Gets the maximum vector in world space
  7401. */
  7402. readonly maximumWorld: Vector3;
  7403. /**
  7404. * Gets the minimum vector in local space
  7405. */
  7406. readonly minimum: Vector3;
  7407. /**
  7408. * Gets the maximum vector in local space
  7409. */
  7410. readonly maximum: Vector3;
  7411. private _worldMatrix;
  7412. private static readonly TmpVector3;
  7413. /**
  7414. * @hidden
  7415. */
  7416. _tag: number;
  7417. /**
  7418. * Creates a new bounding box
  7419. * @param min defines the minimum vector (in local space)
  7420. * @param max defines the maximum vector (in local space)
  7421. * @param worldMatrix defines the new world matrix
  7422. */
  7423. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7424. /**
  7425. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7426. * @param min defines the new minimum vector (in local space)
  7427. * @param max defines the new maximum vector (in local space)
  7428. * @param worldMatrix defines the new world matrix
  7429. */
  7430. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7431. /**
  7432. * Scale the current bounding box by applying a scale factor
  7433. * @param factor defines the scale factor to apply
  7434. * @returns the current bounding box
  7435. */
  7436. scale(factor: number): BoundingBox;
  7437. /**
  7438. * Gets the world matrix of the bounding box
  7439. * @returns a matrix
  7440. */
  7441. getWorldMatrix(): DeepImmutable<Matrix>;
  7442. /** @hidden */
  7443. _update(world: DeepImmutable<Matrix>): void;
  7444. /**
  7445. * Tests if the bounding box is intersecting the frustum planes
  7446. * @param frustumPlanes defines the frustum planes to test
  7447. * @returns true if there is an intersection
  7448. */
  7449. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7450. /**
  7451. * Tests if the bounding box is entirely inside the frustum planes
  7452. * @param frustumPlanes defines the frustum planes to test
  7453. * @returns true if there is an inclusion
  7454. */
  7455. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7456. /**
  7457. * Tests if a point is inside the bounding box
  7458. * @param point defines the point to test
  7459. * @returns true if the point is inside the bounding box
  7460. */
  7461. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7462. /**
  7463. * Tests if the bounding box intersects with a bounding sphere
  7464. * @param sphere defines the sphere to test
  7465. * @returns true if there is an intersection
  7466. */
  7467. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7468. /**
  7469. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7470. * @param min defines the min vector to use
  7471. * @param max defines the max vector to use
  7472. * @returns true if there is an intersection
  7473. */
  7474. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7475. /**
  7476. * Tests if two bounding boxes are intersections
  7477. * @param box0 defines the first box to test
  7478. * @param box1 defines the second box to test
  7479. * @returns true if there is an intersection
  7480. */
  7481. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7482. /**
  7483. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7484. * @param minPoint defines the minimum vector of the bounding box
  7485. * @param maxPoint defines the maximum vector of the bounding box
  7486. * @param sphereCenter defines the sphere center
  7487. * @param sphereRadius defines the sphere radius
  7488. * @returns true if there is an intersection
  7489. */
  7490. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7491. /**
  7492. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7493. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7494. * @param frustumPlanes defines the frustum planes to test
  7495. * @return true if there is an inclusion
  7496. */
  7497. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7498. /**
  7499. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7500. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7501. * @param frustumPlanes defines the frustum planes to test
  7502. * @return true if there is an intersection
  7503. */
  7504. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /** @hidden */
  7509. export class Collider {
  7510. /** Define if a collision was found */
  7511. collisionFound: boolean;
  7512. /**
  7513. * Define last intersection point in local space
  7514. */
  7515. intersectionPoint: Vector3;
  7516. /**
  7517. * Define last collided mesh
  7518. */
  7519. collidedMesh: Nullable<AbstractMesh>;
  7520. private _collisionPoint;
  7521. private _planeIntersectionPoint;
  7522. private _tempVector;
  7523. private _tempVector2;
  7524. private _tempVector3;
  7525. private _tempVector4;
  7526. private _edge;
  7527. private _baseToVertex;
  7528. private _destinationPoint;
  7529. private _slidePlaneNormal;
  7530. private _displacementVector;
  7531. /** @hidden */
  7532. _radius: Vector3;
  7533. /** @hidden */
  7534. _retry: number;
  7535. private _velocity;
  7536. private _basePoint;
  7537. private _epsilon;
  7538. /** @hidden */
  7539. _velocityWorldLength: number;
  7540. /** @hidden */
  7541. _basePointWorld: Vector3;
  7542. private _velocityWorld;
  7543. private _normalizedVelocity;
  7544. /** @hidden */
  7545. _initialVelocity: Vector3;
  7546. /** @hidden */
  7547. _initialPosition: Vector3;
  7548. private _nearestDistance;
  7549. private _collisionMask;
  7550. get collisionMask(): number;
  7551. set collisionMask(mask: number);
  7552. /**
  7553. * Gets the plane normal used to compute the sliding response (in local space)
  7554. */
  7555. get slidePlaneNormal(): Vector3;
  7556. /** @hidden */
  7557. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7558. /** @hidden */
  7559. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7560. /** @hidden */
  7561. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7562. /** @hidden */
  7563. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7564. /** @hidden */
  7565. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7566. /** @hidden */
  7567. _getResponse(pos: Vector3, vel: Vector3): void;
  7568. }
  7569. }
  7570. declare module BABYLON {
  7571. /**
  7572. * Interface for cullable objects
  7573. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7574. */
  7575. export interface ICullable {
  7576. /**
  7577. * Checks if the object or part of the object is in the frustum
  7578. * @param frustumPlanes Camera near/planes
  7579. * @returns true if the object is in frustum otherwise false
  7580. */
  7581. isInFrustum(frustumPlanes: Plane[]): boolean;
  7582. /**
  7583. * Checks if a cullable object (mesh...) is in the camera frustum
  7584. * Unlike isInFrustum this cheks the full bounding box
  7585. * @param frustumPlanes Camera near/planes
  7586. * @returns true if the object is in frustum otherwise false
  7587. */
  7588. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7589. }
  7590. /**
  7591. * Info for a bounding data of a mesh
  7592. */
  7593. export class BoundingInfo implements ICullable {
  7594. /**
  7595. * Bounding box for the mesh
  7596. */
  7597. readonly boundingBox: BoundingBox;
  7598. /**
  7599. * Bounding sphere for the mesh
  7600. */
  7601. readonly boundingSphere: BoundingSphere;
  7602. private _isLocked;
  7603. private static readonly TmpVector3;
  7604. /**
  7605. * Constructs bounding info
  7606. * @param minimum min vector of the bounding box/sphere
  7607. * @param maximum max vector of the bounding box/sphere
  7608. * @param worldMatrix defines the new world matrix
  7609. */
  7610. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7611. /**
  7612. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7613. * @param min defines the new minimum vector (in local space)
  7614. * @param max defines the new maximum vector (in local space)
  7615. * @param worldMatrix defines the new world matrix
  7616. */
  7617. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7618. /**
  7619. * min vector of the bounding box/sphere
  7620. */
  7621. get minimum(): Vector3;
  7622. /**
  7623. * max vector of the bounding box/sphere
  7624. */
  7625. get maximum(): Vector3;
  7626. /**
  7627. * If the info is locked and won't be updated to avoid perf overhead
  7628. */
  7629. get isLocked(): boolean;
  7630. set isLocked(value: boolean);
  7631. /**
  7632. * Updates the bounding sphere and box
  7633. * @param world world matrix to be used to update
  7634. */
  7635. update(world: DeepImmutable<Matrix>): void;
  7636. /**
  7637. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7638. * @param center New center of the bounding info
  7639. * @param extend New extend of the bounding info
  7640. * @returns the current bounding info
  7641. */
  7642. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7643. /**
  7644. * Scale the current bounding info by applying a scale factor
  7645. * @param factor defines the scale factor to apply
  7646. * @returns the current bounding info
  7647. */
  7648. scale(factor: number): BoundingInfo;
  7649. /**
  7650. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7651. * @param frustumPlanes defines the frustum to test
  7652. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7653. * @returns true if the bounding info is in the frustum planes
  7654. */
  7655. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7656. /**
  7657. * Gets the world distance between the min and max points of the bounding box
  7658. */
  7659. get diagonalLength(): number;
  7660. /**
  7661. * Checks if a cullable object (mesh...) is in the camera frustum
  7662. * Unlike isInFrustum this cheks the full bounding box
  7663. * @param frustumPlanes Camera near/planes
  7664. * @returns true if the object is in frustum otherwise false
  7665. */
  7666. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7667. /** @hidden */
  7668. _checkCollision(collider: Collider): boolean;
  7669. /**
  7670. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7671. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7672. * @param point the point to check intersection with
  7673. * @returns if the point intersects
  7674. */
  7675. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7676. /**
  7677. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7678. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7679. * @param boundingInfo the bounding info to check intersection with
  7680. * @param precise if the intersection should be done using OBB
  7681. * @returns if the bounding info intersects
  7682. */
  7683. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Extracts minimum and maximum values from a list of indexed positions
  7689. * @param positions defines the positions to use
  7690. * @param indices defines the indices to the positions
  7691. * @param indexStart defines the start index
  7692. * @param indexCount defines the end index
  7693. * @param bias defines bias value to add to the result
  7694. * @return minimum and maximum values
  7695. */
  7696. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7697. minimum: Vector3;
  7698. maximum: Vector3;
  7699. };
  7700. /**
  7701. * Extracts minimum and maximum values from a list of positions
  7702. * @param positions defines the positions to use
  7703. * @param start defines the start index in the positions array
  7704. * @param count defines the number of positions to handle
  7705. * @param bias defines bias value to add to the result
  7706. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7707. * @return minimum and maximum values
  7708. */
  7709. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7710. minimum: Vector3;
  7711. maximum: Vector3;
  7712. };
  7713. }
  7714. declare module BABYLON {
  7715. /**
  7716. * Class used to manipulate GUIDs
  7717. */
  7718. export class GUID {
  7719. /**
  7720. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7721. * Be aware Math.random() could cause collisions, but:
  7722. * "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"
  7723. * @returns a pseudo random id
  7724. */
  7725. static RandomId(): string;
  7726. }
  7727. }
  7728. declare module BABYLON {
  7729. /**
  7730. * Base class of all the textures in babylon.
  7731. * It groups all the common properties the materials, post process, lights... might need
  7732. * in order to make a correct use of the texture.
  7733. */
  7734. export class BaseTexture extends ThinTexture implements IAnimatable {
  7735. /**
  7736. * Default anisotropic filtering level for the application.
  7737. * It is set to 4 as a good tradeoff between perf and quality.
  7738. */
  7739. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7740. /**
  7741. * Gets or sets the unique id of the texture
  7742. */
  7743. uniqueId: number;
  7744. /**
  7745. * Define the name of the texture.
  7746. */
  7747. name: string;
  7748. /**
  7749. * Gets or sets an object used to store user defined information.
  7750. */
  7751. metadata: any;
  7752. /**
  7753. * For internal use only. Please do not use.
  7754. */
  7755. reservedDataStore: any;
  7756. private _hasAlpha;
  7757. /**
  7758. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7759. */
  7760. set hasAlpha(value: boolean);
  7761. get hasAlpha(): boolean;
  7762. /**
  7763. * Defines if the alpha value should be determined via the rgb values.
  7764. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7765. */
  7766. getAlphaFromRGB: boolean;
  7767. /**
  7768. * Intensity or strength of the texture.
  7769. * It is commonly used by materials to fine tune the intensity of the texture
  7770. */
  7771. level: number;
  7772. /**
  7773. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7774. * This is part of the texture as textures usually maps to one uv set.
  7775. */
  7776. coordinatesIndex: number;
  7777. protected _coordinatesMode: number;
  7778. /**
  7779. * How a texture is mapped.
  7780. *
  7781. * | Value | Type | Description |
  7782. * | ----- | ----------------------------------- | ----------- |
  7783. * | 0 | EXPLICIT_MODE | |
  7784. * | 1 | SPHERICAL_MODE | |
  7785. * | 2 | PLANAR_MODE | |
  7786. * | 3 | CUBIC_MODE | |
  7787. * | 4 | PROJECTION_MODE | |
  7788. * | 5 | SKYBOX_MODE | |
  7789. * | 6 | INVCUBIC_MODE | |
  7790. * | 7 | EQUIRECTANGULAR_MODE | |
  7791. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7792. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7793. */
  7794. set coordinatesMode(value: number);
  7795. get coordinatesMode(): number;
  7796. /**
  7797. * | Value | Type | Description |
  7798. * | ----- | ------------------ | ----------- |
  7799. * | 0 | CLAMP_ADDRESSMODE | |
  7800. * | 1 | WRAP_ADDRESSMODE | |
  7801. * | 2 | MIRROR_ADDRESSMODE | |
  7802. */
  7803. get wrapU(): number;
  7804. set wrapU(value: number);
  7805. /**
  7806. * | Value | Type | Description |
  7807. * | ----- | ------------------ | ----------- |
  7808. * | 0 | CLAMP_ADDRESSMODE | |
  7809. * | 1 | WRAP_ADDRESSMODE | |
  7810. * | 2 | MIRROR_ADDRESSMODE | |
  7811. */
  7812. get wrapV(): number;
  7813. set wrapV(value: number);
  7814. /**
  7815. * | Value | Type | Description |
  7816. * | ----- | ------------------ | ----------- |
  7817. * | 0 | CLAMP_ADDRESSMODE | |
  7818. * | 1 | WRAP_ADDRESSMODE | |
  7819. * | 2 | MIRROR_ADDRESSMODE | |
  7820. */
  7821. wrapR: number;
  7822. /**
  7823. * With compliant hardware and browser (supporting anisotropic filtering)
  7824. * this defines the level of anisotropic filtering in the texture.
  7825. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7826. */
  7827. anisotropicFilteringLevel: number;
  7828. private _isCube;
  7829. /**
  7830. * Define if the texture is a cube texture or if false a 2d texture.
  7831. */
  7832. get isCube(): boolean;
  7833. set isCube(value: boolean);
  7834. /**
  7835. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7836. */
  7837. get is3D(): boolean;
  7838. set is3D(value: boolean);
  7839. /**
  7840. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7841. */
  7842. get is2DArray(): boolean;
  7843. set is2DArray(value: boolean);
  7844. private _gammaSpace;
  7845. /**
  7846. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7847. * HDR texture are usually stored in linear space.
  7848. * This only impacts the PBR and Background materials
  7849. */
  7850. get gammaSpace(): boolean;
  7851. set gammaSpace(gamma: boolean);
  7852. /**
  7853. * Gets or sets whether or not the texture contains RGBD data.
  7854. */
  7855. get isRGBD(): boolean;
  7856. set isRGBD(value: boolean);
  7857. /**
  7858. * Is Z inverted in the texture (useful in a cube texture).
  7859. */
  7860. invertZ: boolean;
  7861. /**
  7862. * Are mip maps generated for this texture or not.
  7863. */
  7864. get noMipmap(): boolean;
  7865. /**
  7866. * @hidden
  7867. */
  7868. lodLevelInAlpha: boolean;
  7869. /**
  7870. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7871. */
  7872. get lodGenerationOffset(): number;
  7873. set lodGenerationOffset(value: number);
  7874. /**
  7875. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7876. */
  7877. get lodGenerationScale(): number;
  7878. set lodGenerationScale(value: number);
  7879. /**
  7880. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7881. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7882. * average roughness values.
  7883. */
  7884. get linearSpecularLOD(): boolean;
  7885. set linearSpecularLOD(value: boolean);
  7886. /**
  7887. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7888. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7889. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7890. */
  7891. get irradianceTexture(): Nullable<BaseTexture>;
  7892. set irradianceTexture(value: Nullable<BaseTexture>);
  7893. /**
  7894. * Define if the texture is a render target.
  7895. */
  7896. isRenderTarget: boolean;
  7897. /**
  7898. * Define the unique id of the texture in the scene.
  7899. */
  7900. get uid(): string;
  7901. /** @hidden */
  7902. _prefiltered: boolean;
  7903. /**
  7904. * Return a string representation of the texture.
  7905. * @returns the texture as a string
  7906. */
  7907. toString(): string;
  7908. /**
  7909. * Get the class name of the texture.
  7910. * @returns "BaseTexture"
  7911. */
  7912. getClassName(): string;
  7913. /**
  7914. * Define the list of animation attached to the texture.
  7915. */
  7916. animations: Animation[];
  7917. /**
  7918. * An event triggered when the texture is disposed.
  7919. */
  7920. onDisposeObservable: Observable<BaseTexture>;
  7921. private _onDisposeObserver;
  7922. /**
  7923. * Callback triggered when the texture has been disposed.
  7924. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7925. */
  7926. set onDispose(callback: () => void);
  7927. protected _scene: Nullable<Scene>;
  7928. /** @hidden */
  7929. _texture: Nullable<InternalTexture>;
  7930. private _uid;
  7931. /**
  7932. * Define if the texture is preventinga material to render or not.
  7933. * If not and the texture is not ready, the engine will use a default black texture instead.
  7934. */
  7935. get isBlocking(): boolean;
  7936. /**
  7937. * Instantiates a new BaseTexture.
  7938. * Base class of all the textures in babylon.
  7939. * It groups all the common properties the materials, post process, lights... might need
  7940. * in order to make a correct use of the texture.
  7941. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7942. */
  7943. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7944. /**
  7945. * Get the scene the texture belongs to.
  7946. * @returns the scene or null if undefined
  7947. */
  7948. getScene(): Nullable<Scene>;
  7949. /** @hidden */
  7950. protected _getEngine(): Nullable<ThinEngine>;
  7951. /**
  7952. * Checks if the texture has the same transform matrix than another texture
  7953. * @param texture texture to check against
  7954. * @returns true if the transforms are the same, else false
  7955. */
  7956. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7957. /**
  7958. * Get the texture transform matrix used to offset tile the texture for istance.
  7959. * @returns the transformation matrix
  7960. */
  7961. getTextureMatrix(): Matrix;
  7962. /**
  7963. * Get the texture reflection matrix used to rotate/transform the reflection.
  7964. * @returns the reflection matrix
  7965. */
  7966. getReflectionTextureMatrix(): Matrix;
  7967. /**
  7968. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7969. * @returns true if ready or not blocking
  7970. */
  7971. isReadyOrNotBlocking(): boolean;
  7972. /**
  7973. * Scales the texture if is `canRescale()`
  7974. * @param ratio the resize factor we want to use to rescale
  7975. */
  7976. scale(ratio: number): void;
  7977. /**
  7978. * Get if the texture can rescale.
  7979. */
  7980. get canRescale(): boolean;
  7981. /** @hidden */
  7982. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7983. /** @hidden */
  7984. _rebuild(): void;
  7985. /**
  7986. * Clones the texture.
  7987. * @returns the cloned texture
  7988. */
  7989. clone(): Nullable<BaseTexture>;
  7990. /**
  7991. * Get the texture underlying type (INT, FLOAT...)
  7992. */
  7993. get textureType(): number;
  7994. /**
  7995. * Get the texture underlying format (RGB, RGBA...)
  7996. */
  7997. get textureFormat(): number;
  7998. /**
  7999. * Indicates that textures need to be re-calculated for all materials
  8000. */
  8001. protected _markAllSubMeshesAsTexturesDirty(): void;
  8002. /**
  8003. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8004. * This will returns an RGBA array buffer containing either in values (0-255) or
  8005. * float values (0-1) depending of the underlying buffer type.
  8006. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8007. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8008. * @param buffer defines a user defined buffer to fill with data (can be null)
  8009. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8010. * @returns The Array buffer promise containing the pixels data.
  8011. */
  8012. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8013. /** @hidden */
  8014. get _lodTextureHigh(): Nullable<BaseTexture>;
  8015. /** @hidden */
  8016. get _lodTextureMid(): Nullable<BaseTexture>;
  8017. /** @hidden */
  8018. get _lodTextureLow(): Nullable<BaseTexture>;
  8019. /**
  8020. * Dispose the texture and release its associated resources.
  8021. */
  8022. dispose(): void;
  8023. /**
  8024. * Serialize the texture into a JSON representation that can be parsed later on.
  8025. * @returns the JSON representation of the texture
  8026. */
  8027. serialize(): any;
  8028. /**
  8029. * Helper function to be called back once a list of texture contains only ready textures.
  8030. * @param textures Define the list of textures to wait for
  8031. * @param callback Define the callback triggered once the entire list will be ready
  8032. */
  8033. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8034. private static _isScene;
  8035. }
  8036. }
  8037. declare module BABYLON {
  8038. /** @hidden */
  8039. export class WebGLDataBuffer extends DataBuffer {
  8040. private _buffer;
  8041. constructor(resource: WebGLBuffer);
  8042. get underlyingResource(): any;
  8043. }
  8044. }
  8045. declare module BABYLON {
  8046. /** @hidden */
  8047. export class WebGLPipelineContext implements IPipelineContext {
  8048. private _valueCache;
  8049. private _uniforms;
  8050. engine: ThinEngine;
  8051. program: Nullable<WebGLProgram>;
  8052. context?: WebGLRenderingContext;
  8053. vertexShader?: WebGLShader;
  8054. fragmentShader?: WebGLShader;
  8055. isParallelCompiled: boolean;
  8056. onCompiled?: () => void;
  8057. transformFeedback?: WebGLTransformFeedback | null;
  8058. vertexCompilationError: Nullable<string>;
  8059. fragmentCompilationError: Nullable<string>;
  8060. programLinkError: Nullable<string>;
  8061. programValidationError: Nullable<string>;
  8062. get isAsync(): boolean;
  8063. get isReady(): boolean;
  8064. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8065. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8066. [key: string]: number;
  8067. }, uniformsNames: string[], uniforms: {
  8068. [key: string]: Nullable<WebGLUniformLocation>;
  8069. }, samplerList: string[], samplers: {
  8070. [key: string]: number;
  8071. }, attributesNames: string[], attributes: number[]): void;
  8072. /**
  8073. * Release all associated resources.
  8074. **/
  8075. dispose(): void;
  8076. /** @hidden */
  8077. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8078. /** @hidden */
  8079. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8080. /** @hidden */
  8081. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8082. /** @hidden */
  8083. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8084. /**
  8085. * Sets an interger value on a uniform variable.
  8086. * @param uniformName Name of the variable.
  8087. * @param value Value to be set.
  8088. */
  8089. setInt(uniformName: string, value: number): void;
  8090. /**
  8091. * Sets a int2 on a uniform variable.
  8092. * @param uniformName Name of the variable.
  8093. * @param x First int in int2.
  8094. * @param y Second int in int2.
  8095. */
  8096. setInt2(uniformName: string, x: number, y: number): void;
  8097. /**
  8098. * Sets a int3 on a uniform variable.
  8099. * @param uniformName Name of the variable.
  8100. * @param x First int in int3.
  8101. * @param y Second int in int3.
  8102. * @param y Third int in int3.
  8103. */
  8104. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8105. /**
  8106. * Sets a int4 on a uniform variable.
  8107. * @param uniformName Name of the variable.
  8108. * @param x First int in int4.
  8109. * @param y Second int in int4.
  8110. * @param y Third int in int4.
  8111. * @param w Fourth int in int4.
  8112. */
  8113. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8114. /**
  8115. * Sets an int array on a uniform variable.
  8116. * @param uniformName Name of the variable.
  8117. * @param array array to be set.
  8118. */
  8119. setIntArray(uniformName: string, array: Int32Array): void;
  8120. /**
  8121. * 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)
  8122. * @param uniformName Name of the variable.
  8123. * @param array array to be set.
  8124. */
  8125. setIntArray2(uniformName: string, array: Int32Array): void;
  8126. /**
  8127. * 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)
  8128. * @param uniformName Name of the variable.
  8129. * @param array array to be set.
  8130. */
  8131. setIntArray3(uniformName: string, array: Int32Array): void;
  8132. /**
  8133. * 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)
  8134. * @param uniformName Name of the variable.
  8135. * @param array array to be set.
  8136. */
  8137. setIntArray4(uniformName: string, array: Int32Array): void;
  8138. /**
  8139. * Sets an array on a uniform variable.
  8140. * @param uniformName Name of the variable.
  8141. * @param array array to be set.
  8142. */
  8143. setArray(uniformName: string, array: number[]): void;
  8144. /**
  8145. * 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)
  8146. * @param uniformName Name of the variable.
  8147. * @param array array to be set.
  8148. */
  8149. setArray2(uniformName: string, array: number[]): void;
  8150. /**
  8151. * 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)
  8152. * @param uniformName Name of the variable.
  8153. * @param array array to be set.
  8154. * @returns this effect.
  8155. */
  8156. setArray3(uniformName: string, array: number[]): void;
  8157. /**
  8158. * 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)
  8159. * @param uniformName Name of the variable.
  8160. * @param array array to be set.
  8161. */
  8162. setArray4(uniformName: string, array: number[]): void;
  8163. /**
  8164. * Sets matrices on a uniform variable.
  8165. * @param uniformName Name of the variable.
  8166. * @param matrices matrices to be set.
  8167. */
  8168. setMatrices(uniformName: string, matrices: Float32Array): void;
  8169. /**
  8170. * Sets matrix on a uniform variable.
  8171. * @param uniformName Name of the variable.
  8172. * @param matrix matrix to be set.
  8173. */
  8174. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8175. /**
  8176. * 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)
  8177. * @param uniformName Name of the variable.
  8178. * @param matrix matrix to be set.
  8179. */
  8180. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8181. /**
  8182. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8183. * @param uniformName Name of the variable.
  8184. * @param matrix matrix to be set.
  8185. */
  8186. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8187. /**
  8188. * Sets a float on a uniform variable.
  8189. * @param uniformName Name of the variable.
  8190. * @param value value to be set.
  8191. * @returns this effect.
  8192. */
  8193. setFloat(uniformName: string, value: number): void;
  8194. /**
  8195. * Sets a Vector2 on a uniform variable.
  8196. * @param uniformName Name of the variable.
  8197. * @param vector2 vector2 to be set.
  8198. */
  8199. setVector2(uniformName: string, vector2: IVector2Like): void;
  8200. /**
  8201. * Sets a float2 on a uniform variable.
  8202. * @param uniformName Name of the variable.
  8203. * @param x First float in float2.
  8204. * @param y Second float in float2.
  8205. */
  8206. setFloat2(uniformName: string, x: number, y: number): void;
  8207. /**
  8208. * Sets a Vector3 on a uniform variable.
  8209. * @param uniformName Name of the variable.
  8210. * @param vector3 Value to be set.
  8211. */
  8212. setVector3(uniformName: string, vector3: IVector3Like): void;
  8213. /**
  8214. * Sets a float3 on a uniform variable.
  8215. * @param uniformName Name of the variable.
  8216. * @param x First float in float3.
  8217. * @param y Second float in float3.
  8218. * @param z Third float in float3.
  8219. */
  8220. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8221. /**
  8222. * Sets a Vector4 on a uniform variable.
  8223. * @param uniformName Name of the variable.
  8224. * @param vector4 Value to be set.
  8225. */
  8226. setVector4(uniformName: string, vector4: IVector4Like): void;
  8227. /**
  8228. * Sets a float4 on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param x First float in float4.
  8231. * @param y Second float in float4.
  8232. * @param z Third float in float4.
  8233. * @param w Fourth float in float4.
  8234. * @returns this effect.
  8235. */
  8236. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8237. /**
  8238. * Sets a Color3 on a uniform variable.
  8239. * @param uniformName Name of the variable.
  8240. * @param color3 Value to be set.
  8241. */
  8242. setColor3(uniformName: string, color3: IColor3Like): void;
  8243. /**
  8244. * Sets a Color4 on a uniform variable.
  8245. * @param uniformName Name of the variable.
  8246. * @param color3 Value to be set.
  8247. * @param alpha Alpha value to be set.
  8248. */
  8249. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8250. /**
  8251. * Sets a Color4 on a uniform variable
  8252. * @param uniformName defines the name of the variable
  8253. * @param color4 defines the value to be set
  8254. */
  8255. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8256. _getVertexShaderCode(): string | null;
  8257. _getFragmentShaderCode(): string | null;
  8258. }
  8259. }
  8260. declare module BABYLON {
  8261. interface ThinEngine {
  8262. /**
  8263. * Create an uniform buffer
  8264. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8265. * @param elements defines the content of the uniform buffer
  8266. * @returns the webGL uniform buffer
  8267. */
  8268. createUniformBuffer(elements: FloatArray): DataBuffer;
  8269. /**
  8270. * Create a dynamic uniform buffer
  8271. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8272. * @param elements defines the content of the uniform buffer
  8273. * @returns the webGL uniform buffer
  8274. */
  8275. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8276. /**
  8277. * Update an existing uniform buffer
  8278. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8279. * @param uniformBuffer defines the target uniform buffer
  8280. * @param elements defines the content to update
  8281. * @param offset defines the offset in the uniform buffer where update should start
  8282. * @param count defines the size of the data to update
  8283. */
  8284. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8285. /**
  8286. * Bind an uniform buffer to the current webGL context
  8287. * @param buffer defines the buffer to bind
  8288. */
  8289. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8290. /**
  8291. * Bind a buffer to the current webGL context at a given location
  8292. * @param buffer defines the buffer to bind
  8293. * @param location defines the index where to bind the buffer
  8294. * @param name Name of the uniform variable to bind
  8295. */
  8296. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8297. /**
  8298. * Bind a specific block at a given index in a specific shader program
  8299. * @param pipelineContext defines the pipeline context to use
  8300. * @param blockName defines the block name
  8301. * @param index defines the index where to bind the block
  8302. */
  8303. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8304. }
  8305. }
  8306. declare module BABYLON {
  8307. /**
  8308. * Uniform buffer objects.
  8309. *
  8310. * Handles blocks of uniform on the GPU.
  8311. *
  8312. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8313. *
  8314. * For more information, please refer to :
  8315. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8316. */
  8317. export class UniformBuffer {
  8318. /** @hidden */
  8319. static _updatedUbosInFrame: {
  8320. [name: string]: number;
  8321. };
  8322. private _engine;
  8323. private _buffer;
  8324. private _buffers;
  8325. private _bufferIndex;
  8326. private _createBufferOnWrite;
  8327. private _data;
  8328. private _bufferData;
  8329. private _dynamic?;
  8330. private _uniformLocations;
  8331. private _uniformSizes;
  8332. private _uniformArraySizes;
  8333. private _uniformLocationPointer;
  8334. private _needSync;
  8335. private _noUBO;
  8336. private _currentEffect;
  8337. private _currentEffectName;
  8338. private _name;
  8339. private _currentFrameId;
  8340. /** @hidden */
  8341. _alreadyBound: boolean;
  8342. private static _MAX_UNIFORM_SIZE;
  8343. private static _tempBuffer;
  8344. private static _tempBufferInt32View;
  8345. /**
  8346. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8347. * This is dynamic to allow compat with webgl 1 and 2.
  8348. * You will need to pass the name of the uniform as well as the value.
  8349. */
  8350. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8351. /**
  8352. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8353. * This is dynamic to allow compat with webgl 1 and 2.
  8354. * You will need to pass the name of the uniform as well as the value.
  8355. */
  8356. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8357. /**
  8358. * Lambda to Update a single float in a uniform buffer.
  8359. * This is dynamic to allow compat with webgl 1 and 2.
  8360. * You will need to pass the name of the uniform as well as the value.
  8361. */
  8362. updateFloat: (name: string, x: number) => void;
  8363. /**
  8364. * Lambda to Update a vec2 of float in a uniform buffer.
  8365. * This is dynamic to allow compat with webgl 1 and 2.
  8366. * You will need to pass the name of the uniform as well as the value.
  8367. */
  8368. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8369. /**
  8370. * Lambda to Update a vec3 of float in a uniform buffer.
  8371. * This is dynamic to allow compat with webgl 1 and 2.
  8372. * You will need to pass the name of the uniform as well as the value.
  8373. */
  8374. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8375. /**
  8376. * Lambda to Update a vec4 of float in a uniform buffer.
  8377. * This is dynamic to allow compat with webgl 1 and 2.
  8378. * You will need to pass the name of the uniform as well as the value.
  8379. */
  8380. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8381. /**
  8382. * Lambda to Update an array of float in a uniform buffer.
  8383. * This is dynamic to allow compat with webgl 1 and 2.
  8384. * You will need to pass the name of the uniform as well as the value.
  8385. */
  8386. updateFloatArray: (name: string, array: Float32Array) => void;
  8387. /**
  8388. * Lambda to Update an array of number in a uniform buffer.
  8389. * This is dynamic to allow compat with webgl 1 and 2.
  8390. * You will need to pass the name of the uniform as well as the value.
  8391. */
  8392. updateArray: (name: string, array: number[]) => void;
  8393. /**
  8394. * Lambda to Update an array of number in a uniform buffer.
  8395. * This is dynamic to allow compat with webgl 1 and 2.
  8396. * You will need to pass the name of the uniform as well as the value.
  8397. */
  8398. updateIntArray: (name: string, array: Int32Array) => void;
  8399. /**
  8400. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8401. * This is dynamic to allow compat with webgl 1 and 2.
  8402. * You will need to pass the name of the uniform as well as the value.
  8403. */
  8404. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8405. /**
  8406. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8407. * This is dynamic to allow compat with webgl 1 and 2.
  8408. * You will need to pass the name of the uniform as well as the value.
  8409. */
  8410. updateMatrices: (name: string, mat: Float32Array) => void;
  8411. /**
  8412. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8413. * This is dynamic to allow compat with webgl 1 and 2.
  8414. * You will need to pass the name of the uniform as well as the value.
  8415. */
  8416. updateVector3: (name: string, vector: Vector3) => void;
  8417. /**
  8418. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8419. * This is dynamic to allow compat with webgl 1 and 2.
  8420. * You will need to pass the name of the uniform as well as the value.
  8421. */
  8422. updateVector4: (name: string, vector: Vector4) => void;
  8423. /**
  8424. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8425. * This is dynamic to allow compat with webgl 1 and 2.
  8426. * You will need to pass the name of the uniform as well as the value.
  8427. */
  8428. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8429. /**
  8430. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8431. * This is dynamic to allow compat with webgl 1 and 2.
  8432. * You will need to pass the name of the uniform as well as the value.
  8433. */
  8434. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8435. /**
  8436. * Lambda to Update a int a uniform buffer.
  8437. * This is dynamic to allow compat with webgl 1 and 2.
  8438. * You will need to pass the name of the uniform as well as the value.
  8439. */
  8440. updateInt: (name: string, x: number, suffix?: string) => void;
  8441. /**
  8442. * Lambda to Update a vec2 of int in a uniform buffer.
  8443. * This is dynamic to allow compat with webgl 1 and 2.
  8444. * You will need to pass the name of the uniform as well as the value.
  8445. */
  8446. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8447. /**
  8448. * Lambda to Update a vec3 of int in a uniform buffer.
  8449. * This is dynamic to allow compat with webgl 1 and 2.
  8450. * You will need to pass the name of the uniform as well as the value.
  8451. */
  8452. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8453. /**
  8454. * Lambda to Update a vec4 of int in a uniform buffer.
  8455. * This is dynamic to allow compat with webgl 1 and 2.
  8456. * You will need to pass the name of the uniform as well as the value.
  8457. */
  8458. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8459. /**
  8460. * Instantiates a new Uniform buffer objects.
  8461. *
  8462. * Handles blocks of uniform on the GPU.
  8463. *
  8464. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8465. *
  8466. * For more information, please refer to :
  8467. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8468. * @param engine Define the engine the buffer is associated with
  8469. * @param data Define the data contained in the buffer
  8470. * @param dynamic Define if the buffer is updatable
  8471. * @param name to assign to the buffer (debugging purpose)
  8472. */
  8473. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8474. /**
  8475. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8476. * or just falling back on setUniformXXX calls.
  8477. */
  8478. get useUbo(): boolean;
  8479. /**
  8480. * Indicates if the WebGL underlying uniform buffer is in sync
  8481. * with the javascript cache data.
  8482. */
  8483. get isSync(): boolean;
  8484. /**
  8485. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8486. * Also, a dynamic UniformBuffer will disable cache verification and always
  8487. * update the underlying WebGL uniform buffer to the GPU.
  8488. * @returns if Dynamic, otherwise false
  8489. */
  8490. isDynamic(): boolean;
  8491. /**
  8492. * The data cache on JS side.
  8493. * @returns the underlying data as a float array
  8494. */
  8495. getData(): Float32Array;
  8496. /**
  8497. * The underlying WebGL Uniform buffer.
  8498. * @returns the webgl buffer
  8499. */
  8500. getBuffer(): Nullable<DataBuffer>;
  8501. /**
  8502. * std140 layout specifies how to align data within an UBO structure.
  8503. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8504. * for specs.
  8505. */
  8506. private _fillAlignment;
  8507. /**
  8508. * Adds an uniform in the buffer.
  8509. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8510. * for the layout to be correct !
  8511. * @param name Name of the uniform, as used in the uniform block in the shader.
  8512. * @param size Data size, or data directly.
  8513. * @param arraySize The number of elements in the array, 0 if not an array.
  8514. */
  8515. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8516. /**
  8517. * Adds a Matrix 4x4 to the uniform buffer.
  8518. * @param name Name of the uniform, as used in the uniform block in the shader.
  8519. * @param mat A 4x4 matrix.
  8520. */
  8521. addMatrix(name: string, mat: Matrix): void;
  8522. /**
  8523. * Adds a vec2 to the uniform buffer.
  8524. * @param name Name of the uniform, as used in the uniform block in the shader.
  8525. * @param x Define the x component value of the vec2
  8526. * @param y Define the y component value of the vec2
  8527. */
  8528. addFloat2(name: string, x: number, y: number): void;
  8529. /**
  8530. * Adds a vec3 to the uniform buffer.
  8531. * @param name Name of the uniform, as used in the uniform block in the shader.
  8532. * @param x Define the x component value of the vec3
  8533. * @param y Define the y component value of the vec3
  8534. * @param z Define the z component value of the vec3
  8535. */
  8536. addFloat3(name: string, x: number, y: number, z: number): void;
  8537. /**
  8538. * Adds a vec3 to the uniform buffer.
  8539. * @param name Name of the uniform, as used in the uniform block in the shader.
  8540. * @param color Define the vec3 from a Color
  8541. */
  8542. addColor3(name: string, color: Color3): void;
  8543. /**
  8544. * Adds a vec4 to the uniform buffer.
  8545. * @param name Name of the uniform, as used in the uniform block in the shader.
  8546. * @param color Define the rgb components from a Color
  8547. * @param alpha Define the a component of the vec4
  8548. */
  8549. addColor4(name: string, color: Color3, alpha: number): void;
  8550. /**
  8551. * Adds a vec3 to the uniform buffer.
  8552. * @param name Name of the uniform, as used in the uniform block in the shader.
  8553. * @param vector Define the vec3 components from a Vector
  8554. */
  8555. addVector3(name: string, vector: Vector3): void;
  8556. /**
  8557. * Adds a Matrix 3x3 to the uniform buffer.
  8558. * @param name Name of the uniform, as used in the uniform block in the shader.
  8559. */
  8560. addMatrix3x3(name: string): void;
  8561. /**
  8562. * Adds a Matrix 2x2 to the uniform buffer.
  8563. * @param name Name of the uniform, as used in the uniform block in the shader.
  8564. */
  8565. addMatrix2x2(name: string): void;
  8566. /**
  8567. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8568. */
  8569. create(): void;
  8570. /** @hidden */
  8571. _rebuild(): void;
  8572. /** @hidden */
  8573. get _numBuffers(): number;
  8574. /** @hidden */
  8575. get _indexBuffer(): number;
  8576. /** Gets the name of this buffer */
  8577. get name(): string;
  8578. /**
  8579. * Updates the WebGL Uniform Buffer on the GPU.
  8580. * If the `dynamic` flag is set to true, no cache comparison is done.
  8581. * Otherwise, the buffer will be updated only if the cache differs.
  8582. */
  8583. update(): void;
  8584. private _createNewBuffer;
  8585. private _checkNewFrame;
  8586. /**
  8587. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8588. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8589. * @param data Define the flattened data
  8590. * @param size Define the size of the data.
  8591. */
  8592. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8593. /**
  8594. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8595. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8596. * @param data Define the flattened data
  8597. * @param size Define the size of the data.
  8598. */
  8599. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8600. private _valueCache;
  8601. private _cacheMatrix;
  8602. private _updateMatrix3x3ForUniform;
  8603. private _updateMatrix3x3ForEffect;
  8604. private _updateMatrix2x2ForEffect;
  8605. private _updateMatrix2x2ForUniform;
  8606. private _updateFloatForEffect;
  8607. private _updateFloatForUniform;
  8608. private _updateFloat2ForEffect;
  8609. private _updateFloat2ForUniform;
  8610. private _updateFloat3ForEffect;
  8611. private _updateFloat3ForUniform;
  8612. private _updateFloat4ForEffect;
  8613. private _updateFloat4ForUniform;
  8614. private _updateFloatArrayForEffect;
  8615. private _updateFloatArrayForUniform;
  8616. private _updateArrayForEffect;
  8617. private _updateArrayForUniform;
  8618. private _updateIntArrayForEffect;
  8619. private _updateIntArrayForUniform;
  8620. private _updateMatrixForEffect;
  8621. private _updateMatrixForUniform;
  8622. private _updateMatricesForEffect;
  8623. private _updateMatricesForUniform;
  8624. private _updateVector3ForEffect;
  8625. private _updateVector3ForUniform;
  8626. private _updateVector4ForEffect;
  8627. private _updateVector4ForUniform;
  8628. private _updateColor3ForEffect;
  8629. private _updateColor3ForUniform;
  8630. private _updateColor4ForEffect;
  8631. private _updateColor4ForUniform;
  8632. private _updateIntForEffect;
  8633. private _updateIntForUniform;
  8634. private _updateInt2ForEffect;
  8635. private _updateInt2ForUniform;
  8636. private _updateInt3ForEffect;
  8637. private _updateInt3ForUniform;
  8638. private _updateInt4ForEffect;
  8639. private _updateInt4ForUniform;
  8640. /**
  8641. * Sets a sampler uniform on the effect.
  8642. * @param name Define the name of the sampler.
  8643. * @param texture Define the texture to set in the sampler
  8644. */
  8645. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8646. /**
  8647. * Directly updates the value of the uniform in the cache AND on the GPU.
  8648. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8649. * @param data Define the flattened data
  8650. */
  8651. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8652. /**
  8653. * Binds this uniform buffer to an effect.
  8654. * @param effect Define the effect to bind the buffer to
  8655. * @param name Name of the uniform block in the shader.
  8656. */
  8657. bindToEffect(effect: Effect, name: string): void;
  8658. /**
  8659. * Disposes the uniform buffer.
  8660. */
  8661. dispose(): void;
  8662. }
  8663. }
  8664. declare module BABYLON {
  8665. /**
  8666. * Manages the defines for the Material
  8667. */
  8668. export class MaterialDefines {
  8669. /** @hidden */
  8670. protected _keys: string[];
  8671. private _isDirty;
  8672. /** @hidden */
  8673. _renderId: number;
  8674. /** @hidden */
  8675. _areLightsDirty: boolean;
  8676. /** @hidden */
  8677. _areLightsDisposed: boolean;
  8678. /** @hidden */
  8679. _areAttributesDirty: boolean;
  8680. /** @hidden */
  8681. _areTexturesDirty: boolean;
  8682. /** @hidden */
  8683. _areFresnelDirty: boolean;
  8684. /** @hidden */
  8685. _areMiscDirty: boolean;
  8686. /** @hidden */
  8687. _arePrePassDirty: boolean;
  8688. /** @hidden */
  8689. _areImageProcessingDirty: boolean;
  8690. /** @hidden */
  8691. _normals: boolean;
  8692. /** @hidden */
  8693. _uvs: boolean;
  8694. /** @hidden */
  8695. _needNormals: boolean;
  8696. /** @hidden */
  8697. _needUVs: boolean;
  8698. [id: string]: any;
  8699. /**
  8700. * Specifies if the material needs to be re-calculated
  8701. */
  8702. get isDirty(): boolean;
  8703. /**
  8704. * Marks the material to indicate that it has been re-calculated
  8705. */
  8706. markAsProcessed(): void;
  8707. /**
  8708. * Marks the material to indicate that it needs to be re-calculated
  8709. */
  8710. markAsUnprocessed(): void;
  8711. /**
  8712. * Marks the material to indicate all of its defines need to be re-calculated
  8713. */
  8714. markAllAsDirty(): void;
  8715. /**
  8716. * Marks the material to indicate that image processing needs to be re-calculated
  8717. */
  8718. markAsImageProcessingDirty(): void;
  8719. /**
  8720. * Marks the material to indicate the lights need to be re-calculated
  8721. * @param disposed Defines whether the light is dirty due to dispose or not
  8722. */
  8723. markAsLightDirty(disposed?: boolean): void;
  8724. /**
  8725. * Marks the attribute state as changed
  8726. */
  8727. markAsAttributesDirty(): void;
  8728. /**
  8729. * Marks the texture state as changed
  8730. */
  8731. markAsTexturesDirty(): void;
  8732. /**
  8733. * Marks the fresnel state as changed
  8734. */
  8735. markAsFresnelDirty(): void;
  8736. /**
  8737. * Marks the misc state as changed
  8738. */
  8739. markAsMiscDirty(): void;
  8740. /**
  8741. * Marks the prepass state as changed
  8742. */
  8743. markAsPrePassDirty(): void;
  8744. /**
  8745. * Rebuilds the material defines
  8746. */
  8747. rebuild(): void;
  8748. /**
  8749. * Specifies if two material defines are equal
  8750. * @param other - A material define instance to compare to
  8751. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8752. */
  8753. isEqual(other: MaterialDefines): boolean;
  8754. /**
  8755. * Clones this instance's defines to another instance
  8756. * @param other - material defines to clone values to
  8757. */
  8758. cloneTo(other: MaterialDefines): void;
  8759. /**
  8760. * Resets the material define values
  8761. */
  8762. reset(): void;
  8763. /**
  8764. * Converts the material define values to a string
  8765. * @returns - String of material define information
  8766. */
  8767. toString(): string;
  8768. }
  8769. }
  8770. declare module BABYLON {
  8771. /**
  8772. * Enum that determines the text-wrapping mode to use.
  8773. */
  8774. export enum InspectableType {
  8775. /**
  8776. * Checkbox for booleans
  8777. */
  8778. Checkbox = 0,
  8779. /**
  8780. * Sliders for numbers
  8781. */
  8782. Slider = 1,
  8783. /**
  8784. * Vector3
  8785. */
  8786. Vector3 = 2,
  8787. /**
  8788. * Quaternions
  8789. */
  8790. Quaternion = 3,
  8791. /**
  8792. * Color3
  8793. */
  8794. Color3 = 4,
  8795. /**
  8796. * String
  8797. */
  8798. String = 5
  8799. }
  8800. /**
  8801. * Interface used to define custom inspectable properties.
  8802. * This interface is used by the inspector to display custom property grids
  8803. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8804. */
  8805. export interface IInspectable {
  8806. /**
  8807. * Gets the label to display
  8808. */
  8809. label: string;
  8810. /**
  8811. * Gets the name of the property to edit
  8812. */
  8813. propertyName: string;
  8814. /**
  8815. * Gets the type of the editor to use
  8816. */
  8817. type: InspectableType;
  8818. /**
  8819. * Gets the minimum value of the property when using in "slider" mode
  8820. */
  8821. min?: number;
  8822. /**
  8823. * Gets the maximum value of the property when using in "slider" mode
  8824. */
  8825. max?: number;
  8826. /**
  8827. * Gets the setp to use when using in "slider" mode
  8828. */
  8829. step?: number;
  8830. }
  8831. }
  8832. declare module BABYLON {
  8833. /**
  8834. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8835. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8836. * 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.
  8837. */
  8838. export abstract class Light extends Node {
  8839. /**
  8840. * Falloff Default: light is falling off following the material specification:
  8841. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8842. */
  8843. static readonly FALLOFF_DEFAULT: number;
  8844. /**
  8845. * Falloff Physical: light is falling off following the inverse squared distance law.
  8846. */
  8847. static readonly FALLOFF_PHYSICAL: number;
  8848. /**
  8849. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8850. * to enhance interoperability with other engines.
  8851. */
  8852. static readonly FALLOFF_GLTF: number;
  8853. /**
  8854. * Falloff Standard: light is falling off like in the standard material
  8855. * to enhance interoperability with other materials.
  8856. */
  8857. static readonly FALLOFF_STANDARD: number;
  8858. /**
  8859. * If every light affecting the material is in this lightmapMode,
  8860. * material.lightmapTexture adds or multiplies
  8861. * (depends on material.useLightmapAsShadowmap)
  8862. * after every other light calculations.
  8863. */
  8864. static readonly LIGHTMAP_DEFAULT: number;
  8865. /**
  8866. * material.lightmapTexture as only diffuse lighting from this light
  8867. * adds only specular lighting from this light
  8868. * adds dynamic shadows
  8869. */
  8870. static readonly LIGHTMAP_SPECULAR: number;
  8871. /**
  8872. * material.lightmapTexture as only lighting
  8873. * no light calculation from this light
  8874. * only adds dynamic shadows from this light
  8875. */
  8876. static readonly LIGHTMAP_SHADOWSONLY: number;
  8877. /**
  8878. * Each light type uses the default quantity according to its type:
  8879. * point/spot lights use luminous intensity
  8880. * directional lights use illuminance
  8881. */
  8882. static readonly INTENSITYMODE_AUTOMATIC: number;
  8883. /**
  8884. * lumen (lm)
  8885. */
  8886. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8887. /**
  8888. * candela (lm/sr)
  8889. */
  8890. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8891. /**
  8892. * lux (lm/m^2)
  8893. */
  8894. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8895. /**
  8896. * nit (cd/m^2)
  8897. */
  8898. static readonly INTENSITYMODE_LUMINANCE: number;
  8899. /**
  8900. * Light type const id of the point light.
  8901. */
  8902. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8903. /**
  8904. * Light type const id of the directional light.
  8905. */
  8906. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8907. /**
  8908. * Light type const id of the spot light.
  8909. */
  8910. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8911. /**
  8912. * Light type const id of the hemispheric light.
  8913. */
  8914. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8915. /**
  8916. * Diffuse gives the basic color to an object.
  8917. */
  8918. diffuse: Color3;
  8919. /**
  8920. * Specular produces a highlight color on an object.
  8921. * Note: This is note affecting PBR materials.
  8922. */
  8923. specular: Color3;
  8924. /**
  8925. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8926. * falling off base on range or angle.
  8927. * This can be set to any values in Light.FALLOFF_x.
  8928. *
  8929. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8930. * other types of materials.
  8931. */
  8932. falloffType: number;
  8933. /**
  8934. * Strength of the light.
  8935. * Note: By default it is define in the framework own unit.
  8936. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8937. */
  8938. intensity: number;
  8939. private _range;
  8940. protected _inverseSquaredRange: number;
  8941. /**
  8942. * Defines how far from the source the light is impacting in scene units.
  8943. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8944. */
  8945. get range(): number;
  8946. /**
  8947. * Defines how far from the source the light is impacting in scene units.
  8948. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8949. */
  8950. set range(value: number);
  8951. /**
  8952. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8953. * of light.
  8954. */
  8955. private _photometricScale;
  8956. private _intensityMode;
  8957. /**
  8958. * Gets the photometric scale used to interpret the intensity.
  8959. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8960. */
  8961. get intensityMode(): number;
  8962. /**
  8963. * Sets the photometric scale used to interpret the intensity.
  8964. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8965. */
  8966. set intensityMode(value: number);
  8967. private _radius;
  8968. /**
  8969. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8970. */
  8971. get radius(): number;
  8972. /**
  8973. * sets the light radius used by PBR Materials to simulate soft area lights.
  8974. */
  8975. set radius(value: number);
  8976. private _renderPriority;
  8977. /**
  8978. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8979. * exceeding the number allowed of the materials.
  8980. */
  8981. renderPriority: number;
  8982. private _shadowEnabled;
  8983. /**
  8984. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8985. * the current shadow generator.
  8986. */
  8987. get shadowEnabled(): boolean;
  8988. /**
  8989. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8990. * the current shadow generator.
  8991. */
  8992. set shadowEnabled(value: boolean);
  8993. private _includedOnlyMeshes;
  8994. /**
  8995. * Gets the only meshes impacted by this light.
  8996. */
  8997. get includedOnlyMeshes(): AbstractMesh[];
  8998. /**
  8999. * Sets the only meshes impacted by this light.
  9000. */
  9001. set includedOnlyMeshes(value: AbstractMesh[]);
  9002. private _excludedMeshes;
  9003. /**
  9004. * Gets the meshes not impacted by this light.
  9005. */
  9006. get excludedMeshes(): AbstractMesh[];
  9007. /**
  9008. * Sets the meshes not impacted by this light.
  9009. */
  9010. set excludedMeshes(value: AbstractMesh[]);
  9011. private _excludeWithLayerMask;
  9012. /**
  9013. * Gets the layer id use to find what meshes are not impacted by the light.
  9014. * Inactive if 0
  9015. */
  9016. get excludeWithLayerMask(): number;
  9017. /**
  9018. * Sets the layer id use to find what meshes are not impacted by the light.
  9019. * Inactive if 0
  9020. */
  9021. set excludeWithLayerMask(value: number);
  9022. private _includeOnlyWithLayerMask;
  9023. /**
  9024. * Gets the layer id use to find what meshes are impacted by the light.
  9025. * Inactive if 0
  9026. */
  9027. get includeOnlyWithLayerMask(): number;
  9028. /**
  9029. * Sets the layer id use to find what meshes are impacted by the light.
  9030. * Inactive if 0
  9031. */
  9032. set includeOnlyWithLayerMask(value: number);
  9033. private _lightmapMode;
  9034. /**
  9035. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9036. */
  9037. get lightmapMode(): number;
  9038. /**
  9039. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9040. */
  9041. set lightmapMode(value: number);
  9042. /**
  9043. * Shadow generator associted to the light.
  9044. * @hidden Internal use only.
  9045. */
  9046. _shadowGenerator: Nullable<IShadowGenerator>;
  9047. /**
  9048. * @hidden Internal use only.
  9049. */
  9050. _excludedMeshesIds: string[];
  9051. /**
  9052. * @hidden Internal use only.
  9053. */
  9054. _includedOnlyMeshesIds: string[];
  9055. /**
  9056. * The current light unifom buffer.
  9057. * @hidden Internal use only.
  9058. */
  9059. _uniformBuffer: UniformBuffer;
  9060. /** @hidden */
  9061. _renderId: number;
  9062. /**
  9063. * Creates a Light object in the scene.
  9064. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9065. * @param name The firendly name of the light
  9066. * @param scene The scene the light belongs too
  9067. */
  9068. constructor(name: string, scene: Scene);
  9069. protected abstract _buildUniformLayout(): void;
  9070. /**
  9071. * Sets the passed Effect "effect" with the Light information.
  9072. * @param effect The effect to update
  9073. * @param lightIndex The index of the light in the effect to update
  9074. * @returns The light
  9075. */
  9076. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9077. /**
  9078. * Sets the passed Effect "effect" with the Light textures.
  9079. * @param effect The effect to update
  9080. * @param lightIndex The index of the light in the effect to update
  9081. * @returns The light
  9082. */
  9083. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9084. /**
  9085. * Binds the lights information from the scene to the effect for the given mesh.
  9086. * @param lightIndex Light index
  9087. * @param scene The scene where the light belongs to
  9088. * @param effect The effect we are binding the data to
  9089. * @param useSpecular Defines if specular is supported
  9090. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9091. */
  9092. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9093. /**
  9094. * Sets the passed Effect "effect" with the Light information.
  9095. * @param effect The effect to update
  9096. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9097. * @returns The light
  9098. */
  9099. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9100. /**
  9101. * Returns the string "Light".
  9102. * @returns the class name
  9103. */
  9104. getClassName(): string;
  9105. /** @hidden */
  9106. readonly _isLight: boolean;
  9107. /**
  9108. * Converts the light information to a readable string for debug purpose.
  9109. * @param fullDetails Supports for multiple levels of logging within scene loading
  9110. * @returns the human readable light info
  9111. */
  9112. toString(fullDetails?: boolean): string;
  9113. /** @hidden */
  9114. protected _syncParentEnabledState(): void;
  9115. /**
  9116. * Set the enabled state of this node.
  9117. * @param value - the new enabled state
  9118. */
  9119. setEnabled(value: boolean): void;
  9120. /**
  9121. * Returns the Light associated shadow generator if any.
  9122. * @return the associated shadow generator.
  9123. */
  9124. getShadowGenerator(): Nullable<IShadowGenerator>;
  9125. /**
  9126. * Returns a Vector3, the absolute light position in the World.
  9127. * @returns the world space position of the light
  9128. */
  9129. getAbsolutePosition(): Vector3;
  9130. /**
  9131. * Specifies if the light will affect the passed mesh.
  9132. * @param mesh The mesh to test against the light
  9133. * @return true the mesh is affected otherwise, false.
  9134. */
  9135. canAffectMesh(mesh: AbstractMesh): boolean;
  9136. /**
  9137. * Sort function to order lights for rendering.
  9138. * @param a First Light object to compare to second.
  9139. * @param b Second Light object to compare first.
  9140. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9141. */
  9142. static CompareLightsPriority(a: Light, b: Light): number;
  9143. /**
  9144. * Releases resources associated with this node.
  9145. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9146. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9147. */
  9148. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9149. /**
  9150. * Returns the light type ID (integer).
  9151. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9152. */
  9153. getTypeID(): number;
  9154. /**
  9155. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9156. * @returns the scaled intensity in intensity mode unit
  9157. */
  9158. getScaledIntensity(): number;
  9159. /**
  9160. * Returns a new Light object, named "name", from the current one.
  9161. * @param name The name of the cloned light
  9162. * @param newParent The parent of this light, if it has one
  9163. * @returns the new created light
  9164. */
  9165. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9166. /**
  9167. * Serializes the current light into a Serialization object.
  9168. * @returns the serialized object.
  9169. */
  9170. serialize(): any;
  9171. /**
  9172. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9173. * This new light is named "name" and added to the passed scene.
  9174. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9175. * @param name The friendly name of the light
  9176. * @param scene The scene the new light will belong to
  9177. * @returns the constructor function
  9178. */
  9179. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9180. /**
  9181. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9182. * @param parsedLight The JSON representation of the light
  9183. * @param scene The scene to create the parsed light in
  9184. * @returns the created light after parsing
  9185. */
  9186. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9187. private _hookArrayForExcluded;
  9188. private _hookArrayForIncludedOnly;
  9189. private _resyncMeshes;
  9190. /**
  9191. * Forces the meshes to update their light related information in their rendering used effects
  9192. * @hidden Internal Use Only
  9193. */
  9194. _markMeshesAsLightDirty(): void;
  9195. /**
  9196. * Recomputes the cached photometric scale if needed.
  9197. */
  9198. private _computePhotometricScale;
  9199. /**
  9200. * Returns the Photometric Scale according to the light type and intensity mode.
  9201. */
  9202. private _getPhotometricScale;
  9203. /**
  9204. * Reorder the light in the scene according to their defined priority.
  9205. * @hidden Internal Use Only
  9206. */
  9207. _reorderLightsInScene(): void;
  9208. /**
  9209. * Prepares the list of defines specific to the light type.
  9210. * @param defines the list of defines
  9211. * @param lightIndex defines the index of the light for the effect
  9212. */
  9213. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9214. }
  9215. }
  9216. declare module BABYLON {
  9217. /** Defines supported spaces */
  9218. export enum Space {
  9219. /** Local (object) space */
  9220. LOCAL = 0,
  9221. /** World space */
  9222. WORLD = 1,
  9223. /** Bone space */
  9224. BONE = 2
  9225. }
  9226. /** Defines the 3 main axes */
  9227. export class Axis {
  9228. /** X axis */
  9229. static X: Vector3;
  9230. /** Y axis */
  9231. static Y: Vector3;
  9232. /** Z axis */
  9233. static Z: Vector3;
  9234. }
  9235. /**
  9236. * Defines cartesian components.
  9237. */
  9238. export enum Coordinate {
  9239. /** X axis */
  9240. X = 0,
  9241. /** Y axis */
  9242. Y = 1,
  9243. /** Z axis */
  9244. Z = 2
  9245. }
  9246. }
  9247. declare module BABYLON {
  9248. /**
  9249. * Interface describing all the common properties and methods a shadow light needs to implement.
  9250. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9251. * as well as binding the different shadow properties to the effects.
  9252. */
  9253. export interface IShadowLight extends Light {
  9254. /**
  9255. * The light id in the scene (used in scene.findLighById for instance)
  9256. */
  9257. id: string;
  9258. /**
  9259. * The position the shdow will be casted from.
  9260. */
  9261. position: Vector3;
  9262. /**
  9263. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9264. */
  9265. direction: Vector3;
  9266. /**
  9267. * The transformed position. Position of the light in world space taking parenting in account.
  9268. */
  9269. transformedPosition: Vector3;
  9270. /**
  9271. * The transformed direction. Direction of the light in world space taking parenting in account.
  9272. */
  9273. transformedDirection: Vector3;
  9274. /**
  9275. * The friendly name of the light in the scene.
  9276. */
  9277. name: string;
  9278. /**
  9279. * Defines the shadow projection clipping minimum z value.
  9280. */
  9281. shadowMinZ: number;
  9282. /**
  9283. * Defines the shadow projection clipping maximum z value.
  9284. */
  9285. shadowMaxZ: number;
  9286. /**
  9287. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9288. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9289. */
  9290. computeTransformedInformation(): boolean;
  9291. /**
  9292. * Gets the scene the light belongs to.
  9293. * @returns The scene
  9294. */
  9295. getScene(): Scene;
  9296. /**
  9297. * Callback defining a custom Projection Matrix Builder.
  9298. * This can be used to override the default projection matrix computation.
  9299. */
  9300. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. /**
  9310. * Gets the current depth scale used in ESM.
  9311. * @returns The scale
  9312. */
  9313. getDepthScale(): number;
  9314. /**
  9315. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9316. * @returns true if a cube texture needs to be use
  9317. */
  9318. needCube(): boolean;
  9319. /**
  9320. * Detects if the projection matrix requires to be recomputed this frame.
  9321. * @returns true if it requires to be recomputed otherwise, false.
  9322. */
  9323. needProjectionMatrixCompute(): boolean;
  9324. /**
  9325. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9326. */
  9327. forceProjectionMatrixCompute(): void;
  9328. /**
  9329. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9330. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9331. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9332. */
  9333. getShadowDirection(faceIndex?: number): Vector3;
  9334. /**
  9335. * Gets the minZ used for shadow according to both the scene and the light.
  9336. * @param activeCamera The camera we are returning the min for
  9337. * @returns the depth min z
  9338. */
  9339. getDepthMinZ(activeCamera: Camera): number;
  9340. /**
  9341. * Gets the maxZ used for shadow according to both the scene and the light.
  9342. * @param activeCamera The camera we are returning the max for
  9343. * @returns the depth max z
  9344. */
  9345. getDepthMaxZ(activeCamera: Camera): number;
  9346. }
  9347. /**
  9348. * Base implementation IShadowLight
  9349. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9350. */
  9351. export abstract class ShadowLight extends Light implements IShadowLight {
  9352. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9353. protected _position: Vector3;
  9354. protected _setPosition(value: Vector3): void;
  9355. /**
  9356. * Sets the position the shadow will be casted from. Also use as the light position for both
  9357. * point and spot lights.
  9358. */
  9359. get position(): Vector3;
  9360. /**
  9361. * Sets the position the shadow will be casted from. Also use as the light position for both
  9362. * point and spot lights.
  9363. */
  9364. set position(value: Vector3);
  9365. protected _direction: Vector3;
  9366. protected _setDirection(value: Vector3): void;
  9367. /**
  9368. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9369. * Also use as the light direction on spot and directional lights.
  9370. */
  9371. get direction(): Vector3;
  9372. /**
  9373. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9374. * Also use as the light direction on spot and directional lights.
  9375. */
  9376. set direction(value: Vector3);
  9377. protected _shadowMinZ: number;
  9378. /**
  9379. * Gets the shadow projection clipping minimum z value.
  9380. */
  9381. get shadowMinZ(): number;
  9382. /**
  9383. * Sets the shadow projection clipping minimum z value.
  9384. */
  9385. set shadowMinZ(value: number);
  9386. protected _shadowMaxZ: number;
  9387. /**
  9388. * Sets the shadow projection clipping maximum z value.
  9389. */
  9390. get shadowMaxZ(): number;
  9391. /**
  9392. * Gets the shadow projection clipping maximum z value.
  9393. */
  9394. set shadowMaxZ(value: number);
  9395. /**
  9396. * Callback defining a custom Projection Matrix Builder.
  9397. * This can be used to override the default projection matrix computation.
  9398. */
  9399. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9400. /**
  9401. * The transformed position. Position of the light in world space taking parenting in account.
  9402. */
  9403. transformedPosition: Vector3;
  9404. /**
  9405. * The transformed direction. Direction of the light in world space taking parenting in account.
  9406. */
  9407. transformedDirection: Vector3;
  9408. private _needProjectionMatrixCompute;
  9409. /**
  9410. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9411. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9412. */
  9413. computeTransformedInformation(): boolean;
  9414. /**
  9415. * Return the depth scale used for the shadow map.
  9416. * @returns the depth scale.
  9417. */
  9418. getDepthScale(): number;
  9419. /**
  9420. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9421. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9422. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9423. */
  9424. getShadowDirection(faceIndex?: number): Vector3;
  9425. /**
  9426. * Returns the ShadowLight absolute position in the World.
  9427. * @returns the position vector in world space
  9428. */
  9429. getAbsolutePosition(): Vector3;
  9430. /**
  9431. * Sets the ShadowLight direction toward the passed target.
  9432. * @param target The point to target in local space
  9433. * @returns the updated ShadowLight direction
  9434. */
  9435. setDirectionToTarget(target: Vector3): Vector3;
  9436. /**
  9437. * Returns the light rotation in euler definition.
  9438. * @returns the x y z rotation in local space.
  9439. */
  9440. getRotation(): Vector3;
  9441. /**
  9442. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9443. * @returns true if a cube texture needs to be use
  9444. */
  9445. needCube(): boolean;
  9446. /**
  9447. * Detects if the projection matrix requires to be recomputed this frame.
  9448. * @returns true if it requires to be recomputed otherwise, false.
  9449. */
  9450. needProjectionMatrixCompute(): boolean;
  9451. /**
  9452. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9453. */
  9454. forceProjectionMatrixCompute(): void;
  9455. /** @hidden */
  9456. _initCache(): void;
  9457. /** @hidden */
  9458. _isSynchronized(): boolean;
  9459. /**
  9460. * Computes the world matrix of the node
  9461. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9462. * @returns the world matrix
  9463. */
  9464. computeWorldMatrix(force?: boolean): Matrix;
  9465. /**
  9466. * Gets the minZ used for shadow according to both the scene and the light.
  9467. * @param activeCamera The camera we are returning the min for
  9468. * @returns the depth min z
  9469. */
  9470. getDepthMinZ(activeCamera: Camera): number;
  9471. /**
  9472. * Gets the maxZ used for shadow according to both the scene and the light.
  9473. * @param activeCamera The camera we are returning the max for
  9474. * @returns the depth max z
  9475. */
  9476. getDepthMaxZ(activeCamera: Camera): number;
  9477. /**
  9478. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9479. * @param matrix The materix to updated with the projection information
  9480. * @param viewMatrix The transform matrix of the light
  9481. * @param renderList The list of mesh to render in the map
  9482. * @returns The current light
  9483. */
  9484. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9485. }
  9486. }
  9487. declare module BABYLON {
  9488. /**
  9489. * Configuration needed for prepass-capable materials
  9490. */
  9491. export class PrePassConfiguration {
  9492. /**
  9493. * Previous world matrices of meshes carrying this material
  9494. * Used for computing velocity
  9495. */
  9496. previousWorldMatrices: {
  9497. [index: number]: Matrix;
  9498. };
  9499. /**
  9500. * Previous view project matrix
  9501. * Used for computing velocity
  9502. */
  9503. previousViewProjection: Matrix;
  9504. /**
  9505. * Previous bones of meshes carrying this material
  9506. * Used for computing velocity
  9507. */
  9508. previousBones: {
  9509. [index: number]: Float32Array;
  9510. };
  9511. /**
  9512. * Add the required uniforms to the current list.
  9513. * @param uniforms defines the current uniform list.
  9514. */
  9515. static AddUniforms(uniforms: string[]): void;
  9516. /**
  9517. * Add the required samplers to the current list.
  9518. * @param samplers defines the current sampler list.
  9519. */
  9520. static AddSamplers(samplers: string[]): void;
  9521. /**
  9522. * Binds the material data.
  9523. * @param effect defines the effect to update
  9524. * @param scene defines the scene the material belongs to.
  9525. * @param mesh The mesh
  9526. * @param world World matrix of this mesh
  9527. * @param isFrozen Is the material frozen
  9528. */
  9529. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9530. }
  9531. }
  9532. declare module BABYLON {
  9533. /**
  9534. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9535. * This is the base of the follow, arc rotate cameras and Free camera
  9536. * @see https://doc.babylonjs.com/features/cameras
  9537. */
  9538. export class TargetCamera extends Camera {
  9539. private static _RigCamTransformMatrix;
  9540. private static _TargetTransformMatrix;
  9541. private static _TargetFocalPoint;
  9542. private _tmpUpVector;
  9543. private _tmpTargetVector;
  9544. /**
  9545. * Define the current direction the camera is moving to
  9546. */
  9547. cameraDirection: Vector3;
  9548. /**
  9549. * Define the current rotation the camera is rotating to
  9550. */
  9551. cameraRotation: Vector2;
  9552. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9553. ignoreParentScaling: boolean;
  9554. /**
  9555. * When set, the up vector of the camera will be updated by the rotation of the camera
  9556. */
  9557. updateUpVectorFromRotation: boolean;
  9558. private _tmpQuaternion;
  9559. /**
  9560. * Define the current rotation of the camera
  9561. */
  9562. rotation: Vector3;
  9563. /**
  9564. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9565. */
  9566. rotationQuaternion: Quaternion;
  9567. /**
  9568. * Define the current speed of the camera
  9569. */
  9570. speed: number;
  9571. /**
  9572. * Add constraint to the camera to prevent it to move freely in all directions and
  9573. * around all axis.
  9574. */
  9575. noRotationConstraint: boolean;
  9576. /**
  9577. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9578. * panning
  9579. */
  9580. invertRotation: boolean;
  9581. /**
  9582. * Speed multiplier for inverse camera panning
  9583. */
  9584. inverseRotationSpeed: number;
  9585. /**
  9586. * Define the current target of the camera as an object or a position.
  9587. */
  9588. lockedTarget: any;
  9589. /** @hidden */
  9590. _currentTarget: Vector3;
  9591. /** @hidden */
  9592. _initialFocalDistance: number;
  9593. /** @hidden */
  9594. _viewMatrix: Matrix;
  9595. /** @hidden */
  9596. _camMatrix: Matrix;
  9597. /** @hidden */
  9598. _cameraTransformMatrix: Matrix;
  9599. /** @hidden */
  9600. _cameraRotationMatrix: Matrix;
  9601. /** @hidden */
  9602. _referencePoint: Vector3;
  9603. /** @hidden */
  9604. _transformedReferencePoint: Vector3;
  9605. /** @hidden */
  9606. _reset: () => void;
  9607. private _defaultUp;
  9608. /**
  9609. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9610. * This is the base of the follow, arc rotate cameras and Free camera
  9611. * @see https://doc.babylonjs.com/features/cameras
  9612. * @param name Defines the name of the camera in the scene
  9613. * @param position Defines the start position of the camera in the scene
  9614. * @param scene Defines the scene the camera belongs to
  9615. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9616. */
  9617. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9618. /**
  9619. * Gets the position in front of the camera at a given distance.
  9620. * @param distance The distance from the camera we want the position to be
  9621. * @returns the position
  9622. */
  9623. getFrontPosition(distance: number): Vector3;
  9624. /** @hidden */
  9625. _getLockedTargetPosition(): Nullable<Vector3>;
  9626. private _storedPosition;
  9627. private _storedRotation;
  9628. private _storedRotationQuaternion;
  9629. /**
  9630. * Store current camera state of the camera (fov, position, rotation, etc..)
  9631. * @returns the camera
  9632. */
  9633. storeState(): Camera;
  9634. /**
  9635. * Restored camera state. You must call storeState() first
  9636. * @returns whether it was successful or not
  9637. * @hidden
  9638. */
  9639. _restoreStateValues(): boolean;
  9640. /** @hidden */
  9641. _initCache(): void;
  9642. /** @hidden */
  9643. _updateCache(ignoreParentClass?: boolean): void;
  9644. /** @hidden */
  9645. _isSynchronizedViewMatrix(): boolean;
  9646. /** @hidden */
  9647. _computeLocalCameraSpeed(): number;
  9648. /**
  9649. * Defines the target the camera should look at.
  9650. * @param target Defines the new target as a Vector or a mesh
  9651. */
  9652. setTarget(target: Vector3): void;
  9653. /**
  9654. * Defines the target point of the camera.
  9655. * The camera looks towards it form the radius distance.
  9656. */
  9657. get target(): Vector3;
  9658. set target(value: Vector3);
  9659. /**
  9660. * Return the current target position of the camera. This value is expressed in local space.
  9661. * @returns the target position
  9662. */
  9663. getTarget(): Vector3;
  9664. /** @hidden */
  9665. _decideIfNeedsToMove(): boolean;
  9666. /** @hidden */
  9667. _updatePosition(): void;
  9668. /** @hidden */
  9669. _checkInputs(): void;
  9670. protected _updateCameraRotationMatrix(): void;
  9671. /**
  9672. * 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)
  9673. * @returns the current camera
  9674. */
  9675. private _rotateUpVectorWithCameraRotationMatrix;
  9676. private _cachedRotationZ;
  9677. private _cachedQuaternionRotationZ;
  9678. /** @hidden */
  9679. _getViewMatrix(): Matrix;
  9680. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9681. /**
  9682. * @hidden
  9683. */
  9684. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9685. /**
  9686. * @hidden
  9687. */
  9688. _updateRigCameras(): void;
  9689. private _getRigCamPositionAndTarget;
  9690. /**
  9691. * Gets the current object class name.
  9692. * @return the class name
  9693. */
  9694. getClassName(): string;
  9695. }
  9696. }
  9697. declare module BABYLON {
  9698. /**
  9699. * @ignore
  9700. * This is a list of all the different input types that are available in the application.
  9701. * Fo instance: ArcRotateCameraGamepadInput...
  9702. */
  9703. export var CameraInputTypes: {};
  9704. /**
  9705. * This is the contract to implement in order to create a new input class.
  9706. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9707. */
  9708. export interface ICameraInput<TCamera extends Camera> {
  9709. /**
  9710. * Defines the camera the input is attached to.
  9711. */
  9712. camera: Nullable<TCamera>;
  9713. /**
  9714. * Gets the class name of the current intput.
  9715. * @returns the class name
  9716. */
  9717. getClassName(): string;
  9718. /**
  9719. * Get the friendly name associated with the input class.
  9720. * @returns the input friendly name
  9721. */
  9722. getSimpleName(): string;
  9723. /**
  9724. * Attach the input controls to a specific dom element to get the input from.
  9725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9726. */
  9727. attachControl(noPreventDefault?: boolean): void;
  9728. /**
  9729. * Detach the current controls from the specified dom element.
  9730. */
  9731. detachControl(): void;
  9732. /**
  9733. * Update the current camera state depending on the inputs that have been used this frame.
  9734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9735. */
  9736. checkInputs?: () => void;
  9737. }
  9738. /**
  9739. * Represents a map of input types to input instance or input index to input instance.
  9740. */
  9741. export interface CameraInputsMap<TCamera extends Camera> {
  9742. /**
  9743. * Accessor to the input by input type.
  9744. */
  9745. [name: string]: ICameraInput<TCamera>;
  9746. /**
  9747. * Accessor to the input by input index.
  9748. */
  9749. [idx: number]: ICameraInput<TCamera>;
  9750. }
  9751. /**
  9752. * This represents the input manager used within a camera.
  9753. * It helps dealing with all the different kind of input attached to a camera.
  9754. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9755. */
  9756. export class CameraInputsManager<TCamera extends Camera> {
  9757. /**
  9758. * Defines the list of inputs attahed to the camera.
  9759. */
  9760. attached: CameraInputsMap<TCamera>;
  9761. /**
  9762. * Defines the dom element the camera is collecting inputs from.
  9763. * This is null if the controls have not been attached.
  9764. */
  9765. attachedToElement: boolean;
  9766. /**
  9767. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9768. */
  9769. noPreventDefault: boolean;
  9770. /**
  9771. * Defined the camera the input manager belongs to.
  9772. */
  9773. camera: TCamera;
  9774. /**
  9775. * Update the current camera state depending on the inputs that have been used this frame.
  9776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9777. */
  9778. checkInputs: () => void;
  9779. /**
  9780. * Instantiate a new Camera Input Manager.
  9781. * @param camera Defines the camera the input manager blongs to
  9782. */
  9783. constructor(camera: TCamera);
  9784. /**
  9785. * Add an input method to a camera
  9786. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9787. * @param input camera input method
  9788. */
  9789. add(input: ICameraInput<TCamera>): void;
  9790. /**
  9791. * Remove a specific input method from a camera
  9792. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9793. * @param inputToRemove camera input method
  9794. */
  9795. remove(inputToRemove: ICameraInput<TCamera>): void;
  9796. /**
  9797. * Remove a specific input type from a camera
  9798. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9799. * @param inputType the type of the input to remove
  9800. */
  9801. removeByType(inputType: string): void;
  9802. private _addCheckInputs;
  9803. /**
  9804. * Attach the input controls to the currently attached dom element to listen the events from.
  9805. * @param input Defines the input to attach
  9806. */
  9807. attachInput(input: ICameraInput<TCamera>): void;
  9808. /**
  9809. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9810. * @param element Defines the dom element to collect the events from
  9811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9812. */
  9813. attachElement(noPreventDefault?: boolean): void;
  9814. /**
  9815. * Detach the current manager inputs controls from a specific dom element.
  9816. * @param element Defines the dom element to collect the events from
  9817. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9818. */
  9819. detachElement(disconnect?: boolean): void;
  9820. /**
  9821. * Rebuild the dynamic inputCheck function from the current list of
  9822. * defined inputs in the manager.
  9823. */
  9824. rebuildInputCheck(): void;
  9825. /**
  9826. * Remove all attached input methods from a camera
  9827. */
  9828. clear(): void;
  9829. /**
  9830. * Serialize the current input manager attached to a camera.
  9831. * This ensures than once parsed,
  9832. * the input associated to the camera will be identical to the current ones
  9833. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9834. */
  9835. serialize(serializedCamera: any): void;
  9836. /**
  9837. * Parses an input manager serialized JSON to restore the previous list of inputs
  9838. * and states associated to a camera.
  9839. * @param parsedCamera Defines the JSON to parse
  9840. */
  9841. parse(parsedCamera: any): void;
  9842. }
  9843. }
  9844. declare module BABYLON {
  9845. /**
  9846. * Gather the list of keyboard event types as constants.
  9847. */
  9848. export class KeyboardEventTypes {
  9849. /**
  9850. * The keydown event is fired when a key becomes active (pressed).
  9851. */
  9852. static readonly KEYDOWN: number;
  9853. /**
  9854. * The keyup event is fired when a key has been released.
  9855. */
  9856. static readonly KEYUP: number;
  9857. }
  9858. /**
  9859. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9860. */
  9861. export class KeyboardInfo {
  9862. /**
  9863. * Defines the type of event (KeyboardEventTypes)
  9864. */
  9865. type: number;
  9866. /**
  9867. * Defines the related dom event
  9868. */
  9869. event: KeyboardEvent;
  9870. /**
  9871. * Instantiates a new keyboard info.
  9872. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9873. * @param type Defines the type of event (KeyboardEventTypes)
  9874. * @param event Defines the related dom event
  9875. */
  9876. constructor(
  9877. /**
  9878. * Defines the type of event (KeyboardEventTypes)
  9879. */
  9880. type: number,
  9881. /**
  9882. * Defines the related dom event
  9883. */
  9884. event: KeyboardEvent);
  9885. }
  9886. /**
  9887. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9888. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9889. */
  9890. export class KeyboardInfoPre extends KeyboardInfo {
  9891. /**
  9892. * Defines the type of event (KeyboardEventTypes)
  9893. */
  9894. type: number;
  9895. /**
  9896. * Defines the related dom event
  9897. */
  9898. event: KeyboardEvent;
  9899. /**
  9900. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9901. */
  9902. skipOnPointerObservable: boolean;
  9903. /**
  9904. * Instantiates a new keyboard pre info.
  9905. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9906. * @param type Defines the type of event (KeyboardEventTypes)
  9907. * @param event Defines the related dom event
  9908. */
  9909. constructor(
  9910. /**
  9911. * Defines the type of event (KeyboardEventTypes)
  9912. */
  9913. type: number,
  9914. /**
  9915. * Defines the related dom event
  9916. */
  9917. event: KeyboardEvent);
  9918. }
  9919. }
  9920. declare module BABYLON {
  9921. /**
  9922. * Manage the keyboard inputs to control the movement of a free camera.
  9923. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9924. */
  9925. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9926. /**
  9927. * Defines the camera the input is attached to.
  9928. */
  9929. camera: FreeCamera;
  9930. /**
  9931. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9932. */
  9933. keysUp: number[];
  9934. /**
  9935. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9936. */
  9937. keysUpward: number[];
  9938. /**
  9939. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9940. */
  9941. keysDown: number[];
  9942. /**
  9943. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9944. */
  9945. keysDownward: number[];
  9946. /**
  9947. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9948. */
  9949. keysLeft: number[];
  9950. /**
  9951. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9952. */
  9953. keysRight: number[];
  9954. private _keys;
  9955. private _onCanvasBlurObserver;
  9956. private _onKeyboardObserver;
  9957. private _engine;
  9958. private _scene;
  9959. /**
  9960. * Attach the input controls to a specific dom element to get the input from.
  9961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9962. */
  9963. attachControl(noPreventDefault?: boolean): void;
  9964. /**
  9965. * Detach the current controls from the specified dom element.
  9966. */
  9967. detachControl(): void;
  9968. /**
  9969. * Update the current camera state depending on the inputs that have been used this frame.
  9970. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9971. */
  9972. checkInputs(): void;
  9973. /**
  9974. * Gets the class name of the current intput.
  9975. * @returns the class name
  9976. */
  9977. getClassName(): string;
  9978. /** @hidden */
  9979. _onLostFocus(): void;
  9980. /**
  9981. * Get the friendly name associated with the input class.
  9982. * @returns the input friendly name
  9983. */
  9984. getSimpleName(): string;
  9985. }
  9986. }
  9987. declare module BABYLON {
  9988. /**
  9989. * Interface used to define Action
  9990. */
  9991. export interface IAction {
  9992. /**
  9993. * Trigger for the action
  9994. */
  9995. trigger: number;
  9996. /** Options of the trigger */
  9997. triggerOptions: any;
  9998. /**
  9999. * Gets the trigger parameters
  10000. * @returns the trigger parameters
  10001. */
  10002. getTriggerParameter(): any;
  10003. /**
  10004. * Internal only - executes current action event
  10005. * @hidden
  10006. */
  10007. _executeCurrent(evt?: ActionEvent): void;
  10008. /**
  10009. * Serialize placeholder for child classes
  10010. * @param parent of child
  10011. * @returns the serialized object
  10012. */
  10013. serialize(parent: any): any;
  10014. /**
  10015. * Internal only
  10016. * @hidden
  10017. */
  10018. _prepare(): void;
  10019. /**
  10020. * Internal only - manager for action
  10021. * @hidden
  10022. */
  10023. _actionManager: Nullable<AbstractActionManager>;
  10024. /**
  10025. * Adds action to chain of actions, may be a DoNothingAction
  10026. * @param action defines the next action to execute
  10027. * @returns The action passed in
  10028. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10029. */
  10030. then(action: IAction): IAction;
  10031. }
  10032. /**
  10033. * The action to be carried out following a trigger
  10034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10035. */
  10036. export class Action implements IAction {
  10037. /** the trigger, with or without parameters, for the action */
  10038. triggerOptions: any;
  10039. /**
  10040. * Trigger for the action
  10041. */
  10042. trigger: number;
  10043. /**
  10044. * Internal only - manager for action
  10045. * @hidden
  10046. */
  10047. _actionManager: ActionManager;
  10048. private _nextActiveAction;
  10049. private _child;
  10050. private _condition?;
  10051. private _triggerParameter;
  10052. /**
  10053. * An event triggered prior to action being executed.
  10054. */
  10055. onBeforeExecuteObservable: Observable<Action>;
  10056. /**
  10057. * Creates a new Action
  10058. * @param triggerOptions the trigger, with or without parameters, for the action
  10059. * @param condition an optional determinant of action
  10060. */
  10061. constructor(
  10062. /** the trigger, with or without parameters, for the action */
  10063. triggerOptions: any, condition?: Condition);
  10064. /**
  10065. * Internal only
  10066. * @hidden
  10067. */
  10068. _prepare(): void;
  10069. /**
  10070. * Gets the trigger parameter
  10071. * @returns the trigger parameter
  10072. */
  10073. getTriggerParameter(): any;
  10074. /**
  10075. * Sets the trigger parameter
  10076. * @param value defines the new trigger parameter
  10077. */
  10078. setTriggerParameter(value: any): void;
  10079. /**
  10080. * Internal only - executes current action event
  10081. * @hidden
  10082. */
  10083. _executeCurrent(evt?: ActionEvent): void;
  10084. /**
  10085. * Execute placeholder for child classes
  10086. * @param evt optional action event
  10087. */
  10088. execute(evt?: ActionEvent): void;
  10089. /**
  10090. * Skips to next active action
  10091. */
  10092. skipToNextActiveAction(): void;
  10093. /**
  10094. * Adds action to chain of actions, may be a DoNothingAction
  10095. * @param action defines the next action to execute
  10096. * @returns The action passed in
  10097. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10098. */
  10099. then(action: Action): Action;
  10100. /**
  10101. * Internal only
  10102. * @hidden
  10103. */
  10104. _getProperty(propertyPath: string): string;
  10105. /**
  10106. * Internal only
  10107. * @hidden
  10108. */
  10109. _getEffectiveTarget(target: any, propertyPath: string): any;
  10110. /**
  10111. * Serialize placeholder for child classes
  10112. * @param parent of child
  10113. * @returns the serialized object
  10114. */
  10115. serialize(parent: any): any;
  10116. /**
  10117. * Internal only called by serialize
  10118. * @hidden
  10119. */
  10120. protected _serialize(serializedAction: any, parent?: any): any;
  10121. /**
  10122. * Internal only
  10123. * @hidden
  10124. */
  10125. static _SerializeValueAsString: (value: any) => string;
  10126. /**
  10127. * Internal only
  10128. * @hidden
  10129. */
  10130. static _GetTargetProperty: (target: Scene | Node) => {
  10131. name: string;
  10132. targetType: string;
  10133. value: string;
  10134. };
  10135. }
  10136. }
  10137. declare module BABYLON {
  10138. /**
  10139. * A Condition applied to an Action
  10140. */
  10141. export class Condition {
  10142. /**
  10143. * Internal only - manager for action
  10144. * @hidden
  10145. */
  10146. _actionManager: ActionManager;
  10147. /**
  10148. * Internal only
  10149. * @hidden
  10150. */
  10151. _evaluationId: number;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */
  10156. _currentResult: boolean;
  10157. /**
  10158. * Creates a new Condition
  10159. * @param actionManager the manager of the action the condition is applied to
  10160. */
  10161. constructor(actionManager: ActionManager);
  10162. /**
  10163. * Check if the current condition is valid
  10164. * @returns a boolean
  10165. */
  10166. isValid(): boolean;
  10167. /**
  10168. * Internal only
  10169. * @hidden
  10170. */
  10171. _getProperty(propertyPath: string): string;
  10172. /**
  10173. * Internal only
  10174. * @hidden
  10175. */
  10176. _getEffectiveTarget(target: any, propertyPath: string): any;
  10177. /**
  10178. * Serialize placeholder for child classes
  10179. * @returns the serialized object
  10180. */
  10181. serialize(): any;
  10182. /**
  10183. * Internal only
  10184. * @hidden
  10185. */
  10186. protected _serialize(serializedCondition: any): any;
  10187. }
  10188. /**
  10189. * Defines specific conditional operators as extensions of Condition
  10190. */
  10191. export class ValueCondition extends Condition {
  10192. /** path to specify the property of the target the conditional operator uses */
  10193. propertyPath: string;
  10194. /** the value compared by the conditional operator against the current value of the property */
  10195. value: any;
  10196. /** the conditional operator, default ValueCondition.IsEqual */
  10197. operator: number;
  10198. /**
  10199. * Internal only
  10200. * @hidden
  10201. */
  10202. private static _IsEqual;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. private static _IsDifferent;
  10208. /**
  10209. * Internal only
  10210. * @hidden
  10211. */
  10212. private static _IsGreater;
  10213. /**
  10214. * Internal only
  10215. * @hidden
  10216. */
  10217. private static _IsLesser;
  10218. /**
  10219. * returns the number for IsEqual
  10220. */
  10221. static get IsEqual(): number;
  10222. /**
  10223. * Returns the number for IsDifferent
  10224. */
  10225. static get IsDifferent(): number;
  10226. /**
  10227. * Returns the number for IsGreater
  10228. */
  10229. static get IsGreater(): number;
  10230. /**
  10231. * Returns the number for IsLesser
  10232. */
  10233. static get IsLesser(): number;
  10234. /**
  10235. * Internal only The action manager for the condition
  10236. * @hidden
  10237. */
  10238. _actionManager: ActionManager;
  10239. /**
  10240. * Internal only
  10241. * @hidden
  10242. */
  10243. private _target;
  10244. /**
  10245. * Internal only
  10246. * @hidden
  10247. */
  10248. private _effectiveTarget;
  10249. /**
  10250. * Internal only
  10251. * @hidden
  10252. */
  10253. private _property;
  10254. /**
  10255. * Creates a new ValueCondition
  10256. * @param actionManager manager for the action the condition applies to
  10257. * @param target for the action
  10258. * @param propertyPath path to specify the property of the target the conditional operator uses
  10259. * @param value the value compared by the conditional operator against the current value of the property
  10260. * @param operator the conditional operator, default ValueCondition.IsEqual
  10261. */
  10262. constructor(actionManager: ActionManager, target: any,
  10263. /** path to specify the property of the target the conditional operator uses */
  10264. propertyPath: string,
  10265. /** the value compared by the conditional operator against the current value of the property */
  10266. value: any,
  10267. /** the conditional operator, default ValueCondition.IsEqual */
  10268. operator?: number);
  10269. /**
  10270. * Compares the given value with the property value for the specified conditional operator
  10271. * @returns the result of the comparison
  10272. */
  10273. isValid(): boolean;
  10274. /**
  10275. * Serialize the ValueCondition into a JSON compatible object
  10276. * @returns serialization object
  10277. */
  10278. serialize(): any;
  10279. /**
  10280. * Gets the name of the conditional operator for the ValueCondition
  10281. * @param operator the conditional operator
  10282. * @returns the name
  10283. */
  10284. static GetOperatorName(operator: number): string;
  10285. }
  10286. /**
  10287. * Defines a predicate condition as an extension of Condition
  10288. */
  10289. export class PredicateCondition extends Condition {
  10290. /** defines the predicate function used to validate the condition */
  10291. predicate: () => boolean;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Creates a new PredicateCondition
  10299. * @param actionManager manager for the action the condition applies to
  10300. * @param predicate defines the predicate function used to validate the condition
  10301. */
  10302. constructor(actionManager: ActionManager,
  10303. /** defines the predicate function used to validate the condition */
  10304. predicate: () => boolean);
  10305. /**
  10306. * @returns the validity of the predicate condition
  10307. */
  10308. isValid(): boolean;
  10309. }
  10310. /**
  10311. * Defines a state condition as an extension of Condition
  10312. */
  10313. export class StateCondition extends Condition {
  10314. /** Value to compare with target state */
  10315. value: string;
  10316. /**
  10317. * Internal only - manager for action
  10318. * @hidden
  10319. */
  10320. _actionManager: ActionManager;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. private _target;
  10326. /**
  10327. * Creates a new StateCondition
  10328. * @param actionManager manager for the action the condition applies to
  10329. * @param target of the condition
  10330. * @param value to compare with target state
  10331. */
  10332. constructor(actionManager: ActionManager, target: any,
  10333. /** Value to compare with target state */
  10334. value: string);
  10335. /**
  10336. * Gets a boolean indicating if the current condition is met
  10337. * @returns the validity of the state
  10338. */
  10339. isValid(): boolean;
  10340. /**
  10341. * Serialize the StateCondition into a JSON compatible object
  10342. * @returns serialization object
  10343. */
  10344. serialize(): any;
  10345. }
  10346. }
  10347. declare module BABYLON {
  10348. /**
  10349. * This defines an action responsible to toggle a boolean once triggered.
  10350. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10351. */
  10352. export class SwitchBooleanAction extends Action {
  10353. /**
  10354. * The path to the boolean property in the target object
  10355. */
  10356. propertyPath: string;
  10357. private _target;
  10358. private _effectiveTarget;
  10359. private _property;
  10360. /**
  10361. * Instantiate the action
  10362. * @param triggerOptions defines the trigger options
  10363. * @param target defines the object containing the boolean
  10364. * @param propertyPath defines the path to the boolean property in the target object
  10365. * @param condition defines the trigger related conditions
  10366. */
  10367. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10368. /** @hidden */
  10369. _prepare(): void;
  10370. /**
  10371. * Execute the action toggle the boolean value.
  10372. */
  10373. execute(): void;
  10374. /**
  10375. * Serializes the actions and its related information.
  10376. * @param parent defines the object to serialize in
  10377. * @returns the serialized object
  10378. */
  10379. serialize(parent: any): any;
  10380. }
  10381. /**
  10382. * This defines an action responsible to set a the state field of the target
  10383. * to a desired value once triggered.
  10384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10385. */
  10386. export class SetStateAction extends Action {
  10387. /**
  10388. * The value to store in the state field.
  10389. */
  10390. value: string;
  10391. private _target;
  10392. /**
  10393. * Instantiate the action
  10394. * @param triggerOptions defines the trigger options
  10395. * @param target defines the object containing the state property
  10396. * @param value defines the value to store in the state field
  10397. * @param condition defines the trigger related conditions
  10398. */
  10399. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10400. /**
  10401. * Execute the action and store the value on the target state property.
  10402. */
  10403. execute(): void;
  10404. /**
  10405. * Serializes the actions and its related information.
  10406. * @param parent defines the object to serialize in
  10407. * @returns the serialized object
  10408. */
  10409. serialize(parent: any): any;
  10410. }
  10411. /**
  10412. * This defines an action responsible to set a property of the target
  10413. * to a desired value once triggered.
  10414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10415. */
  10416. export class SetValueAction extends Action {
  10417. /**
  10418. * The path of the property to set in the target.
  10419. */
  10420. propertyPath: string;
  10421. /**
  10422. * The value to set in the property
  10423. */
  10424. value: any;
  10425. private _target;
  10426. private _effectiveTarget;
  10427. private _property;
  10428. /**
  10429. * Instantiate the action
  10430. * @param triggerOptions defines the trigger options
  10431. * @param target defines the object containing the property
  10432. * @param propertyPath defines the path of the property to set in the target
  10433. * @param value defines the value to set in the property
  10434. * @param condition defines the trigger related conditions
  10435. */
  10436. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10437. /** @hidden */
  10438. _prepare(): void;
  10439. /**
  10440. * Execute the action and set the targetted property to the desired value.
  10441. */
  10442. execute(): void;
  10443. /**
  10444. * Serializes the actions and its related information.
  10445. * @param parent defines the object to serialize in
  10446. * @returns the serialized object
  10447. */
  10448. serialize(parent: any): any;
  10449. }
  10450. /**
  10451. * This defines an action responsible to increment the target value
  10452. * to a desired value once triggered.
  10453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10454. */
  10455. export class IncrementValueAction extends Action {
  10456. /**
  10457. * The path of the property to increment in the target.
  10458. */
  10459. propertyPath: string;
  10460. /**
  10461. * The value we should increment the property by.
  10462. */
  10463. value: any;
  10464. private _target;
  10465. private _effectiveTarget;
  10466. private _property;
  10467. /**
  10468. * Instantiate the action
  10469. * @param triggerOptions defines the trigger options
  10470. * @param target defines the object containing the property
  10471. * @param propertyPath defines the path of the property to increment in the target
  10472. * @param value defines the value value we should increment the property by
  10473. * @param condition defines the trigger related conditions
  10474. */
  10475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10476. /** @hidden */
  10477. _prepare(): void;
  10478. /**
  10479. * Execute the action and increment the target of the value amount.
  10480. */
  10481. execute(): void;
  10482. /**
  10483. * Serializes the actions and its related information.
  10484. * @param parent defines the object to serialize in
  10485. * @returns the serialized object
  10486. */
  10487. serialize(parent: any): any;
  10488. }
  10489. /**
  10490. * This defines an action responsible to start an animation once triggered.
  10491. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10492. */
  10493. export class PlayAnimationAction extends Action {
  10494. /**
  10495. * Where the animation should start (animation frame)
  10496. */
  10497. from: number;
  10498. /**
  10499. * Where the animation should stop (animation frame)
  10500. */
  10501. to: number;
  10502. /**
  10503. * Define if the animation should loop or stop after the first play.
  10504. */
  10505. loop?: boolean;
  10506. private _target;
  10507. /**
  10508. * Instantiate the action
  10509. * @param triggerOptions defines the trigger options
  10510. * @param target defines the target animation or animation name
  10511. * @param from defines from where the animation should start (animation frame)
  10512. * @param end defines where the animation should stop (animation frame)
  10513. * @param loop defines if the animation should loop or stop after the first play
  10514. * @param condition defines the trigger related conditions
  10515. */
  10516. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10517. /** @hidden */
  10518. _prepare(): void;
  10519. /**
  10520. * Execute the action and play the animation.
  10521. */
  10522. execute(): void;
  10523. /**
  10524. * Serializes the actions and its related information.
  10525. * @param parent defines the object to serialize in
  10526. * @returns the serialized object
  10527. */
  10528. serialize(parent: any): any;
  10529. }
  10530. /**
  10531. * This defines an action responsible to stop an animation once triggered.
  10532. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class StopAnimationAction extends Action {
  10535. private _target;
  10536. /**
  10537. * Instantiate the action
  10538. * @param triggerOptions defines the trigger options
  10539. * @param target defines the target animation or animation name
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions: any, target: any, condition?: Condition);
  10543. /** @hidden */
  10544. _prepare(): void;
  10545. /**
  10546. * Execute the action and stop the animation.
  10547. */
  10548. execute(): void;
  10549. /**
  10550. * Serializes the actions and its related information.
  10551. * @param parent defines the object to serialize in
  10552. * @returns the serialized object
  10553. */
  10554. serialize(parent: any): any;
  10555. }
  10556. /**
  10557. * This defines an action responsible that does nothing once triggered.
  10558. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10559. */
  10560. export class DoNothingAction extends Action {
  10561. /**
  10562. * Instantiate the action
  10563. * @param triggerOptions defines the trigger options
  10564. * @param condition defines the trigger related conditions
  10565. */
  10566. constructor(triggerOptions?: any, condition?: Condition);
  10567. /**
  10568. * Execute the action and do nothing.
  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 to trigger several actions once triggered.
  10580. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10581. */
  10582. export class CombineAction extends Action {
  10583. /**
  10584. * The list of aggregated animations to run.
  10585. */
  10586. children: Action[];
  10587. /**
  10588. * Instantiate the action
  10589. * @param triggerOptions defines the trigger options
  10590. * @param children defines the list of aggregated animations to run
  10591. * @param condition defines the trigger related conditions
  10592. */
  10593. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10594. /** @hidden */
  10595. _prepare(): void;
  10596. /**
  10597. * Execute the action and executes all the aggregated actions.
  10598. */
  10599. execute(evt: ActionEvent): void;
  10600. /**
  10601. * Serializes the actions and its related information.
  10602. * @param parent defines the object to serialize in
  10603. * @returns the serialized object
  10604. */
  10605. serialize(parent: any): any;
  10606. }
  10607. /**
  10608. * This defines an action responsible to run code (external event) once triggered.
  10609. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10610. */
  10611. export class ExecuteCodeAction extends Action {
  10612. /**
  10613. * The callback function to run.
  10614. */
  10615. func: (evt: ActionEvent) => void;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param func defines the callback function to run
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10623. /**
  10624. * Execute the action and run the attached code.
  10625. */
  10626. execute(evt: ActionEvent): void;
  10627. }
  10628. /**
  10629. * This defines an action responsible to set the parent property of the target once triggered.
  10630. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10631. */
  10632. export class SetParentAction extends Action {
  10633. private _parent;
  10634. private _target;
  10635. /**
  10636. * Instantiate the action
  10637. * @param triggerOptions defines the trigger options
  10638. * @param target defines the target containing the parent property
  10639. * @param parent defines from where the animation should start (animation frame)
  10640. * @param condition defines the trigger related conditions
  10641. */
  10642. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10643. /** @hidden */
  10644. _prepare(): void;
  10645. /**
  10646. * Execute the action and set the parent property.
  10647. */
  10648. execute(): void;
  10649. /**
  10650. * Serializes the actions and its related information.
  10651. * @param parent defines the object to serialize in
  10652. * @returns the serialized object
  10653. */
  10654. serialize(parent: any): any;
  10655. }
  10656. }
  10657. declare module BABYLON {
  10658. /**
  10659. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10660. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10661. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10662. */
  10663. export class ActionManager extends AbstractActionManager {
  10664. /**
  10665. * Nothing
  10666. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10667. */
  10668. static readonly NothingTrigger: number;
  10669. /**
  10670. * On pick
  10671. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10672. */
  10673. static readonly OnPickTrigger: number;
  10674. /**
  10675. * On left pick
  10676. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10677. */
  10678. static readonly OnLeftPickTrigger: number;
  10679. /**
  10680. * On right pick
  10681. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10682. */
  10683. static readonly OnRightPickTrigger: number;
  10684. /**
  10685. * On center pick
  10686. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10687. */
  10688. static readonly OnCenterPickTrigger: number;
  10689. /**
  10690. * On pick down
  10691. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10692. */
  10693. static readonly OnPickDownTrigger: number;
  10694. /**
  10695. * On double pick
  10696. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10697. */
  10698. static readonly OnDoublePickTrigger: number;
  10699. /**
  10700. * On pick up
  10701. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10702. */
  10703. static readonly OnPickUpTrigger: number;
  10704. /**
  10705. * On pick out.
  10706. * This trigger will only be raised if you also declared a OnPickDown
  10707. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10708. */
  10709. static readonly OnPickOutTrigger: number;
  10710. /**
  10711. * On long press
  10712. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10713. */
  10714. static readonly OnLongPressTrigger: number;
  10715. /**
  10716. * On pointer over
  10717. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10718. */
  10719. static readonly OnPointerOverTrigger: number;
  10720. /**
  10721. * On pointer out
  10722. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10723. */
  10724. static readonly OnPointerOutTrigger: number;
  10725. /**
  10726. * On every frame
  10727. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10728. */
  10729. static readonly OnEveryFrameTrigger: number;
  10730. /**
  10731. * On intersection enter
  10732. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10733. */
  10734. static readonly OnIntersectionEnterTrigger: number;
  10735. /**
  10736. * On intersection exit
  10737. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10738. */
  10739. static readonly OnIntersectionExitTrigger: number;
  10740. /**
  10741. * On key down
  10742. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10743. */
  10744. static readonly OnKeyDownTrigger: number;
  10745. /**
  10746. * On key up
  10747. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10748. */
  10749. static readonly OnKeyUpTrigger: number;
  10750. private _scene;
  10751. /**
  10752. * Creates a new action manager
  10753. * @param scene defines the hosting scene
  10754. */
  10755. constructor(scene: Scene);
  10756. /**
  10757. * Releases all associated resources
  10758. */
  10759. dispose(): void;
  10760. /**
  10761. * Gets hosting scene
  10762. * @returns the hosting scene
  10763. */
  10764. getScene(): Scene;
  10765. /**
  10766. * Does this action manager handles actions of any of the given triggers
  10767. * @param triggers defines the triggers to be tested
  10768. * @return a boolean indicating whether one (or more) of the triggers is handled
  10769. */
  10770. hasSpecificTriggers(triggers: number[]): boolean;
  10771. /**
  10772. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10773. * speed.
  10774. * @param triggerA defines the trigger to be tested
  10775. * @param triggerB defines the trigger to be tested
  10776. * @return a boolean indicating whether one (or more) of the triggers is handled
  10777. */
  10778. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10779. /**
  10780. * Does this action manager handles actions of a given trigger
  10781. * @param trigger defines the trigger to be tested
  10782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10783. * @return whether the trigger is handled
  10784. */
  10785. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10786. /**
  10787. * Does this action manager has pointer triggers
  10788. */
  10789. get hasPointerTriggers(): boolean;
  10790. /**
  10791. * Does this action manager has pick triggers
  10792. */
  10793. get hasPickTriggers(): boolean;
  10794. /**
  10795. * Registers an action to this action manager
  10796. * @param action defines the action to be registered
  10797. * @return the action amended (prepared) after registration
  10798. */
  10799. registerAction(action: IAction): Nullable<IAction>;
  10800. /**
  10801. * Unregisters an action to this action manager
  10802. * @param action defines the action to be unregistered
  10803. * @return a boolean indicating whether the action has been unregistered
  10804. */
  10805. unregisterAction(action: IAction): Boolean;
  10806. /**
  10807. * Process a specific trigger
  10808. * @param trigger defines the trigger to process
  10809. * @param evt defines the event details to be processed
  10810. */
  10811. processTrigger(trigger: number, evt?: IActionEvent): void;
  10812. /** @hidden */
  10813. _getEffectiveTarget(target: any, propertyPath: string): any;
  10814. /** @hidden */
  10815. _getProperty(propertyPath: string): string;
  10816. /**
  10817. * Serialize this manager to a JSON object
  10818. * @param name defines the property name to store this manager
  10819. * @returns a JSON representation of this manager
  10820. */
  10821. serialize(name: string): any;
  10822. /**
  10823. * Creates a new ActionManager from a JSON data
  10824. * @param parsedActions defines the JSON data to read from
  10825. * @param object defines the hosting mesh
  10826. * @param scene defines the hosting scene
  10827. */
  10828. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10829. /**
  10830. * Get a trigger name by index
  10831. * @param trigger defines the trigger index
  10832. * @returns a trigger name
  10833. */
  10834. static GetTriggerName(trigger: number): string;
  10835. }
  10836. }
  10837. declare module BABYLON {
  10838. /**
  10839. * Class representing a ray with position and direction
  10840. */
  10841. export class Ray {
  10842. /** origin point */
  10843. origin: Vector3;
  10844. /** direction */
  10845. direction: Vector3;
  10846. /** length of the ray */
  10847. length: number;
  10848. private static readonly _TmpVector3;
  10849. private _tmpRay;
  10850. /**
  10851. * Creates a new ray
  10852. * @param origin origin point
  10853. * @param direction direction
  10854. * @param length length of the ray
  10855. */
  10856. constructor(
  10857. /** origin point */
  10858. origin: Vector3,
  10859. /** direction */
  10860. direction: Vector3,
  10861. /** length of the ray */
  10862. length?: number);
  10863. /**
  10864. * Checks if the ray intersects a box
  10865. * This does not account for the ray lenght by design to improve perfs.
  10866. * @param minimum bound of the box
  10867. * @param maximum bound of the box
  10868. * @param intersectionTreshold extra extend to be added to the box in all direction
  10869. * @returns if the box was hit
  10870. */
  10871. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10872. /**
  10873. * Checks if the ray intersects a box
  10874. * This does not account for the ray lenght by design to improve perfs.
  10875. * @param box the bounding box to check
  10876. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10877. * @returns if the box was hit
  10878. */
  10879. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10880. /**
  10881. * If the ray hits a sphere
  10882. * @param sphere the bounding sphere to check
  10883. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10884. * @returns true if it hits the sphere
  10885. */
  10886. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10887. /**
  10888. * If the ray hits a triange
  10889. * @param vertex0 triangle vertex
  10890. * @param vertex1 triangle vertex
  10891. * @param vertex2 triangle vertex
  10892. * @returns intersection information if hit
  10893. */
  10894. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10895. /**
  10896. * Checks if ray intersects a plane
  10897. * @param plane the plane to check
  10898. * @returns the distance away it was hit
  10899. */
  10900. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10901. /**
  10902. * Calculate the intercept of a ray on a given axis
  10903. * @param axis to check 'x' | 'y' | 'z'
  10904. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10905. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10906. */
  10907. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10908. /**
  10909. * Checks if ray intersects a mesh
  10910. * @param mesh the mesh to check
  10911. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10912. * @returns picking info of the intersecton
  10913. */
  10914. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10915. /**
  10916. * Checks if ray intersects a mesh
  10917. * @param meshes the meshes to check
  10918. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10919. * @param results array to store result in
  10920. * @returns Array of picking infos
  10921. */
  10922. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10923. private _comparePickingInfo;
  10924. private static smallnum;
  10925. private static rayl;
  10926. /**
  10927. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10928. * @param sega the first point of the segment to test the intersection against
  10929. * @param segb the second point of the segment to test the intersection against
  10930. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10931. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10932. */
  10933. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10934. /**
  10935. * Update the ray from viewport position
  10936. * @param x position
  10937. * @param y y position
  10938. * @param viewportWidth viewport width
  10939. * @param viewportHeight viewport height
  10940. * @param world world matrix
  10941. * @param view view matrix
  10942. * @param projection projection matrix
  10943. * @returns this ray updated
  10944. */
  10945. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10946. /**
  10947. * Creates a ray with origin and direction of 0,0,0
  10948. * @returns the new ray
  10949. */
  10950. static Zero(): Ray;
  10951. /**
  10952. * Creates a new ray from screen space and viewport
  10953. * @param x position
  10954. * @param y y position
  10955. * @param viewportWidth viewport width
  10956. * @param viewportHeight viewport height
  10957. * @param world world matrix
  10958. * @param view view matrix
  10959. * @param projection projection matrix
  10960. * @returns new ray
  10961. */
  10962. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10963. /**
  10964. * 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
  10965. * transformed to the given world matrix.
  10966. * @param origin The origin point
  10967. * @param end The end point
  10968. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10969. * @returns the new ray
  10970. */
  10971. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10972. /**
  10973. * Transforms a ray by a matrix
  10974. * @param ray ray to transform
  10975. * @param matrix matrix to apply
  10976. * @returns the resulting new ray
  10977. */
  10978. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10979. /**
  10980. * Transforms a ray by a matrix
  10981. * @param ray ray to transform
  10982. * @param matrix matrix to apply
  10983. * @param result ray to store result in
  10984. */
  10985. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10986. /**
  10987. * Unproject a ray from screen space to object space
  10988. * @param sourceX defines the screen space x coordinate to use
  10989. * @param sourceY defines the screen space y coordinate to use
  10990. * @param viewportWidth defines the current width of the viewport
  10991. * @param viewportHeight defines the current height of the viewport
  10992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10993. * @param view defines the view matrix to use
  10994. * @param projection defines the projection matrix to use
  10995. */
  10996. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10997. }
  10998. /**
  10999. * Type used to define predicate used to select faces when a mesh intersection is detected
  11000. */
  11001. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11002. interface Scene {
  11003. /** @hidden */
  11004. _tempPickingRay: Nullable<Ray>;
  11005. /** @hidden */
  11006. _cachedRayForTransform: Ray;
  11007. /** @hidden */
  11008. _pickWithRayInverseMatrix: Matrix;
  11009. /** @hidden */
  11010. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11011. /** @hidden */
  11012. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11013. /** @hidden */
  11014. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11015. }
  11016. }
  11017. declare module BABYLON {
  11018. /**
  11019. * Groups all the scene component constants in one place to ease maintenance.
  11020. * @hidden
  11021. */
  11022. export class SceneComponentConstants {
  11023. static readonly NAME_EFFECTLAYER: string;
  11024. static readonly NAME_LAYER: string;
  11025. static readonly NAME_LENSFLARESYSTEM: string;
  11026. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11027. static readonly NAME_PARTICLESYSTEM: string;
  11028. static readonly NAME_GAMEPAD: string;
  11029. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11030. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11031. static readonly NAME_PREPASSRENDERER: string;
  11032. static readonly NAME_DEPTHRENDERER: string;
  11033. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11034. static readonly NAME_SPRITE: string;
  11035. static readonly NAME_SUBSURFACE: string;
  11036. static readonly NAME_OUTLINERENDERER: string;
  11037. static readonly NAME_PROCEDURALTEXTURE: string;
  11038. static readonly NAME_SHADOWGENERATOR: string;
  11039. static readonly NAME_OCTREE: string;
  11040. static readonly NAME_PHYSICSENGINE: string;
  11041. static readonly NAME_AUDIO: string;
  11042. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11043. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11044. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11045. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11046. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11047. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11048. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11049. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11050. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11051. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11052. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11053. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11054. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11055. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11056. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11057. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11058. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11059. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11060. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11061. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11062. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11063. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11064. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11065. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11066. static readonly STEP_AFTERRENDER_AUDIO: number;
  11067. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11068. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11069. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11070. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11071. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11072. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11073. static readonly STEP_POINTERMOVE_SPRITE: number;
  11074. static readonly STEP_POINTERDOWN_SPRITE: number;
  11075. static readonly STEP_POINTERUP_SPRITE: number;
  11076. }
  11077. /**
  11078. * This represents a scene component.
  11079. *
  11080. * This is used to decouple the dependency the scene is having on the different workloads like
  11081. * layers, post processes...
  11082. */
  11083. export interface ISceneComponent {
  11084. /**
  11085. * The name of the component. Each component must have a unique name.
  11086. */
  11087. name: string;
  11088. /**
  11089. * The scene the component belongs to.
  11090. */
  11091. scene: Scene;
  11092. /**
  11093. * Register the component to one instance of a scene.
  11094. */
  11095. register(): void;
  11096. /**
  11097. * Rebuilds the elements related to this component in case of
  11098. * context lost for instance.
  11099. */
  11100. rebuild(): void;
  11101. /**
  11102. * Disposes the component and the associated ressources.
  11103. */
  11104. dispose(): void;
  11105. }
  11106. /**
  11107. * This represents a SERIALIZABLE scene component.
  11108. *
  11109. * This extends Scene Component to add Serialization methods on top.
  11110. */
  11111. export interface ISceneSerializableComponent extends ISceneComponent {
  11112. /**
  11113. * Adds all the elements from the container to the scene
  11114. * @param container the container holding the elements
  11115. */
  11116. addFromContainer(container: AbstractScene): void;
  11117. /**
  11118. * Removes all the elements in the container from the scene
  11119. * @param container contains the elements to remove
  11120. * @param dispose if the removed element should be disposed (default: false)
  11121. */
  11122. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11123. /**
  11124. * Serializes the component data to the specified json object
  11125. * @param serializationObject The object to serialize to
  11126. */
  11127. serialize(serializationObject: any): void;
  11128. }
  11129. /**
  11130. * Strong typing of a Mesh related stage step action
  11131. */
  11132. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11133. /**
  11134. * Strong typing of a Evaluate Sub Mesh related stage step action
  11135. */
  11136. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11137. /**
  11138. * Strong typing of a pre active Mesh related stage step action
  11139. */
  11140. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11141. /**
  11142. * Strong typing of a Camera related stage step action
  11143. */
  11144. export type CameraStageAction = (camera: Camera) => void;
  11145. /**
  11146. * Strong typing of a Camera Frame buffer related stage step action
  11147. */
  11148. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11149. /**
  11150. * Strong typing of a Render Target related stage step action
  11151. */
  11152. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11153. /**
  11154. * Strong typing of a RenderingGroup related stage step action
  11155. */
  11156. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11157. /**
  11158. * Strong typing of a Mesh Render related stage step action
  11159. */
  11160. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11161. /**
  11162. * Strong typing of a simple stage step action
  11163. */
  11164. export type SimpleStageAction = () => void;
  11165. /**
  11166. * Strong typing of a render target action.
  11167. */
  11168. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11169. /**
  11170. * Strong typing of a pointer move action.
  11171. */
  11172. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11173. /**
  11174. * Strong typing of a pointer up/down action.
  11175. */
  11176. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11177. /**
  11178. * Representation of a stage in the scene (Basically a list of ordered steps)
  11179. * @hidden
  11180. */
  11181. export class Stage<T extends Function> extends Array<{
  11182. index: number;
  11183. component: ISceneComponent;
  11184. action: T;
  11185. }> {
  11186. /**
  11187. * Hide ctor from the rest of the world.
  11188. * @param items The items to add.
  11189. */
  11190. private constructor();
  11191. /**
  11192. * Creates a new Stage.
  11193. * @returns A new instance of a Stage
  11194. */
  11195. static Create<T extends Function>(): Stage<T>;
  11196. /**
  11197. * Registers a step in an ordered way in the targeted stage.
  11198. * @param index Defines the position to register the step in
  11199. * @param component Defines the component attached to the step
  11200. * @param action Defines the action to launch during the step
  11201. */
  11202. registerStep(index: number, component: ISceneComponent, action: T): void;
  11203. /**
  11204. * Clears all the steps from the stage.
  11205. */
  11206. clear(): void;
  11207. }
  11208. }
  11209. declare module BABYLON {
  11210. interface Scene {
  11211. /** @hidden */
  11212. _pointerOverSprite: Nullable<Sprite>;
  11213. /** @hidden */
  11214. _pickedDownSprite: Nullable<Sprite>;
  11215. /** @hidden */
  11216. _tempSpritePickingRay: Nullable<Ray>;
  11217. /**
  11218. * All of the sprite managers added to this scene
  11219. * @see https://doc.babylonjs.com/babylon101/sprites
  11220. */
  11221. spriteManagers: Array<ISpriteManager>;
  11222. /**
  11223. * An event triggered when sprites rendering is about to start
  11224. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11225. */
  11226. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11227. /**
  11228. * An event triggered when sprites rendering is done
  11229. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11230. */
  11231. onAfterSpritesRenderingObservable: Observable<Scene>;
  11232. /** @hidden */
  11233. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11234. /** Launch a ray to try to pick a sprite in the scene
  11235. * @param x position on screen
  11236. * @param y position on screen
  11237. * @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
  11238. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11239. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11240. * @returns a PickingInfo
  11241. */
  11242. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11243. /** Use the given ray to pick a sprite in the scene
  11244. * @param ray The ray (in world space) to use to pick meshes
  11245. * @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
  11246. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11247. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11248. * @returns a PickingInfo
  11249. */
  11250. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11251. /** @hidden */
  11252. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11253. /** Launch a ray to try to pick sprites in the scene
  11254. * @param x position on screen
  11255. * @param y position on screen
  11256. * @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
  11257. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11258. * @returns a PickingInfo array
  11259. */
  11260. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11261. /** Use the given ray to pick sprites in the scene
  11262. * @param ray The ray (in world space) to use to pick meshes
  11263. * @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
  11264. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11265. * @returns a PickingInfo array
  11266. */
  11267. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11268. /**
  11269. * Force the sprite under the pointer
  11270. * @param sprite defines the sprite to use
  11271. */
  11272. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11273. /**
  11274. * Gets the sprite under the pointer
  11275. * @returns a Sprite or null if no sprite is under the pointer
  11276. */
  11277. getPointerOverSprite(): Nullable<Sprite>;
  11278. }
  11279. /**
  11280. * Defines the sprite scene component responsible to manage sprites
  11281. * in a given scene.
  11282. */
  11283. export class SpriteSceneComponent implements ISceneComponent {
  11284. /**
  11285. * The component name helpfull to identify the component in the list of scene components.
  11286. */
  11287. readonly name: string;
  11288. /**
  11289. * The scene the component belongs to.
  11290. */
  11291. scene: Scene;
  11292. /** @hidden */
  11293. private _spritePredicate;
  11294. /**
  11295. * Creates a new instance of the component for the given scene
  11296. * @param scene Defines the scene to register the component in
  11297. */
  11298. constructor(scene: Scene);
  11299. /**
  11300. * Registers the component in a given scene
  11301. */
  11302. register(): void;
  11303. /**
  11304. * Rebuilds the elements related to this component in case of
  11305. * context lost for instance.
  11306. */
  11307. rebuild(): void;
  11308. /**
  11309. * Disposes the component and the associated ressources.
  11310. */
  11311. dispose(): void;
  11312. private _pickSpriteButKeepRay;
  11313. private _pointerMove;
  11314. private _pointerDown;
  11315. private _pointerUp;
  11316. }
  11317. }
  11318. declare module BABYLON {
  11319. /**
  11320. * Class used to provide helper for timing
  11321. */
  11322. export class TimingTools {
  11323. /**
  11324. * Polyfill for setImmediate
  11325. * @param action defines the action to execute after the current execution block
  11326. */
  11327. static SetImmediate(action: () => void): void;
  11328. }
  11329. }
  11330. declare module BABYLON {
  11331. /**
  11332. * Class used to enable instatition of objects by class name
  11333. */
  11334. export class InstantiationTools {
  11335. /**
  11336. * Use this object to register external classes like custom textures or material
  11337. * to allow the laoders to instantiate them
  11338. */
  11339. static RegisteredExternalClasses: {
  11340. [key: string]: Object;
  11341. };
  11342. /**
  11343. * Tries to instantiate a new object from a given class name
  11344. * @param className defines the class name to instantiate
  11345. * @returns the new object or null if the system was not able to do the instantiation
  11346. */
  11347. static Instantiate(className: string): any;
  11348. }
  11349. }
  11350. declare module BABYLON {
  11351. /**
  11352. * Class used to host copy specific utilities
  11353. */
  11354. export class CopyTools {
  11355. /**
  11356. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11357. * @param texture defines the texture to read pixels from
  11358. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11359. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11360. * @returns The base64 encoded string or null
  11361. */
  11362. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11363. }
  11364. }
  11365. declare module BABYLON {
  11366. /**
  11367. * Define options used to create a depth texture
  11368. */
  11369. export class DepthTextureCreationOptions {
  11370. /** Specifies whether or not a stencil should be allocated in the texture */
  11371. generateStencil?: boolean;
  11372. /** Specifies whether or not bilinear filtering is enable on the texture */
  11373. bilinearFiltering?: boolean;
  11374. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11375. comparisonFunction?: number;
  11376. /** Specifies if the created texture is a cube texture */
  11377. isCube?: boolean;
  11378. /** Specifies the sample count of the depth/stencil texture texture */
  11379. samples?: number;
  11380. }
  11381. }
  11382. declare module BABYLON {
  11383. interface ThinEngine {
  11384. /**
  11385. * Creates a depth stencil cube texture.
  11386. * This is only available in WebGL 2.
  11387. * @param size The size of face edge in the cube texture.
  11388. * @param options The options defining the cube texture.
  11389. * @returns The cube texture
  11390. */
  11391. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11392. /**
  11393. * Creates a cube texture
  11394. * @param rootUrl defines the url where the files to load is located
  11395. * @param scene defines the current scene
  11396. * @param files defines the list of files to load (1 per face)
  11397. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11398. * @param onLoad defines an optional callback raised when the texture is loaded
  11399. * @param onError defines an optional callback raised if there is an issue to load the texture
  11400. * @param format defines the format of the data
  11401. * @param forcedExtension defines the extension to use to pick the right loader
  11402. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11403. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11404. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11405. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11406. * @param loaderOptions options to be passed to the loader
  11407. * @returns the cube texture as an InternalTexture
  11408. */
  11409. 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;
  11410. /**
  11411. * Creates a cube texture
  11412. * @param rootUrl defines the url where the files to load is located
  11413. * @param scene defines the current scene
  11414. * @param files defines the list of files to load (1 per face)
  11415. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11416. * @param onLoad defines an optional callback raised when the texture is loaded
  11417. * @param onError defines an optional callback raised if there is an issue to load the texture
  11418. * @param format defines the format of the data
  11419. * @param forcedExtension defines the extension to use to pick the right loader
  11420. * @returns the cube texture as an InternalTexture
  11421. */
  11422. 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;
  11423. /**
  11424. * Creates a cube texture
  11425. * @param rootUrl defines the url where the files to load is located
  11426. * @param scene defines the current scene
  11427. * @param files defines the list of files to load (1 per face)
  11428. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11429. * @param onLoad defines an optional callback raised when the texture is loaded
  11430. * @param onError defines an optional callback raised if there is an issue to load the texture
  11431. * @param format defines the format of the data
  11432. * @param forcedExtension defines the extension to use to pick the right loader
  11433. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11434. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11435. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11436. * @returns the cube texture as an InternalTexture
  11437. */
  11438. 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;
  11439. /** @hidden */
  11440. 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;
  11441. /** @hidden */
  11442. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11443. /** @hidden */
  11444. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11445. /** @hidden */
  11446. _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;
  11447. /** @hidden */
  11448. _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;
  11449. /**
  11450. * @hidden
  11451. */
  11452. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11453. }
  11454. }
  11455. declare module BABYLON {
  11456. /**
  11457. * Class for creating a cube texture
  11458. */
  11459. export class CubeTexture extends BaseTexture {
  11460. private _delayedOnLoad;
  11461. /**
  11462. * Observable triggered once the texture has been loaded.
  11463. */
  11464. onLoadObservable: Observable<CubeTexture>;
  11465. /**
  11466. * The url of the texture
  11467. */
  11468. url: string;
  11469. /**
  11470. * Gets or sets the center of the bounding box associated with the cube texture.
  11471. * It must define where the camera used to render the texture was set
  11472. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11473. */
  11474. boundingBoxPosition: Vector3;
  11475. private _boundingBoxSize;
  11476. /**
  11477. * Gets or sets the size of the bounding box associated with the cube texture
  11478. * When defined, the cubemap will switch to local mode
  11479. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11480. * @example https://www.babylonjs-playground.com/#RNASML
  11481. */
  11482. set boundingBoxSize(value: Vector3);
  11483. /**
  11484. * Returns the bounding box size
  11485. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11486. */
  11487. get boundingBoxSize(): Vector3;
  11488. protected _rotationY: number;
  11489. /**
  11490. * Sets texture matrix rotation angle around Y axis in radians.
  11491. */
  11492. set rotationY(value: number);
  11493. /**
  11494. * Gets texture matrix rotation angle around Y axis radians.
  11495. */
  11496. get rotationY(): number;
  11497. /**
  11498. * Are mip maps generated for this texture or not.
  11499. */
  11500. get noMipmap(): boolean;
  11501. private _noMipmap;
  11502. private _files;
  11503. protected _forcedExtension: Nullable<string>;
  11504. private _extensions;
  11505. private _textureMatrix;
  11506. private _format;
  11507. private _createPolynomials;
  11508. private _loaderOptions;
  11509. /**
  11510. * Creates a cube texture from an array of image urls
  11511. * @param files defines an array of image urls
  11512. * @param scene defines the hosting scene
  11513. * @param noMipmap specifies if mip maps are not used
  11514. * @returns a cube texture
  11515. */
  11516. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11517. /**
  11518. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11519. * @param url defines the url of the prefiltered texture
  11520. * @param scene defines the scene the texture is attached to
  11521. * @param forcedExtension defines the extension of the file if different from the url
  11522. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11523. * @return the prefiltered texture
  11524. */
  11525. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11526. /**
  11527. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11528. * as prefiltered data.
  11529. * @param rootUrl defines the url of the texture or the root name of the six images
  11530. * @param null defines the scene or engine the texture is attached to
  11531. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11532. * @param noMipmap defines if mipmaps should be created or not
  11533. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11534. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11535. * @param onError defines a callback triggered in case of error during load
  11536. * @param format defines the internal format to use for the texture once loaded
  11537. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11538. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11539. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11540. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11541. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11542. * @param loaderOptions options to be passed to the loader
  11543. * @return the cube texture
  11544. */
  11545. 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);
  11546. /**
  11547. * Get the current class name of the texture useful for serialization or dynamic coding.
  11548. * @returns "CubeTexture"
  11549. */
  11550. getClassName(): string;
  11551. /**
  11552. * Update the url (and optional buffer) of this texture if url was null during construction.
  11553. * @param url the url of the texture
  11554. * @param forcedExtension defines the extension to use
  11555. * @param onLoad callback called when the texture is loaded (defaults to null)
  11556. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11557. */
  11558. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11559. /**
  11560. * Delays loading of the cube texture
  11561. * @param forcedExtension defines the extension to use
  11562. */
  11563. delayLoad(forcedExtension?: string): void;
  11564. /**
  11565. * Returns the reflection texture matrix
  11566. * @returns the reflection texture matrix
  11567. */
  11568. getReflectionTextureMatrix(): Matrix;
  11569. /**
  11570. * Sets the reflection texture matrix
  11571. * @param value Reflection texture matrix
  11572. */
  11573. setReflectionTextureMatrix(value: Matrix): void;
  11574. /**
  11575. * Parses text to create a cube texture
  11576. * @param parsedTexture define the serialized text to read from
  11577. * @param scene defines the hosting scene
  11578. * @param rootUrl defines the root url of the cube texture
  11579. * @returns a cube texture
  11580. */
  11581. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11582. /**
  11583. * Makes a clone, or deep copy, of the cube texture
  11584. * @returns a new cube texture
  11585. */
  11586. clone(): CubeTexture;
  11587. }
  11588. }
  11589. declare module BABYLON {
  11590. /**
  11591. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11592. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11593. * 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;
  11594. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11595. */
  11596. export class ColorCurves {
  11597. private _dirty;
  11598. private _tempColor;
  11599. private _globalCurve;
  11600. private _highlightsCurve;
  11601. private _midtonesCurve;
  11602. private _shadowsCurve;
  11603. private _positiveCurve;
  11604. private _negativeCurve;
  11605. private _globalHue;
  11606. private _globalDensity;
  11607. private _globalSaturation;
  11608. private _globalExposure;
  11609. /**
  11610. * Gets the global Hue value.
  11611. * 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).
  11612. */
  11613. get globalHue(): number;
  11614. /**
  11615. * Sets the global Hue value.
  11616. * 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).
  11617. */
  11618. set globalHue(value: number);
  11619. /**
  11620. * Gets the global Density value.
  11621. * 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.
  11622. * Values less than zero provide a filter of opposite hue.
  11623. */
  11624. get globalDensity(): number;
  11625. /**
  11626. * Sets the global Density value.
  11627. * 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.
  11628. * Values less than zero provide a filter of opposite hue.
  11629. */
  11630. set globalDensity(value: number);
  11631. /**
  11632. * Gets the global Saturation value.
  11633. * 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.
  11634. */
  11635. get globalSaturation(): number;
  11636. /**
  11637. * Sets the global Saturation value.
  11638. * 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.
  11639. */
  11640. set globalSaturation(value: number);
  11641. /**
  11642. * Gets the global Exposure value.
  11643. * 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.
  11644. */
  11645. get globalExposure(): number;
  11646. /**
  11647. * Sets the global Exposure value.
  11648. * 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.
  11649. */
  11650. set globalExposure(value: number);
  11651. private _highlightsHue;
  11652. private _highlightsDensity;
  11653. private _highlightsSaturation;
  11654. private _highlightsExposure;
  11655. /**
  11656. * Gets the highlights Hue value.
  11657. * 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).
  11658. */
  11659. get highlightsHue(): number;
  11660. /**
  11661. * Sets the highlights Hue value.
  11662. * 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).
  11663. */
  11664. set highlightsHue(value: number);
  11665. /**
  11666. * Gets the highlights Density value.
  11667. * 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.
  11668. * Values less than zero provide a filter of opposite hue.
  11669. */
  11670. get highlightsDensity(): number;
  11671. /**
  11672. * Sets the highlights Density value.
  11673. * 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.
  11674. * Values less than zero provide a filter of opposite hue.
  11675. */
  11676. set highlightsDensity(value: number);
  11677. /**
  11678. * Gets the highlights Saturation value.
  11679. * 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.
  11680. */
  11681. get highlightsSaturation(): number;
  11682. /**
  11683. * Sets the highlights Saturation value.
  11684. * 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.
  11685. */
  11686. set highlightsSaturation(value: number);
  11687. /**
  11688. * Gets the highlights Exposure value.
  11689. * 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.
  11690. */
  11691. get highlightsExposure(): number;
  11692. /**
  11693. * Sets the highlights Exposure value.
  11694. * 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.
  11695. */
  11696. set highlightsExposure(value: number);
  11697. private _midtonesHue;
  11698. private _midtonesDensity;
  11699. private _midtonesSaturation;
  11700. private _midtonesExposure;
  11701. /**
  11702. * Gets the midtones Hue value.
  11703. * 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).
  11704. */
  11705. get midtonesHue(): number;
  11706. /**
  11707. * Sets the midtones Hue value.
  11708. * 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).
  11709. */
  11710. set midtonesHue(value: number);
  11711. /**
  11712. * Gets the midtones Density value.
  11713. * 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.
  11714. * Values less than zero provide a filter of opposite hue.
  11715. */
  11716. get midtonesDensity(): number;
  11717. /**
  11718. * Sets the midtones Density value.
  11719. * 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.
  11720. * Values less than zero provide a filter of opposite hue.
  11721. */
  11722. set midtonesDensity(value: number);
  11723. /**
  11724. * Gets the midtones Saturation value.
  11725. * 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.
  11726. */
  11727. get midtonesSaturation(): number;
  11728. /**
  11729. * Sets the midtones Saturation value.
  11730. * 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.
  11731. */
  11732. set midtonesSaturation(value: number);
  11733. /**
  11734. * Gets the midtones Exposure value.
  11735. * 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.
  11736. */
  11737. get midtonesExposure(): number;
  11738. /**
  11739. * Sets the midtones Exposure value.
  11740. * 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.
  11741. */
  11742. set midtonesExposure(value: number);
  11743. private _shadowsHue;
  11744. private _shadowsDensity;
  11745. private _shadowsSaturation;
  11746. private _shadowsExposure;
  11747. /**
  11748. * Gets the shadows Hue value.
  11749. * 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).
  11750. */
  11751. get shadowsHue(): number;
  11752. /**
  11753. * Sets the shadows Hue value.
  11754. * 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).
  11755. */
  11756. set shadowsHue(value: number);
  11757. /**
  11758. * Gets the shadows Density value.
  11759. * 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.
  11760. * Values less than zero provide a filter of opposite hue.
  11761. */
  11762. get shadowsDensity(): number;
  11763. /**
  11764. * Sets the shadows Density value.
  11765. * 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.
  11766. * Values less than zero provide a filter of opposite hue.
  11767. */
  11768. set shadowsDensity(value: number);
  11769. /**
  11770. * Gets the shadows Saturation value.
  11771. * 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.
  11772. */
  11773. get shadowsSaturation(): number;
  11774. /**
  11775. * Sets the shadows Saturation value.
  11776. * 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.
  11777. */
  11778. set shadowsSaturation(value: number);
  11779. /**
  11780. * Gets the shadows Exposure value.
  11781. * 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.
  11782. */
  11783. get shadowsExposure(): number;
  11784. /**
  11785. * Sets the shadows Exposure value.
  11786. * 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.
  11787. */
  11788. set shadowsExposure(value: number);
  11789. /**
  11790. * Returns the class name
  11791. * @returns The class name
  11792. */
  11793. getClassName(): string;
  11794. /**
  11795. * Binds the color curves to the shader.
  11796. * @param colorCurves The color curve to bind
  11797. * @param effect The effect to bind to
  11798. * @param positiveUniform The positive uniform shader parameter
  11799. * @param neutralUniform The neutral uniform shader parameter
  11800. * @param negativeUniform The negative uniform shader parameter
  11801. */
  11802. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11803. /**
  11804. * Prepare the list of uniforms associated with the ColorCurves effects.
  11805. * @param uniformsList The list of uniforms used in the effect
  11806. */
  11807. static PrepareUniforms(uniformsList: string[]): void;
  11808. /**
  11809. * Returns color grading data based on a hue, density, saturation and exposure value.
  11810. * @param filterHue The hue of the color filter.
  11811. * @param filterDensity The density of the color filter.
  11812. * @param saturation The saturation.
  11813. * @param exposure The exposure.
  11814. * @param result The result data container.
  11815. */
  11816. private getColorGradingDataToRef;
  11817. /**
  11818. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11819. * @param value The input slider value in range [-100,100].
  11820. * @returns Adjusted value.
  11821. */
  11822. private static applyColorGradingSliderNonlinear;
  11823. /**
  11824. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11825. * @param hue The hue (H) input.
  11826. * @param saturation The saturation (S) input.
  11827. * @param brightness The brightness (B) input.
  11828. * @result An RGBA color represented as Vector4.
  11829. */
  11830. private static fromHSBToRef;
  11831. /**
  11832. * Returns a value clamped between min and max
  11833. * @param value The value to clamp
  11834. * @param min The minimum of value
  11835. * @param max The maximum of value
  11836. * @returns The clamped value.
  11837. */
  11838. private static clamp;
  11839. /**
  11840. * Clones the current color curve instance.
  11841. * @return The cloned curves
  11842. */
  11843. clone(): ColorCurves;
  11844. /**
  11845. * Serializes the current color curve instance to a json representation.
  11846. * @return a JSON representation
  11847. */
  11848. serialize(): any;
  11849. /**
  11850. * Parses the color curve from a json representation.
  11851. * @param source the JSON source to parse
  11852. * @return The parsed curves
  11853. */
  11854. static Parse(source: any): ColorCurves;
  11855. }
  11856. }
  11857. declare module BABYLON {
  11858. /**
  11859. * Interface to follow in your material defines to integrate easily the
  11860. * Image proccessing functions.
  11861. * @hidden
  11862. */
  11863. export interface IImageProcessingConfigurationDefines {
  11864. IMAGEPROCESSING: boolean;
  11865. VIGNETTE: boolean;
  11866. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11867. VIGNETTEBLENDMODEOPAQUE: boolean;
  11868. TONEMAPPING: boolean;
  11869. TONEMAPPING_ACES: boolean;
  11870. CONTRAST: boolean;
  11871. EXPOSURE: boolean;
  11872. COLORCURVES: boolean;
  11873. COLORGRADING: boolean;
  11874. COLORGRADING3D: boolean;
  11875. SAMPLER3DGREENDEPTH: boolean;
  11876. SAMPLER3DBGRMAP: boolean;
  11877. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11878. }
  11879. /**
  11880. * @hidden
  11881. */
  11882. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11883. IMAGEPROCESSING: boolean;
  11884. VIGNETTE: boolean;
  11885. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11886. VIGNETTEBLENDMODEOPAQUE: boolean;
  11887. TONEMAPPING: boolean;
  11888. TONEMAPPING_ACES: boolean;
  11889. CONTRAST: boolean;
  11890. COLORCURVES: boolean;
  11891. COLORGRADING: boolean;
  11892. COLORGRADING3D: boolean;
  11893. SAMPLER3DGREENDEPTH: boolean;
  11894. SAMPLER3DBGRMAP: boolean;
  11895. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11896. EXPOSURE: boolean;
  11897. constructor();
  11898. }
  11899. /**
  11900. * This groups together the common properties used for image processing either in direct forward pass
  11901. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11902. * or not.
  11903. */
  11904. export class ImageProcessingConfiguration {
  11905. /**
  11906. * Default tone mapping applied in BabylonJS.
  11907. */
  11908. static readonly TONEMAPPING_STANDARD: number;
  11909. /**
  11910. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11911. * to other engines rendering to increase portability.
  11912. */
  11913. static readonly TONEMAPPING_ACES: number;
  11914. /**
  11915. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11916. */
  11917. colorCurves: Nullable<ColorCurves>;
  11918. private _colorCurvesEnabled;
  11919. /**
  11920. * Gets wether the color curves effect is enabled.
  11921. */
  11922. get colorCurvesEnabled(): boolean;
  11923. /**
  11924. * Sets wether the color curves effect is enabled.
  11925. */
  11926. set colorCurvesEnabled(value: boolean);
  11927. private _colorGradingTexture;
  11928. /**
  11929. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11930. */
  11931. get colorGradingTexture(): Nullable<BaseTexture>;
  11932. /**
  11933. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11934. */
  11935. set colorGradingTexture(value: Nullable<BaseTexture>);
  11936. private _colorGradingEnabled;
  11937. /**
  11938. * Gets wether the color grading effect is enabled.
  11939. */
  11940. get colorGradingEnabled(): boolean;
  11941. /**
  11942. * Sets wether the color grading effect is enabled.
  11943. */
  11944. set colorGradingEnabled(value: boolean);
  11945. private _colorGradingWithGreenDepth;
  11946. /**
  11947. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11948. */
  11949. get colorGradingWithGreenDepth(): boolean;
  11950. /**
  11951. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11952. */
  11953. set colorGradingWithGreenDepth(value: boolean);
  11954. private _colorGradingBGR;
  11955. /**
  11956. * Gets wether the color grading texture contains BGR values.
  11957. */
  11958. get colorGradingBGR(): boolean;
  11959. /**
  11960. * Sets wether the color grading texture contains BGR values.
  11961. */
  11962. set colorGradingBGR(value: boolean);
  11963. /** @hidden */
  11964. _exposure: number;
  11965. /**
  11966. * Gets the Exposure used in the effect.
  11967. */
  11968. get exposure(): number;
  11969. /**
  11970. * Sets the Exposure used in the effect.
  11971. */
  11972. set exposure(value: number);
  11973. private _toneMappingEnabled;
  11974. /**
  11975. * Gets wether the tone mapping effect is enabled.
  11976. */
  11977. get toneMappingEnabled(): boolean;
  11978. /**
  11979. * Sets wether the tone mapping effect is enabled.
  11980. */
  11981. set toneMappingEnabled(value: boolean);
  11982. private _toneMappingType;
  11983. /**
  11984. * Gets the type of tone mapping effect.
  11985. */
  11986. get toneMappingType(): number;
  11987. /**
  11988. * Sets the type of tone mapping effect used in BabylonJS.
  11989. */
  11990. set toneMappingType(value: number);
  11991. protected _contrast: number;
  11992. /**
  11993. * Gets the contrast used in the effect.
  11994. */
  11995. get contrast(): number;
  11996. /**
  11997. * Sets the contrast used in the effect.
  11998. */
  11999. set contrast(value: number);
  12000. /**
  12001. * Vignette stretch size.
  12002. */
  12003. vignetteStretch: number;
  12004. /**
  12005. * Vignette centre X Offset.
  12006. */
  12007. vignetteCentreX: number;
  12008. /**
  12009. * Vignette centre Y Offset.
  12010. */
  12011. vignetteCentreY: number;
  12012. /**
  12013. * Vignette weight or intensity of the vignette effect.
  12014. */
  12015. vignetteWeight: number;
  12016. /**
  12017. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12018. * if vignetteEnabled is set to true.
  12019. */
  12020. vignetteColor: Color4;
  12021. /**
  12022. * Camera field of view used by the Vignette effect.
  12023. */
  12024. vignetteCameraFov: number;
  12025. private _vignetteBlendMode;
  12026. /**
  12027. * Gets the vignette blend mode allowing different kind of effect.
  12028. */
  12029. get vignetteBlendMode(): number;
  12030. /**
  12031. * Sets the vignette blend mode allowing different kind of effect.
  12032. */
  12033. set vignetteBlendMode(value: number);
  12034. private _vignetteEnabled;
  12035. /**
  12036. * Gets wether the vignette effect is enabled.
  12037. */
  12038. get vignetteEnabled(): boolean;
  12039. /**
  12040. * Sets wether the vignette effect is enabled.
  12041. */
  12042. set vignetteEnabled(value: boolean);
  12043. private _applyByPostProcess;
  12044. /**
  12045. * Gets wether the image processing is applied through a post process or not.
  12046. */
  12047. get applyByPostProcess(): boolean;
  12048. /**
  12049. * Sets wether the image processing is applied through a post process or not.
  12050. */
  12051. set applyByPostProcess(value: boolean);
  12052. private _isEnabled;
  12053. /**
  12054. * Gets wether the image processing is enabled or not.
  12055. */
  12056. get isEnabled(): boolean;
  12057. /**
  12058. * Sets wether the image processing is enabled or not.
  12059. */
  12060. set isEnabled(value: boolean);
  12061. /**
  12062. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12063. */
  12064. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12065. /**
  12066. * Method called each time the image processing information changes requires to recompile the effect.
  12067. */
  12068. protected _updateParameters(): void;
  12069. /**
  12070. * Gets the current class name.
  12071. * @return "ImageProcessingConfiguration"
  12072. */
  12073. getClassName(): string;
  12074. /**
  12075. * Prepare the list of uniforms associated with the Image Processing effects.
  12076. * @param uniforms The list of uniforms used in the effect
  12077. * @param defines the list of defines currently in use
  12078. */
  12079. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12080. /**
  12081. * Prepare the list of samplers associated with the Image Processing effects.
  12082. * @param samplersList The list of uniforms used in the effect
  12083. * @param defines the list of defines currently in use
  12084. */
  12085. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12086. /**
  12087. * Prepare the list of defines associated to the shader.
  12088. * @param defines the list of defines to complete
  12089. * @param forPostProcess Define if we are currently in post process mode or not
  12090. */
  12091. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12092. /**
  12093. * Returns true if all the image processing information are ready.
  12094. * @returns True if ready, otherwise, false
  12095. */
  12096. isReady(): boolean;
  12097. /**
  12098. * Binds the image processing to the shader.
  12099. * @param effect The effect to bind to
  12100. * @param overrideAspectRatio Override the aspect ratio of the effect
  12101. */
  12102. bind(effect: Effect, overrideAspectRatio?: number): void;
  12103. /**
  12104. * Clones the current image processing instance.
  12105. * @return The cloned image processing
  12106. */
  12107. clone(): ImageProcessingConfiguration;
  12108. /**
  12109. * Serializes the current image processing instance to a json representation.
  12110. * @return a JSON representation
  12111. */
  12112. serialize(): any;
  12113. /**
  12114. * Parses the image processing from a json representation.
  12115. * @param source the JSON source to parse
  12116. * @return The parsed image processing
  12117. */
  12118. static Parse(source: any): ImageProcessingConfiguration;
  12119. private static _VIGNETTEMODE_MULTIPLY;
  12120. private static _VIGNETTEMODE_OPAQUE;
  12121. /**
  12122. * Used to apply the vignette as a mix with the pixel color.
  12123. */
  12124. static get VIGNETTEMODE_MULTIPLY(): number;
  12125. /**
  12126. * Used to apply the vignette as a replacement of the pixel color.
  12127. */
  12128. static get VIGNETTEMODE_OPAQUE(): number;
  12129. }
  12130. }
  12131. declare module BABYLON {
  12132. /** @hidden */
  12133. export var postprocessVertexShader: {
  12134. name: string;
  12135. shader: string;
  12136. };
  12137. }
  12138. declare module BABYLON {
  12139. /**
  12140. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12141. */
  12142. export type RenderTargetTextureSize = number | {
  12143. width: number;
  12144. height: number;
  12145. layers?: number;
  12146. };
  12147. interface ThinEngine {
  12148. /**
  12149. * Creates a new render target texture
  12150. * @param size defines the size of the texture
  12151. * @param options defines the options used to create the texture
  12152. * @returns a new render target texture stored in an InternalTexture
  12153. */
  12154. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12155. /**
  12156. * Creates a depth stencil texture.
  12157. * This is only available in WebGL 2 or with the depth texture extension available.
  12158. * @param size The size of face edge in the texture.
  12159. * @param options The options defining the texture.
  12160. * @returns The texture
  12161. */
  12162. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12163. /** @hidden */
  12164. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12165. }
  12166. }
  12167. declare module BABYLON {
  12168. /**
  12169. * Defines the kind of connection point for node based material
  12170. */
  12171. export enum NodeMaterialBlockConnectionPointTypes {
  12172. /** Float */
  12173. Float = 1,
  12174. /** Int */
  12175. Int = 2,
  12176. /** Vector2 */
  12177. Vector2 = 4,
  12178. /** Vector3 */
  12179. Vector3 = 8,
  12180. /** Vector4 */
  12181. Vector4 = 16,
  12182. /** Color3 */
  12183. Color3 = 32,
  12184. /** Color4 */
  12185. Color4 = 64,
  12186. /** Matrix */
  12187. Matrix = 128,
  12188. /** Custom object */
  12189. Object = 256,
  12190. /** Detect type based on connection */
  12191. AutoDetect = 1024,
  12192. /** Output type that will be defined by input type */
  12193. BasedOnInput = 2048
  12194. }
  12195. }
  12196. declare module BABYLON {
  12197. /**
  12198. * Enum used to define the target of a block
  12199. */
  12200. export enum NodeMaterialBlockTargets {
  12201. /** Vertex shader */
  12202. Vertex = 1,
  12203. /** Fragment shader */
  12204. Fragment = 2,
  12205. /** Neutral */
  12206. Neutral = 4,
  12207. /** Vertex and Fragment */
  12208. VertexAndFragment = 3
  12209. }
  12210. }
  12211. declare module BABYLON {
  12212. /**
  12213. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12214. */
  12215. export enum NodeMaterialBlockConnectionPointMode {
  12216. /** Value is an uniform */
  12217. Uniform = 0,
  12218. /** Value is a mesh attribute */
  12219. Attribute = 1,
  12220. /** Value is a varying between vertex and fragment shaders */
  12221. Varying = 2,
  12222. /** Mode is undefined */
  12223. Undefined = 3
  12224. }
  12225. }
  12226. declare module BABYLON {
  12227. /**
  12228. * Enum used to define system values e.g. values automatically provided by the system
  12229. */
  12230. export enum NodeMaterialSystemValues {
  12231. /** World */
  12232. World = 1,
  12233. /** View */
  12234. View = 2,
  12235. /** Projection */
  12236. Projection = 3,
  12237. /** ViewProjection */
  12238. ViewProjection = 4,
  12239. /** WorldView */
  12240. WorldView = 5,
  12241. /** WorldViewProjection */
  12242. WorldViewProjection = 6,
  12243. /** CameraPosition */
  12244. CameraPosition = 7,
  12245. /** Fog Color */
  12246. FogColor = 8,
  12247. /** Delta time */
  12248. DeltaTime = 9
  12249. }
  12250. }
  12251. declare module BABYLON {
  12252. /**
  12253. * Represents a camera frustum
  12254. */
  12255. export class Frustum {
  12256. /**
  12257. * Gets the planes representing the frustum
  12258. * @param transform matrix to be applied to the returned planes
  12259. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12260. */
  12261. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12262. /**
  12263. * Gets the near frustum plane transformed by the transform matrix
  12264. * @param transform transformation matrix to be applied to the resulting frustum plane
  12265. * @param frustumPlane the resuling frustum plane
  12266. */
  12267. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12268. /**
  12269. * Gets the far frustum plane transformed by the transform matrix
  12270. * @param transform transformation matrix to be applied to the resulting frustum plane
  12271. * @param frustumPlane the resuling frustum plane
  12272. */
  12273. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12274. /**
  12275. * Gets the left frustum plane transformed by the transform matrix
  12276. * @param transform transformation matrix to be applied to the resulting frustum plane
  12277. * @param frustumPlane the resuling frustum plane
  12278. */
  12279. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12280. /**
  12281. * Gets the right frustum plane transformed by the transform matrix
  12282. * @param transform transformation matrix to be applied to the resulting frustum plane
  12283. * @param frustumPlane the resuling frustum plane
  12284. */
  12285. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12286. /**
  12287. * Gets the top frustum plane transformed by the transform matrix
  12288. * @param transform transformation matrix to be applied to the resulting frustum plane
  12289. * @param frustumPlane the resuling frustum plane
  12290. */
  12291. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12292. /**
  12293. * Gets the bottom frustum plane transformed by the transform matrix
  12294. * @param transform transformation matrix to be applied to the resulting frustum plane
  12295. * @param frustumPlane the resuling frustum plane
  12296. */
  12297. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12298. /**
  12299. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12300. * @param transform transformation matrix to be applied to the resulting frustum planes
  12301. * @param frustumPlanes the resuling frustum planes
  12302. */
  12303. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12304. }
  12305. }
  12306. declare module BABYLON {
  12307. /**
  12308. * Contains position and normal vectors for a vertex
  12309. */
  12310. export class PositionNormalVertex {
  12311. /** the position of the vertex (defaut: 0,0,0) */
  12312. position: Vector3;
  12313. /** the normal of the vertex (defaut: 0,1,0) */
  12314. normal: Vector3;
  12315. /**
  12316. * Creates a PositionNormalVertex
  12317. * @param position the position of the vertex (defaut: 0,0,0)
  12318. * @param normal the normal of the vertex (defaut: 0,1,0)
  12319. */
  12320. constructor(
  12321. /** the position of the vertex (defaut: 0,0,0) */
  12322. position?: Vector3,
  12323. /** the normal of the vertex (defaut: 0,1,0) */
  12324. normal?: Vector3);
  12325. /**
  12326. * Clones the PositionNormalVertex
  12327. * @returns the cloned PositionNormalVertex
  12328. */
  12329. clone(): PositionNormalVertex;
  12330. }
  12331. /**
  12332. * Contains position, normal and uv vectors for a vertex
  12333. */
  12334. export class PositionNormalTextureVertex {
  12335. /** the position of the vertex (defaut: 0,0,0) */
  12336. position: Vector3;
  12337. /** the normal of the vertex (defaut: 0,1,0) */
  12338. normal: Vector3;
  12339. /** the uv of the vertex (default: 0,0) */
  12340. uv: Vector2;
  12341. /**
  12342. * Creates a PositionNormalTextureVertex
  12343. * @param position the position of the vertex (defaut: 0,0,0)
  12344. * @param normal the normal of the vertex (defaut: 0,1,0)
  12345. * @param uv the uv of the vertex (default: 0,0)
  12346. */
  12347. constructor(
  12348. /** the position of the vertex (defaut: 0,0,0) */
  12349. position?: Vector3,
  12350. /** the normal of the vertex (defaut: 0,1,0) */
  12351. normal?: Vector3,
  12352. /** the uv of the vertex (default: 0,0) */
  12353. uv?: Vector2);
  12354. /**
  12355. * Clones the PositionNormalTextureVertex
  12356. * @returns the cloned PositionNormalTextureVertex
  12357. */
  12358. clone(): PositionNormalTextureVertex;
  12359. }
  12360. }
  12361. declare module BABYLON {
  12362. /**
  12363. * Enum defining the type of animations supported by InputBlock
  12364. */
  12365. export enum AnimatedInputBlockTypes {
  12366. /** No animation */
  12367. None = 0,
  12368. /** Time based animation. Will only work for floats */
  12369. Time = 1
  12370. }
  12371. }
  12372. declare module BABYLON {
  12373. /**
  12374. * Block used to expose an input value
  12375. */
  12376. export class InputBlock extends NodeMaterialBlock {
  12377. private _mode;
  12378. private _associatedVariableName;
  12379. private _storedValue;
  12380. private _valueCallback;
  12381. private _type;
  12382. private _animationType;
  12383. /** Gets or set a value used to limit the range of float values */
  12384. min: number;
  12385. /** Gets or set a value used to limit the range of float values */
  12386. max: number;
  12387. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12388. isBoolean: boolean;
  12389. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12390. matrixMode: number;
  12391. /** @hidden */
  12392. _systemValue: Nullable<NodeMaterialSystemValues>;
  12393. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12394. isConstant: boolean;
  12395. /** Gets or sets the group to use to display this block in the Inspector */
  12396. groupInInspector: string;
  12397. /** Gets an observable raised when the value is changed */
  12398. onValueChangedObservable: Observable<InputBlock>;
  12399. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12400. convertToGammaSpace: boolean;
  12401. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12402. convertToLinearSpace: boolean;
  12403. /**
  12404. * Gets or sets the connection point type (default is float)
  12405. */
  12406. get type(): NodeMaterialBlockConnectionPointTypes;
  12407. /**
  12408. * Creates a new InputBlock
  12409. * @param name defines the block name
  12410. * @param target defines the target of that block (Vertex by default)
  12411. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12412. */
  12413. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12414. /**
  12415. * Validates if a name is a reserve word.
  12416. * @param newName the new name to be given to the node.
  12417. * @returns false if the name is a reserve word, else true.
  12418. */
  12419. validateBlockName(newName: string): boolean;
  12420. /**
  12421. * Gets the output component
  12422. */
  12423. get output(): NodeMaterialConnectionPoint;
  12424. /**
  12425. * Set the source of this connection point to a vertex attribute
  12426. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12427. * @returns the current connection point
  12428. */
  12429. setAsAttribute(attributeName?: string): InputBlock;
  12430. /**
  12431. * Set the source of this connection point to a system value
  12432. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12433. * @returns the current connection point
  12434. */
  12435. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12436. /**
  12437. * Gets or sets the value of that point.
  12438. * Please note that this value will be ignored if valueCallback is defined
  12439. */
  12440. get value(): any;
  12441. set value(value: any);
  12442. /**
  12443. * Gets or sets a callback used to get the value of that point.
  12444. * Please note that setting this value will force the connection point to ignore the value property
  12445. */
  12446. get valueCallback(): () => any;
  12447. set valueCallback(value: () => any);
  12448. /**
  12449. * Gets or sets the associated variable name in the shader
  12450. */
  12451. get associatedVariableName(): string;
  12452. set associatedVariableName(value: string);
  12453. /** Gets or sets the type of animation applied to the input */
  12454. get animationType(): AnimatedInputBlockTypes;
  12455. set animationType(value: AnimatedInputBlockTypes);
  12456. /**
  12457. * Gets a boolean indicating that this connection point not defined yet
  12458. */
  12459. get isUndefined(): boolean;
  12460. /**
  12461. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12462. * In this case the connection point name must be the name of the uniform to use.
  12463. * Can only be set on inputs
  12464. */
  12465. get isUniform(): boolean;
  12466. set isUniform(value: boolean);
  12467. /**
  12468. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12469. * In this case the connection point name must be the name of the attribute to use
  12470. * Can only be set on inputs
  12471. */
  12472. get isAttribute(): boolean;
  12473. set isAttribute(value: boolean);
  12474. /**
  12475. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12476. * Can only be set on exit points
  12477. */
  12478. get isVarying(): boolean;
  12479. set isVarying(value: boolean);
  12480. /**
  12481. * Gets a boolean indicating that the current connection point is a system value
  12482. */
  12483. get isSystemValue(): boolean;
  12484. /**
  12485. * Gets or sets the current well known value or null if not defined as a system value
  12486. */
  12487. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12488. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12489. /**
  12490. * Gets the current class name
  12491. * @returns the class name
  12492. */
  12493. getClassName(): string;
  12494. /**
  12495. * Animate the input if animationType !== None
  12496. * @param scene defines the rendering scene
  12497. */
  12498. animate(scene: Scene): void;
  12499. private _emitDefine;
  12500. initialize(state: NodeMaterialBuildState): void;
  12501. /**
  12502. * Set the input block to its default value (based on its type)
  12503. */
  12504. setDefaultValue(): void;
  12505. private _emitConstant;
  12506. /** @hidden */
  12507. get _noContextSwitch(): boolean;
  12508. private _emit;
  12509. /** @hidden */
  12510. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12511. /** @hidden */
  12512. _transmit(effect: Effect, scene: Scene): void;
  12513. protected _buildBlock(state: NodeMaterialBuildState): void;
  12514. protected _dumpPropertiesCode(): string;
  12515. dispose(): void;
  12516. serialize(): any;
  12517. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12518. }
  12519. }
  12520. declare module BABYLON {
  12521. /**
  12522. * Enum used to define the compatibility state between two connection points
  12523. */
  12524. export enum NodeMaterialConnectionPointCompatibilityStates {
  12525. /** Points are compatibles */
  12526. Compatible = 0,
  12527. /** Points are incompatible because of their types */
  12528. TypeIncompatible = 1,
  12529. /** Points are incompatible because of their targets (vertex vs fragment) */
  12530. TargetIncompatible = 2
  12531. }
  12532. /**
  12533. * Defines the direction of a connection point
  12534. */
  12535. export enum NodeMaterialConnectionPointDirection {
  12536. /** Input */
  12537. Input = 0,
  12538. /** Output */
  12539. Output = 1
  12540. }
  12541. /**
  12542. * Defines a connection point for a block
  12543. */
  12544. export class NodeMaterialConnectionPoint {
  12545. /**
  12546. * Checks if two types are equivalent
  12547. * @param type1 type 1 to check
  12548. * @param type2 type 2 to check
  12549. * @returns true if both types are equivalent, else false
  12550. */
  12551. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12552. /** @hidden */
  12553. _ownerBlock: NodeMaterialBlock;
  12554. /** @hidden */
  12555. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12556. private _endpoints;
  12557. private _associatedVariableName;
  12558. private _direction;
  12559. /** @hidden */
  12560. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12561. /** @hidden */
  12562. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12563. /** @hidden */
  12564. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12565. private _type;
  12566. /** @hidden */
  12567. _enforceAssociatedVariableName: boolean;
  12568. /** Gets the direction of the point */
  12569. get direction(): NodeMaterialConnectionPointDirection;
  12570. /** Indicates that this connection point needs dual validation before being connected to another point */
  12571. needDualDirectionValidation: boolean;
  12572. /**
  12573. * Gets or sets the additional types supported by this connection point
  12574. */
  12575. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12576. /**
  12577. * Gets or sets the additional types excluded by this connection point
  12578. */
  12579. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12580. /**
  12581. * Observable triggered when this point is connected
  12582. */
  12583. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12584. /**
  12585. * Gets or sets the associated variable name in the shader
  12586. */
  12587. get associatedVariableName(): string;
  12588. set associatedVariableName(value: string);
  12589. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12590. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12591. /**
  12592. * Gets or sets the connection point type (default is float)
  12593. */
  12594. get type(): NodeMaterialBlockConnectionPointTypes;
  12595. set type(value: NodeMaterialBlockConnectionPointTypes);
  12596. /**
  12597. * Gets or sets the connection point name
  12598. */
  12599. name: string;
  12600. /**
  12601. * Gets or sets the connection point name
  12602. */
  12603. displayName: string;
  12604. /**
  12605. * Gets or sets a boolean indicating that this connection point can be omitted
  12606. */
  12607. isOptional: boolean;
  12608. /**
  12609. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12610. */
  12611. isExposedOnFrame: boolean;
  12612. /**
  12613. * Gets or sets number indicating the position that the port is exposed to on a frame
  12614. */
  12615. exposedPortPosition: number;
  12616. /**
  12617. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12618. */
  12619. define: string;
  12620. /** @hidden */
  12621. _prioritizeVertex: boolean;
  12622. private _target;
  12623. /** Gets or sets the target of that connection point */
  12624. get target(): NodeMaterialBlockTargets;
  12625. set target(value: NodeMaterialBlockTargets);
  12626. /**
  12627. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12628. */
  12629. get isConnected(): boolean;
  12630. /**
  12631. * Gets a boolean indicating that the current point is connected to an input block
  12632. */
  12633. get isConnectedToInputBlock(): boolean;
  12634. /**
  12635. * Gets a the connected input block (if any)
  12636. */
  12637. get connectInputBlock(): Nullable<InputBlock>;
  12638. /** Get the other side of the connection (if any) */
  12639. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12640. /** Get the block that owns this connection point */
  12641. get ownerBlock(): NodeMaterialBlock;
  12642. /** Get the block connected on the other side of this connection (if any) */
  12643. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12644. /** Get the block connected on the endpoints of this connection (if any) */
  12645. get connectedBlocks(): Array<NodeMaterialBlock>;
  12646. /** Gets the list of connected endpoints */
  12647. get endpoints(): NodeMaterialConnectionPoint[];
  12648. /** Gets a boolean indicating if that output point is connected to at least one input */
  12649. get hasEndpoints(): boolean;
  12650. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12651. get isConnectedInVertexShader(): boolean;
  12652. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12653. get isConnectedInFragmentShader(): boolean;
  12654. /**
  12655. * Creates a block suitable to be used as an input for this input point.
  12656. * If null is returned, a block based on the point type will be created.
  12657. * @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
  12658. */
  12659. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12660. /**
  12661. * Creates a new connection point
  12662. * @param name defines the connection point name
  12663. * @param ownerBlock defines the block hosting this connection point
  12664. * @param direction defines the direction of the connection point
  12665. */
  12666. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12667. /**
  12668. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12669. * @returns the class name
  12670. */
  12671. getClassName(): string;
  12672. /**
  12673. * Gets a boolean indicating if the current point can be connected to another point
  12674. * @param connectionPoint defines the other connection point
  12675. * @returns a boolean
  12676. */
  12677. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12678. /**
  12679. * Gets a number indicating if the current point can be connected to another point
  12680. * @param connectionPoint defines the other connection point
  12681. * @returns a number defining the compatibility state
  12682. */
  12683. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12684. /**
  12685. * Connect this point to another connection point
  12686. * @param connectionPoint defines the other connection point
  12687. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12688. * @returns the current connection point
  12689. */
  12690. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12691. /**
  12692. * Disconnect this point from one of his endpoint
  12693. * @param endpoint defines the other connection point
  12694. * @returns the current connection point
  12695. */
  12696. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12697. /**
  12698. * Serializes this point in a JSON representation
  12699. * @param isInput defines if the connection point is an input (default is true)
  12700. * @returns the serialized point object
  12701. */
  12702. serialize(isInput?: boolean): any;
  12703. /**
  12704. * Release resources
  12705. */
  12706. dispose(): void;
  12707. }
  12708. }
  12709. declare module BABYLON {
  12710. /**
  12711. * Enum used to define the material modes
  12712. */
  12713. export enum NodeMaterialModes {
  12714. /** Regular material */
  12715. Material = 0,
  12716. /** For post process */
  12717. PostProcess = 1,
  12718. /** For particle system */
  12719. Particle = 2,
  12720. /** For procedural texture */
  12721. ProceduralTexture = 3
  12722. }
  12723. }
  12724. declare module BABYLON {
  12725. /** @hidden */
  12726. export var helperFunctions: {
  12727. name: string;
  12728. shader: string;
  12729. };
  12730. }
  12731. declare module BABYLON {
  12732. /**
  12733. * Block used to read a texture from a sampler
  12734. */
  12735. export class TextureBlock extends NodeMaterialBlock {
  12736. private _defineName;
  12737. private _linearDefineName;
  12738. private _gammaDefineName;
  12739. private _tempTextureRead;
  12740. private _samplerName;
  12741. private _transformedUVName;
  12742. private _textureTransformName;
  12743. private _textureInfoName;
  12744. private _mainUVName;
  12745. private _mainUVDefineName;
  12746. private _fragmentOnly;
  12747. /**
  12748. * Gets or sets the texture associated with the node
  12749. */
  12750. texture: Nullable<Texture>;
  12751. /**
  12752. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12753. */
  12754. convertToGammaSpace: boolean;
  12755. /**
  12756. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12757. */
  12758. convertToLinearSpace: boolean;
  12759. /**
  12760. * Create a new TextureBlock
  12761. * @param name defines the block name
  12762. */
  12763. constructor(name: string, fragmentOnly?: boolean);
  12764. /**
  12765. * Gets the current class name
  12766. * @returns the class name
  12767. */
  12768. getClassName(): string;
  12769. /**
  12770. * Gets the uv input component
  12771. */
  12772. get uv(): NodeMaterialConnectionPoint;
  12773. /**
  12774. * Gets the rgba output component
  12775. */
  12776. get rgba(): NodeMaterialConnectionPoint;
  12777. /**
  12778. * Gets the rgb output component
  12779. */
  12780. get rgb(): NodeMaterialConnectionPoint;
  12781. /**
  12782. * Gets the r output component
  12783. */
  12784. get r(): NodeMaterialConnectionPoint;
  12785. /**
  12786. * Gets the g output component
  12787. */
  12788. get g(): NodeMaterialConnectionPoint;
  12789. /**
  12790. * Gets the b output component
  12791. */
  12792. get b(): NodeMaterialConnectionPoint;
  12793. /**
  12794. * Gets the a output component
  12795. */
  12796. get a(): NodeMaterialConnectionPoint;
  12797. get target(): NodeMaterialBlockTargets;
  12798. autoConfigure(material: NodeMaterial): void;
  12799. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12801. isReady(): boolean;
  12802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12803. private get _isMixed();
  12804. private _injectVertexCode;
  12805. private _writeTextureRead;
  12806. private _writeOutput;
  12807. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12808. protected _dumpPropertiesCode(): string;
  12809. serialize(): any;
  12810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12811. }
  12812. }
  12813. declare module BABYLON {
  12814. /** @hidden */
  12815. export var reflectionFunction: {
  12816. name: string;
  12817. shader: string;
  12818. };
  12819. }
  12820. declare module BABYLON {
  12821. /**
  12822. * Base block used to read a reflection texture from a sampler
  12823. */
  12824. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12825. /** @hidden */
  12826. _define3DName: string;
  12827. /** @hidden */
  12828. _defineCubicName: string;
  12829. /** @hidden */
  12830. _defineExplicitName: string;
  12831. /** @hidden */
  12832. _defineProjectionName: string;
  12833. /** @hidden */
  12834. _defineLocalCubicName: string;
  12835. /** @hidden */
  12836. _defineSphericalName: string;
  12837. /** @hidden */
  12838. _definePlanarName: string;
  12839. /** @hidden */
  12840. _defineEquirectangularName: string;
  12841. /** @hidden */
  12842. _defineMirroredEquirectangularFixedName: string;
  12843. /** @hidden */
  12844. _defineEquirectangularFixedName: string;
  12845. /** @hidden */
  12846. _defineSkyboxName: string;
  12847. /** @hidden */
  12848. _defineOppositeZ: string;
  12849. /** @hidden */
  12850. _cubeSamplerName: string;
  12851. /** @hidden */
  12852. _2DSamplerName: string;
  12853. protected _positionUVWName: string;
  12854. protected _directionWName: string;
  12855. protected _reflectionVectorName: string;
  12856. /** @hidden */
  12857. _reflectionCoordsName: string;
  12858. /** @hidden */
  12859. _reflectionMatrixName: string;
  12860. protected _reflectionColorName: string;
  12861. /**
  12862. * Gets or sets the texture associated with the node
  12863. */
  12864. texture: Nullable<BaseTexture>;
  12865. /**
  12866. * Create a new ReflectionTextureBaseBlock
  12867. * @param name defines the block name
  12868. */
  12869. constructor(name: string);
  12870. /**
  12871. * Gets the current class name
  12872. * @returns the class name
  12873. */
  12874. getClassName(): string;
  12875. /**
  12876. * Gets the world position input component
  12877. */
  12878. abstract get position(): NodeMaterialConnectionPoint;
  12879. /**
  12880. * Gets the world position input component
  12881. */
  12882. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12883. /**
  12884. * Gets the world normal input component
  12885. */
  12886. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12887. /**
  12888. * Gets the world input component
  12889. */
  12890. abstract get world(): NodeMaterialConnectionPoint;
  12891. /**
  12892. * Gets the camera (or eye) position component
  12893. */
  12894. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12895. /**
  12896. * Gets the view input component
  12897. */
  12898. abstract get view(): NodeMaterialConnectionPoint;
  12899. protected _getTexture(): Nullable<BaseTexture>;
  12900. autoConfigure(material: NodeMaterial): void;
  12901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12902. isReady(): boolean;
  12903. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12904. /**
  12905. * Gets the code to inject in the vertex shader
  12906. * @param state current state of the node material building
  12907. * @returns the shader code
  12908. */
  12909. handleVertexSide(state: NodeMaterialBuildState): string;
  12910. /**
  12911. * Handles the inits for the fragment code path
  12912. * @param state node material build state
  12913. */
  12914. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12915. /**
  12916. * Generates the reflection coords code for the fragment code path
  12917. * @param worldNormalVarName name of the world normal variable
  12918. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12919. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12920. * @returns the shader code
  12921. */
  12922. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12923. /**
  12924. * Generates the reflection color code for the fragment code path
  12925. * @param lodVarName name of the lod variable
  12926. * @param swizzleLookupTexture swizzle to use for the final color variable
  12927. * @returns the shader code
  12928. */
  12929. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12930. /**
  12931. * Generates the code corresponding to the connected output points
  12932. * @param state node material build state
  12933. * @param varName name of the variable to output
  12934. * @returns the shader code
  12935. */
  12936. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12937. protected _buildBlock(state: NodeMaterialBuildState): this;
  12938. protected _dumpPropertiesCode(): string;
  12939. serialize(): any;
  12940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12941. }
  12942. }
  12943. declare module BABYLON {
  12944. /**
  12945. * Defines a connection point to be used for points with a custom object type
  12946. */
  12947. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12948. private _blockType;
  12949. private _blockName;
  12950. private _nameForCheking?;
  12951. /**
  12952. * Creates a new connection point
  12953. * @param name defines the connection point name
  12954. * @param ownerBlock defines the block hosting this connection point
  12955. * @param direction defines the direction of the connection point
  12956. */
  12957. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12958. /**
  12959. * Gets a number indicating if the current point can be connected to another point
  12960. * @param connectionPoint defines the other connection point
  12961. * @returns a number defining the compatibility state
  12962. */
  12963. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12964. /**
  12965. * Creates a block suitable to be used as an input for this input point.
  12966. * If null is returned, a block based on the point type will be created.
  12967. * @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
  12968. */
  12969. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12970. }
  12971. }
  12972. declare module BABYLON {
  12973. /**
  12974. * Enum defining the type of properties that can be edited in the property pages in the NME
  12975. */
  12976. export enum PropertyTypeForEdition {
  12977. /** property is a boolean */
  12978. Boolean = 0,
  12979. /** property is a float */
  12980. Float = 1,
  12981. /** property is a Vector2 */
  12982. Vector2 = 2,
  12983. /** property is a list of values */
  12984. List = 3
  12985. }
  12986. /**
  12987. * Interface that defines an option in a variable of type list
  12988. */
  12989. export interface IEditablePropertyListOption {
  12990. /** label of the option */
  12991. "label": string;
  12992. /** value of the option */
  12993. "value": number;
  12994. }
  12995. /**
  12996. * Interface that defines the options available for an editable property
  12997. */
  12998. export interface IEditablePropertyOption {
  12999. /** min value */
  13000. "min"?: number;
  13001. /** max value */
  13002. "max"?: number;
  13003. /** notifiers: indicates which actions to take when the property is changed */
  13004. "notifiers"?: {
  13005. /** the material should be rebuilt */
  13006. "rebuild"?: boolean;
  13007. /** the preview should be updated */
  13008. "update"?: boolean;
  13009. };
  13010. /** list of the options for a variable of type list */
  13011. "options"?: IEditablePropertyListOption[];
  13012. }
  13013. /**
  13014. * Interface that describes an editable property
  13015. */
  13016. export interface IPropertyDescriptionForEdition {
  13017. /** name of the property */
  13018. "propertyName": string;
  13019. /** display name of the property */
  13020. "displayName": string;
  13021. /** type of the property */
  13022. "type": PropertyTypeForEdition;
  13023. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13024. "groupName": string;
  13025. /** options for the property */
  13026. "options": IEditablePropertyOption;
  13027. }
  13028. /**
  13029. * Decorator that flags a property in a node material block as being editable
  13030. */
  13031. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13032. }
  13033. declare module BABYLON {
  13034. /**
  13035. * Block used to implement the refraction part of the sub surface module of the PBR material
  13036. */
  13037. export class RefractionBlock extends NodeMaterialBlock {
  13038. /** @hidden */
  13039. _define3DName: string;
  13040. /** @hidden */
  13041. _refractionMatrixName: string;
  13042. /** @hidden */
  13043. _defineLODRefractionAlpha: string;
  13044. /** @hidden */
  13045. _defineLinearSpecularRefraction: string;
  13046. /** @hidden */
  13047. _defineOppositeZ: string;
  13048. /** @hidden */
  13049. _cubeSamplerName: string;
  13050. /** @hidden */
  13051. _2DSamplerName: string;
  13052. /** @hidden */
  13053. _vRefractionMicrosurfaceInfosName: string;
  13054. /** @hidden */
  13055. _vRefractionInfosName: string;
  13056. /** @hidden */
  13057. _vRefractionFilteringInfoName: string;
  13058. private _scene;
  13059. /**
  13060. * The properties below are set by the main PBR block prior to calling methods of this class.
  13061. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13062. * It's less burden on the user side in the editor part.
  13063. */
  13064. /** @hidden */
  13065. viewConnectionPoint: NodeMaterialConnectionPoint;
  13066. /** @hidden */
  13067. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13068. /**
  13069. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13070. * Materials half opaque for instance using refraction could benefit from this control.
  13071. */
  13072. linkRefractionWithTransparency: boolean;
  13073. /**
  13074. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13075. */
  13076. invertRefractionY: boolean;
  13077. /**
  13078. * Gets or sets the texture associated with the node
  13079. */
  13080. texture: Nullable<BaseTexture>;
  13081. /**
  13082. * Create a new RefractionBlock
  13083. * @param name defines the block name
  13084. */
  13085. constructor(name: string);
  13086. /**
  13087. * Gets the current class name
  13088. * @returns the class name
  13089. */
  13090. getClassName(): string;
  13091. /**
  13092. * Gets the intensity input component
  13093. */
  13094. get intensity(): NodeMaterialConnectionPoint;
  13095. /**
  13096. * Gets the tint at distance input component
  13097. */
  13098. get tintAtDistance(): NodeMaterialConnectionPoint;
  13099. /**
  13100. * Gets the view input component
  13101. */
  13102. get view(): NodeMaterialConnectionPoint;
  13103. /**
  13104. * Gets the refraction object output component
  13105. */
  13106. get refraction(): NodeMaterialConnectionPoint;
  13107. /**
  13108. * Returns true if the block has a texture
  13109. */
  13110. get hasTexture(): boolean;
  13111. protected _getTexture(): Nullable<BaseTexture>;
  13112. autoConfigure(material: NodeMaterial): void;
  13113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13114. isReady(): boolean;
  13115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13116. /**
  13117. * Gets the main code of the block (fragment side)
  13118. * @param state current state of the node material building
  13119. * @returns the shader code
  13120. */
  13121. getCode(state: NodeMaterialBuildState): string;
  13122. protected _buildBlock(state: NodeMaterialBuildState): this;
  13123. protected _dumpPropertiesCode(): string;
  13124. serialize(): any;
  13125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13126. }
  13127. }
  13128. declare module BABYLON {
  13129. /**
  13130. * Base block used as input for post process
  13131. */
  13132. export class CurrentScreenBlock extends NodeMaterialBlock {
  13133. private _samplerName;
  13134. private _linearDefineName;
  13135. private _gammaDefineName;
  13136. private _mainUVName;
  13137. private _tempTextureRead;
  13138. /**
  13139. * Gets or sets the texture associated with the node
  13140. */
  13141. texture: Nullable<BaseTexture>;
  13142. /**
  13143. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13144. */
  13145. convertToGammaSpace: boolean;
  13146. /**
  13147. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13148. */
  13149. convertToLinearSpace: boolean;
  13150. /**
  13151. * Create a new CurrentScreenBlock
  13152. * @param name defines the block name
  13153. */
  13154. constructor(name: string);
  13155. /**
  13156. * Gets the current class name
  13157. * @returns the class name
  13158. */
  13159. getClassName(): string;
  13160. /**
  13161. * Gets the uv input component
  13162. */
  13163. get uv(): NodeMaterialConnectionPoint;
  13164. /**
  13165. * Gets the rgba output component
  13166. */
  13167. get rgba(): NodeMaterialConnectionPoint;
  13168. /**
  13169. * Gets the rgb output component
  13170. */
  13171. get rgb(): NodeMaterialConnectionPoint;
  13172. /**
  13173. * Gets the r output component
  13174. */
  13175. get r(): NodeMaterialConnectionPoint;
  13176. /**
  13177. * Gets the g output component
  13178. */
  13179. get g(): NodeMaterialConnectionPoint;
  13180. /**
  13181. * Gets the b output component
  13182. */
  13183. get b(): NodeMaterialConnectionPoint;
  13184. /**
  13185. * Gets the a output component
  13186. */
  13187. get a(): NodeMaterialConnectionPoint;
  13188. /**
  13189. * Initialize the block and prepare the context for build
  13190. * @param state defines the state that will be used for the build
  13191. */
  13192. initialize(state: NodeMaterialBuildState): void;
  13193. get target(): NodeMaterialBlockTargets;
  13194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13195. isReady(): boolean;
  13196. private _injectVertexCode;
  13197. private _writeTextureRead;
  13198. private _writeOutput;
  13199. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13200. serialize(): any;
  13201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13202. }
  13203. }
  13204. declare module BABYLON {
  13205. /**
  13206. * Base block used for the particle texture
  13207. */
  13208. export class ParticleTextureBlock extends NodeMaterialBlock {
  13209. private _samplerName;
  13210. private _linearDefineName;
  13211. private _gammaDefineName;
  13212. private _tempTextureRead;
  13213. /**
  13214. * Gets or sets the texture associated with the node
  13215. */
  13216. texture: Nullable<BaseTexture>;
  13217. /**
  13218. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13219. */
  13220. convertToGammaSpace: boolean;
  13221. /**
  13222. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13223. */
  13224. convertToLinearSpace: boolean;
  13225. /**
  13226. * Create a new ParticleTextureBlock
  13227. * @param name defines the block name
  13228. */
  13229. constructor(name: string);
  13230. /**
  13231. * Gets the current class name
  13232. * @returns the class name
  13233. */
  13234. getClassName(): string;
  13235. /**
  13236. * Gets the uv input component
  13237. */
  13238. get uv(): NodeMaterialConnectionPoint;
  13239. /**
  13240. * Gets the rgba output component
  13241. */
  13242. get rgba(): NodeMaterialConnectionPoint;
  13243. /**
  13244. * Gets the rgb output component
  13245. */
  13246. get rgb(): NodeMaterialConnectionPoint;
  13247. /**
  13248. * Gets the r output component
  13249. */
  13250. get r(): NodeMaterialConnectionPoint;
  13251. /**
  13252. * Gets the g output component
  13253. */
  13254. get g(): NodeMaterialConnectionPoint;
  13255. /**
  13256. * Gets the b output component
  13257. */
  13258. get b(): NodeMaterialConnectionPoint;
  13259. /**
  13260. * Gets the a output component
  13261. */
  13262. get a(): NodeMaterialConnectionPoint;
  13263. /**
  13264. * Initialize the block and prepare the context for build
  13265. * @param state defines the state that will be used for the build
  13266. */
  13267. initialize(state: NodeMaterialBuildState): void;
  13268. autoConfigure(material: NodeMaterial): void;
  13269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13270. isReady(): boolean;
  13271. private _writeOutput;
  13272. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13273. serialize(): any;
  13274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13275. }
  13276. }
  13277. declare module BABYLON {
  13278. /**
  13279. * Class used to store shared data between 2 NodeMaterialBuildState
  13280. */
  13281. export class NodeMaterialBuildStateSharedData {
  13282. /**
  13283. * Gets the list of emitted varyings
  13284. */
  13285. temps: string[];
  13286. /**
  13287. * Gets the list of emitted varyings
  13288. */
  13289. varyings: string[];
  13290. /**
  13291. * Gets the varying declaration string
  13292. */
  13293. varyingDeclaration: string;
  13294. /**
  13295. * Input blocks
  13296. */
  13297. inputBlocks: InputBlock[];
  13298. /**
  13299. * Input blocks
  13300. */
  13301. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13302. /**
  13303. * Bindable blocks (Blocks that need to set data to the effect)
  13304. */
  13305. bindableBlocks: NodeMaterialBlock[];
  13306. /**
  13307. * List of blocks that can provide a compilation fallback
  13308. */
  13309. blocksWithFallbacks: NodeMaterialBlock[];
  13310. /**
  13311. * List of blocks that can provide a define update
  13312. */
  13313. blocksWithDefines: NodeMaterialBlock[];
  13314. /**
  13315. * List of blocks that can provide a repeatable content
  13316. */
  13317. repeatableContentBlocks: NodeMaterialBlock[];
  13318. /**
  13319. * List of blocks that can provide a dynamic list of uniforms
  13320. */
  13321. dynamicUniformBlocks: NodeMaterialBlock[];
  13322. /**
  13323. * List of blocks that can block the isReady function for the material
  13324. */
  13325. blockingBlocks: NodeMaterialBlock[];
  13326. /**
  13327. * Gets the list of animated inputs
  13328. */
  13329. animatedInputs: InputBlock[];
  13330. /**
  13331. * Build Id used to avoid multiple recompilations
  13332. */
  13333. buildId: number;
  13334. /** List of emitted variables */
  13335. variableNames: {
  13336. [key: string]: number;
  13337. };
  13338. /** List of emitted defines */
  13339. defineNames: {
  13340. [key: string]: number;
  13341. };
  13342. /** Should emit comments? */
  13343. emitComments: boolean;
  13344. /** Emit build activity */
  13345. verbose: boolean;
  13346. /** Gets or sets the hosting scene */
  13347. scene: Scene;
  13348. /**
  13349. * Gets the compilation hints emitted at compilation time
  13350. */
  13351. hints: {
  13352. needWorldViewMatrix: boolean;
  13353. needWorldViewProjectionMatrix: boolean;
  13354. needAlphaBlending: boolean;
  13355. needAlphaTesting: boolean;
  13356. };
  13357. /**
  13358. * List of compilation checks
  13359. */
  13360. checks: {
  13361. emitVertex: boolean;
  13362. emitFragment: boolean;
  13363. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13364. };
  13365. /**
  13366. * Is vertex program allowed to be empty?
  13367. */
  13368. allowEmptyVertexProgram: boolean;
  13369. /** Creates a new shared data */
  13370. constructor();
  13371. /**
  13372. * Emits console errors and exceptions if there is a failing check
  13373. */
  13374. emitErrors(): void;
  13375. }
  13376. }
  13377. declare module BABYLON {
  13378. /**
  13379. * Class used to store node based material build state
  13380. */
  13381. export class NodeMaterialBuildState {
  13382. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13383. supportUniformBuffers: boolean;
  13384. /**
  13385. * Gets the list of emitted attributes
  13386. */
  13387. attributes: string[];
  13388. /**
  13389. * Gets the list of emitted uniforms
  13390. */
  13391. uniforms: string[];
  13392. /**
  13393. * Gets the list of emitted constants
  13394. */
  13395. constants: string[];
  13396. /**
  13397. * Gets the list of emitted samplers
  13398. */
  13399. samplers: string[];
  13400. /**
  13401. * Gets the list of emitted functions
  13402. */
  13403. functions: {
  13404. [key: string]: string;
  13405. };
  13406. /**
  13407. * Gets the list of emitted extensions
  13408. */
  13409. extensions: {
  13410. [key: string]: string;
  13411. };
  13412. /**
  13413. * Gets the target of the compilation state
  13414. */
  13415. target: NodeMaterialBlockTargets;
  13416. /**
  13417. * Gets the list of emitted counters
  13418. */
  13419. counters: {
  13420. [key: string]: number;
  13421. };
  13422. /**
  13423. * Shared data between multiple NodeMaterialBuildState instances
  13424. */
  13425. sharedData: NodeMaterialBuildStateSharedData;
  13426. /** @hidden */
  13427. _vertexState: NodeMaterialBuildState;
  13428. /** @hidden */
  13429. _attributeDeclaration: string;
  13430. /** @hidden */
  13431. _uniformDeclaration: string;
  13432. /** @hidden */
  13433. _constantDeclaration: string;
  13434. /** @hidden */
  13435. _samplerDeclaration: string;
  13436. /** @hidden */
  13437. _varyingTransfer: string;
  13438. /** @hidden */
  13439. _injectAtEnd: string;
  13440. private _repeatableContentAnchorIndex;
  13441. /** @hidden */
  13442. _builtCompilationString: string;
  13443. /**
  13444. * Gets the emitted compilation strings
  13445. */
  13446. compilationString: string;
  13447. /**
  13448. * Finalize the compilation strings
  13449. * @param state defines the current compilation state
  13450. */
  13451. finalize(state: NodeMaterialBuildState): void;
  13452. /** @hidden */
  13453. get _repeatableContentAnchor(): string;
  13454. /** @hidden */
  13455. _getFreeVariableName(prefix: string): string;
  13456. /** @hidden */
  13457. _getFreeDefineName(prefix: string): string;
  13458. /** @hidden */
  13459. _excludeVariableName(name: string): void;
  13460. /** @hidden */
  13461. _emit2DSampler(name: string): void;
  13462. /** @hidden */
  13463. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13464. /** @hidden */
  13465. _emitExtension(name: string, extension: string, define?: string): void;
  13466. /** @hidden */
  13467. _emitFunction(name: string, code: string, comments: string): void;
  13468. /** @hidden */
  13469. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13470. replaceStrings?: {
  13471. search: RegExp;
  13472. replace: string;
  13473. }[];
  13474. repeatKey?: string;
  13475. }): string;
  13476. /** @hidden */
  13477. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13478. repeatKey?: string;
  13479. removeAttributes?: boolean;
  13480. removeUniforms?: boolean;
  13481. removeVaryings?: boolean;
  13482. removeIfDef?: boolean;
  13483. replaceStrings?: {
  13484. search: RegExp;
  13485. replace: string;
  13486. }[];
  13487. }, storeKey?: string): void;
  13488. /** @hidden */
  13489. _registerTempVariable(name: string): boolean;
  13490. /** @hidden */
  13491. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13492. /** @hidden */
  13493. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13494. /** @hidden */
  13495. _emitFloat(value: number): string;
  13496. }
  13497. }
  13498. declare module BABYLON {
  13499. /**
  13500. * Helper class used to generate session unique ID
  13501. */
  13502. export class UniqueIdGenerator {
  13503. private static _UniqueIdCounter;
  13504. /**
  13505. * Gets an unique (relatively to the current scene) Id
  13506. */
  13507. static get UniqueId(): number;
  13508. }
  13509. }
  13510. declare module BABYLON {
  13511. /**
  13512. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13513. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13514. */
  13515. export class EffectFallbacks implements IEffectFallbacks {
  13516. private _defines;
  13517. private _currentRank;
  13518. private _maxRank;
  13519. private _mesh;
  13520. /**
  13521. * Removes the fallback from the bound mesh.
  13522. */
  13523. unBindMesh(): void;
  13524. /**
  13525. * Adds a fallback on the specified property.
  13526. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13527. * @param define The name of the define in the shader
  13528. */
  13529. addFallback(rank: number, define: string): void;
  13530. /**
  13531. * Sets the mesh to use CPU skinning when needing to fallback.
  13532. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13533. * @param mesh The mesh to use the fallbacks.
  13534. */
  13535. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13536. /**
  13537. * Checks to see if more fallbacks are still availible.
  13538. */
  13539. get hasMoreFallbacks(): boolean;
  13540. /**
  13541. * Removes the defines that should be removed when falling back.
  13542. * @param currentDefines defines the current define statements for the shader.
  13543. * @param effect defines the current effect we try to compile
  13544. * @returns The resulting defines with defines of the current rank removed.
  13545. */
  13546. reduce(currentDefines: string, effect: Effect): string;
  13547. }
  13548. }
  13549. declare module BABYLON {
  13550. /**
  13551. * Defines a block that can be used inside a node based material
  13552. */
  13553. export class NodeMaterialBlock {
  13554. private _buildId;
  13555. private _buildTarget;
  13556. private _target;
  13557. private _isFinalMerger;
  13558. private _isInput;
  13559. private _name;
  13560. protected _isUnique: boolean;
  13561. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13562. inputsAreExclusive: boolean;
  13563. /** @hidden */
  13564. _codeVariableName: string;
  13565. /** @hidden */
  13566. _inputs: NodeMaterialConnectionPoint[];
  13567. /** @hidden */
  13568. _outputs: NodeMaterialConnectionPoint[];
  13569. /** @hidden */
  13570. _preparationId: number;
  13571. /**
  13572. * Gets the name of the block
  13573. */
  13574. get name(): string;
  13575. /**
  13576. * Sets the name of the block. Will check if the name is valid.
  13577. */
  13578. set name(newName: string);
  13579. /**
  13580. * Gets or sets the unique id of the node
  13581. */
  13582. uniqueId: number;
  13583. /**
  13584. * Gets or sets the comments associated with this block
  13585. */
  13586. comments: string;
  13587. /**
  13588. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13589. */
  13590. get isUnique(): boolean;
  13591. /**
  13592. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13593. */
  13594. get isFinalMerger(): boolean;
  13595. /**
  13596. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13597. */
  13598. get isInput(): boolean;
  13599. /**
  13600. * Gets or sets the build Id
  13601. */
  13602. get buildId(): number;
  13603. set buildId(value: number);
  13604. /**
  13605. * Gets or sets the target of the block
  13606. */
  13607. get target(): NodeMaterialBlockTargets;
  13608. set target(value: NodeMaterialBlockTargets);
  13609. /**
  13610. * Gets the list of input points
  13611. */
  13612. get inputs(): NodeMaterialConnectionPoint[];
  13613. /** Gets the list of output points */
  13614. get outputs(): NodeMaterialConnectionPoint[];
  13615. /**
  13616. * Find an input by its name
  13617. * @param name defines the name of the input to look for
  13618. * @returns the input or null if not found
  13619. */
  13620. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13621. /**
  13622. * Find an output by its name
  13623. * @param name defines the name of the outputto look for
  13624. * @returns the output or null if not found
  13625. */
  13626. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13627. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13628. visibleInInspector: boolean;
  13629. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13630. visibleOnFrame: boolean;
  13631. /**
  13632. * Creates a new NodeMaterialBlock
  13633. * @param name defines the block name
  13634. * @param target defines the target of that block (Vertex by default)
  13635. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13636. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13637. */
  13638. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13639. /**
  13640. * Initialize the block and prepare the context for build
  13641. * @param state defines the state that will be used for the build
  13642. */
  13643. initialize(state: NodeMaterialBuildState): void;
  13644. /**
  13645. * Bind data to effect. Will only be called for blocks with isBindable === true
  13646. * @param effect defines the effect to bind data to
  13647. * @param nodeMaterial defines the hosting NodeMaterial
  13648. * @param mesh defines the mesh that will be rendered
  13649. * @param subMesh defines the submesh that will be rendered
  13650. */
  13651. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13652. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13653. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13654. protected _writeFloat(value: number): string;
  13655. /**
  13656. * Gets the current class name e.g. "NodeMaterialBlock"
  13657. * @returns the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Register a new input. Must be called inside a block constructor
  13662. * @param name defines the connection point name
  13663. * @param type defines the connection point type
  13664. * @param isOptional defines a boolean indicating that this input can be omitted
  13665. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13666. * @param point an already created connection point. If not provided, create a new one
  13667. * @returns the current block
  13668. */
  13669. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13670. /**
  13671. * Register a new output. Must be called inside a block constructor
  13672. * @param name defines the connection point name
  13673. * @param type defines the connection point type
  13674. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13675. * @param point an already created connection point. If not provided, create a new one
  13676. * @returns the current block
  13677. */
  13678. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13679. /**
  13680. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13681. * @param forOutput defines an optional connection point to check compatibility with
  13682. * @returns the first available input or null
  13683. */
  13684. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13685. /**
  13686. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13687. * @param forBlock defines an optional block to check compatibility with
  13688. * @returns the first available input or null
  13689. */
  13690. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13691. /**
  13692. * Gets the sibling of the given output
  13693. * @param current defines the current output
  13694. * @returns the next output in the list or null
  13695. */
  13696. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13697. /**
  13698. * Connect current block with another block
  13699. * @param other defines the block to connect with
  13700. * @param options define the various options to help pick the right connections
  13701. * @returns the current block
  13702. */
  13703. connectTo(other: NodeMaterialBlock, options?: {
  13704. input?: string;
  13705. output?: string;
  13706. outputSwizzle?: string;
  13707. }): this | undefined;
  13708. protected _buildBlock(state: NodeMaterialBuildState): void;
  13709. /**
  13710. * Add uniforms, samplers and uniform buffers at compilation time
  13711. * @param state defines the state to update
  13712. * @param nodeMaterial defines the node material requesting the update
  13713. * @param defines defines the material defines to update
  13714. * @param uniformBuffers defines the list of uniform buffer names
  13715. */
  13716. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13717. /**
  13718. * Add potential fallbacks if shader compilation fails
  13719. * @param mesh defines the mesh to be rendered
  13720. * @param fallbacks defines the current prioritized list of fallbacks
  13721. */
  13722. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13723. /**
  13724. * Initialize defines for shader compilation
  13725. * @param mesh defines the mesh to be rendered
  13726. * @param nodeMaterial defines the node material requesting the update
  13727. * @param defines defines the material defines to update
  13728. * @param useInstances specifies that instances should be used
  13729. */
  13730. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13731. /**
  13732. * Update defines for shader compilation
  13733. * @param mesh defines the mesh to be rendered
  13734. * @param nodeMaterial defines the node material requesting the update
  13735. * @param defines defines the material defines to update
  13736. * @param useInstances specifies that instances should be used
  13737. * @param subMesh defines which submesh to render
  13738. */
  13739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13740. /**
  13741. * Lets the block try to connect some inputs automatically
  13742. * @param material defines the hosting NodeMaterial
  13743. */
  13744. autoConfigure(material: NodeMaterial): void;
  13745. /**
  13746. * Function called when a block is declared as repeatable content generator
  13747. * @param vertexShaderState defines the current compilation state for the vertex shader
  13748. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13749. * @param mesh defines the mesh to be rendered
  13750. * @param defines defines the material defines to update
  13751. */
  13752. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13753. /**
  13754. * Checks if the block is ready
  13755. * @param mesh defines the mesh to be rendered
  13756. * @param nodeMaterial defines the node material requesting the update
  13757. * @param defines defines the material defines to update
  13758. * @param useInstances specifies that instances should be used
  13759. * @returns true if the block is ready
  13760. */
  13761. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13762. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13763. private _processBuild;
  13764. /**
  13765. * Validates the new name for the block node.
  13766. * @param newName the new name to be given to the node.
  13767. * @returns false if the name is a reserve word, else true.
  13768. */
  13769. validateBlockName(newName: string): boolean;
  13770. /**
  13771. * Compile the current node and generate the shader code
  13772. * @param state defines the current compilation state (uniforms, samplers, current string)
  13773. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13774. * @returns true if already built
  13775. */
  13776. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13777. protected _inputRename(name: string): string;
  13778. protected _outputRename(name: string): string;
  13779. protected _dumpPropertiesCode(): string;
  13780. /** @hidden */
  13781. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13782. /** @hidden */
  13783. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13784. /**
  13785. * Clone the current block to a new identical block
  13786. * @param scene defines the hosting scene
  13787. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13788. * @returns a copy of the current block
  13789. */
  13790. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13791. /**
  13792. * Serializes this block in a JSON representation
  13793. * @returns the serialized block object
  13794. */
  13795. serialize(): any;
  13796. /** @hidden */
  13797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13798. private _deserializePortDisplayNamesAndExposedOnFrame;
  13799. /**
  13800. * Release resources
  13801. */
  13802. dispose(): void;
  13803. }
  13804. }
  13805. declare module BABYLON {
  13806. /**
  13807. * Base class of materials working in push mode in babylon JS
  13808. * @hidden
  13809. */
  13810. export class PushMaterial extends Material {
  13811. protected _activeEffect: Effect;
  13812. protected _normalMatrix: Matrix;
  13813. constructor(name: string, scene: Scene);
  13814. getEffect(): Effect;
  13815. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13816. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13817. /**
  13818. * Binds the given world matrix to the active effect
  13819. *
  13820. * @param world the matrix to bind
  13821. */
  13822. bindOnlyWorldMatrix(world: Matrix): void;
  13823. /**
  13824. * Binds the given normal matrix to the active effect
  13825. *
  13826. * @param normalMatrix the matrix to bind
  13827. */
  13828. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13829. bind(world: Matrix, mesh?: Mesh): void;
  13830. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13831. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13832. }
  13833. }
  13834. declare module BABYLON {
  13835. /**
  13836. * Root class for all node material optimizers
  13837. */
  13838. export class NodeMaterialOptimizer {
  13839. /**
  13840. * Function used to optimize a NodeMaterial graph
  13841. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13842. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13843. */
  13844. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13845. }
  13846. }
  13847. declare module BABYLON {
  13848. /**
  13849. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13850. */
  13851. export class TransformBlock extends NodeMaterialBlock {
  13852. /**
  13853. * Defines the value to use to complement W value to transform it to a Vector4
  13854. */
  13855. complementW: number;
  13856. /**
  13857. * Defines the value to use to complement z value to transform it to a Vector4
  13858. */
  13859. complementZ: number;
  13860. /**
  13861. * Creates a new TransformBlock
  13862. * @param name defines the block name
  13863. */
  13864. constructor(name: string);
  13865. /**
  13866. * Gets the current class name
  13867. * @returns the class name
  13868. */
  13869. getClassName(): string;
  13870. /**
  13871. * Gets the vector input
  13872. */
  13873. get vector(): NodeMaterialConnectionPoint;
  13874. /**
  13875. * Gets the output component
  13876. */
  13877. get output(): NodeMaterialConnectionPoint;
  13878. /**
  13879. * Gets the xyz output component
  13880. */
  13881. get xyz(): NodeMaterialConnectionPoint;
  13882. /**
  13883. * Gets the matrix transform input
  13884. */
  13885. get transform(): NodeMaterialConnectionPoint;
  13886. protected _buildBlock(state: NodeMaterialBuildState): this;
  13887. /**
  13888. * Update defines for shader compilation
  13889. * @param mesh defines the mesh to be rendered
  13890. * @param nodeMaterial defines the node material requesting the update
  13891. * @param defines defines the material defines to update
  13892. * @param useInstances specifies that instances should be used
  13893. * @param subMesh defines which submesh to render
  13894. */
  13895. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13896. serialize(): any;
  13897. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13898. protected _dumpPropertiesCode(): string;
  13899. }
  13900. }
  13901. declare module BABYLON {
  13902. /**
  13903. * Block used to output the vertex position
  13904. */
  13905. export class VertexOutputBlock extends NodeMaterialBlock {
  13906. /**
  13907. * Creates a new VertexOutputBlock
  13908. * @param name defines the block name
  13909. */
  13910. constructor(name: string);
  13911. /**
  13912. * Gets the current class name
  13913. * @returns the class name
  13914. */
  13915. getClassName(): string;
  13916. /**
  13917. * Gets the vector input component
  13918. */
  13919. get vector(): NodeMaterialConnectionPoint;
  13920. protected _buildBlock(state: NodeMaterialBuildState): this;
  13921. }
  13922. }
  13923. declare module BABYLON {
  13924. /**
  13925. * Block used to output the final color
  13926. */
  13927. export class FragmentOutputBlock extends NodeMaterialBlock {
  13928. /**
  13929. * Create a new FragmentOutputBlock
  13930. * @param name defines the block name
  13931. */
  13932. constructor(name: string);
  13933. /**
  13934. * Gets the current class name
  13935. * @returns the class name
  13936. */
  13937. getClassName(): string;
  13938. /**
  13939. * Gets the rgba input component
  13940. */
  13941. get rgba(): NodeMaterialConnectionPoint;
  13942. /**
  13943. * Gets the rgb input component
  13944. */
  13945. get rgb(): NodeMaterialConnectionPoint;
  13946. /**
  13947. * Gets the a input component
  13948. */
  13949. get a(): NodeMaterialConnectionPoint;
  13950. protected _buildBlock(state: NodeMaterialBuildState): this;
  13951. }
  13952. }
  13953. declare module BABYLON {
  13954. /**
  13955. * Block used for the particle ramp gradient section
  13956. */
  13957. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13958. /**
  13959. * Create a new ParticleRampGradientBlock
  13960. * @param name defines the block name
  13961. */
  13962. constructor(name: string);
  13963. /**
  13964. * Gets the current class name
  13965. * @returns the class name
  13966. */
  13967. getClassName(): string;
  13968. /**
  13969. * Gets the color input component
  13970. */
  13971. get color(): NodeMaterialConnectionPoint;
  13972. /**
  13973. * Gets the rampColor output component
  13974. */
  13975. get rampColor(): NodeMaterialConnectionPoint;
  13976. /**
  13977. * Initialize the block and prepare the context for build
  13978. * @param state defines the state that will be used for the build
  13979. */
  13980. initialize(state: NodeMaterialBuildState): void;
  13981. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13982. }
  13983. }
  13984. declare module BABYLON {
  13985. /**
  13986. * Block used for the particle blend multiply section
  13987. */
  13988. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13989. /**
  13990. * Create a new ParticleBlendMultiplyBlock
  13991. * @param name defines the block name
  13992. */
  13993. constructor(name: string);
  13994. /**
  13995. * Gets the current class name
  13996. * @returns the class name
  13997. */
  13998. getClassName(): string;
  13999. /**
  14000. * Gets the color input component
  14001. */
  14002. get color(): NodeMaterialConnectionPoint;
  14003. /**
  14004. * Gets the alphaTexture input component
  14005. */
  14006. get alphaTexture(): NodeMaterialConnectionPoint;
  14007. /**
  14008. * Gets the alphaColor input component
  14009. */
  14010. get alphaColor(): NodeMaterialConnectionPoint;
  14011. /**
  14012. * Gets the blendColor output component
  14013. */
  14014. get blendColor(): NodeMaterialConnectionPoint;
  14015. /**
  14016. * Initialize the block and prepare the context for build
  14017. * @param state defines the state that will be used for the build
  14018. */
  14019. initialize(state: NodeMaterialBuildState): void;
  14020. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14021. }
  14022. }
  14023. declare module BABYLON {
  14024. /**
  14025. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14026. */
  14027. export class VectorMergerBlock extends NodeMaterialBlock {
  14028. /**
  14029. * Create a new VectorMergerBlock
  14030. * @param name defines the block name
  14031. */
  14032. constructor(name: string);
  14033. /**
  14034. * Gets the current class name
  14035. * @returns the class name
  14036. */
  14037. getClassName(): string;
  14038. /**
  14039. * Gets the xyz component (input)
  14040. */
  14041. get xyzIn(): NodeMaterialConnectionPoint;
  14042. /**
  14043. * Gets the xy component (input)
  14044. */
  14045. get xyIn(): NodeMaterialConnectionPoint;
  14046. /**
  14047. * Gets the x component (input)
  14048. */
  14049. get x(): NodeMaterialConnectionPoint;
  14050. /**
  14051. * Gets the y component (input)
  14052. */
  14053. get y(): NodeMaterialConnectionPoint;
  14054. /**
  14055. * Gets the z component (input)
  14056. */
  14057. get z(): NodeMaterialConnectionPoint;
  14058. /**
  14059. * Gets the w component (input)
  14060. */
  14061. get w(): NodeMaterialConnectionPoint;
  14062. /**
  14063. * Gets the xyzw component (output)
  14064. */
  14065. get xyzw(): NodeMaterialConnectionPoint;
  14066. /**
  14067. * Gets the xyz component (output)
  14068. */
  14069. get xyzOut(): NodeMaterialConnectionPoint;
  14070. /**
  14071. * Gets the xy component (output)
  14072. */
  14073. get xyOut(): NodeMaterialConnectionPoint;
  14074. /**
  14075. * Gets the xy component (output)
  14076. * @deprecated Please use xyOut instead.
  14077. */
  14078. get xy(): NodeMaterialConnectionPoint;
  14079. /**
  14080. * Gets the xyz component (output)
  14081. * @deprecated Please use xyzOut instead.
  14082. */
  14083. get xyz(): NodeMaterialConnectionPoint;
  14084. protected _buildBlock(state: NodeMaterialBuildState): this;
  14085. }
  14086. }
  14087. declare module BABYLON {
  14088. /**
  14089. * Block used to remap a float from a range to a new one
  14090. */
  14091. export class RemapBlock extends NodeMaterialBlock {
  14092. /**
  14093. * Gets or sets the source range
  14094. */
  14095. sourceRange: Vector2;
  14096. /**
  14097. * Gets or sets the target range
  14098. */
  14099. targetRange: Vector2;
  14100. /**
  14101. * Creates a new RemapBlock
  14102. * @param name defines the block name
  14103. */
  14104. constructor(name: string);
  14105. /**
  14106. * Gets the current class name
  14107. * @returns the class name
  14108. */
  14109. getClassName(): string;
  14110. /**
  14111. * Gets the input component
  14112. */
  14113. get input(): NodeMaterialConnectionPoint;
  14114. /**
  14115. * Gets the source min input component
  14116. */
  14117. get sourceMin(): NodeMaterialConnectionPoint;
  14118. /**
  14119. * Gets the source max input component
  14120. */
  14121. get sourceMax(): NodeMaterialConnectionPoint;
  14122. /**
  14123. * Gets the target min input component
  14124. */
  14125. get targetMin(): NodeMaterialConnectionPoint;
  14126. /**
  14127. * Gets the target max input component
  14128. */
  14129. get targetMax(): NodeMaterialConnectionPoint;
  14130. /**
  14131. * Gets the output component
  14132. */
  14133. get output(): NodeMaterialConnectionPoint;
  14134. protected _buildBlock(state: NodeMaterialBuildState): this;
  14135. protected _dumpPropertiesCode(): string;
  14136. serialize(): any;
  14137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14138. }
  14139. }
  14140. declare module BABYLON {
  14141. /**
  14142. * Block used to multiply 2 values
  14143. */
  14144. export class MultiplyBlock extends NodeMaterialBlock {
  14145. /**
  14146. * Creates a new MultiplyBlock
  14147. * @param name defines the block name
  14148. */
  14149. constructor(name: string);
  14150. /**
  14151. * Gets the current class name
  14152. * @returns the class name
  14153. */
  14154. getClassName(): string;
  14155. /**
  14156. * Gets the left operand input component
  14157. */
  14158. get left(): NodeMaterialConnectionPoint;
  14159. /**
  14160. * Gets the right operand input component
  14161. */
  14162. get right(): NodeMaterialConnectionPoint;
  14163. /**
  14164. * Gets the output component
  14165. */
  14166. get output(): NodeMaterialConnectionPoint;
  14167. protected _buildBlock(state: NodeMaterialBuildState): this;
  14168. }
  14169. }
  14170. declare module BABYLON {
  14171. /** Interface used by value gradients (color, factor, ...) */
  14172. export interface IValueGradient {
  14173. /**
  14174. * Gets or sets the gradient value (between 0 and 1)
  14175. */
  14176. gradient: number;
  14177. }
  14178. /** Class used to store color4 gradient */
  14179. export class ColorGradient implements IValueGradient {
  14180. /**
  14181. * Gets or sets the gradient value (between 0 and 1)
  14182. */
  14183. gradient: number;
  14184. /**
  14185. * Gets or sets first associated color
  14186. */
  14187. color1: Color4;
  14188. /**
  14189. * Gets or sets second associated color
  14190. */
  14191. color2?: Color4 | undefined;
  14192. /**
  14193. * Creates a new color4 gradient
  14194. * @param gradient gets or sets the gradient value (between 0 and 1)
  14195. * @param color1 gets or sets first associated color
  14196. * @param color2 gets or sets first second color
  14197. */
  14198. constructor(
  14199. /**
  14200. * Gets or sets the gradient value (between 0 and 1)
  14201. */
  14202. gradient: number,
  14203. /**
  14204. * Gets or sets first associated color
  14205. */
  14206. color1: Color4,
  14207. /**
  14208. * Gets or sets second associated color
  14209. */
  14210. color2?: Color4 | undefined);
  14211. /**
  14212. * Will get a color picked randomly between color1 and color2.
  14213. * If color2 is undefined then color1 will be used
  14214. * @param result defines the target Color4 to store the result in
  14215. */
  14216. getColorToRef(result: Color4): void;
  14217. }
  14218. /** Class used to store color 3 gradient */
  14219. export class Color3Gradient implements IValueGradient {
  14220. /**
  14221. * Gets or sets the gradient value (between 0 and 1)
  14222. */
  14223. gradient: number;
  14224. /**
  14225. * Gets or sets the associated color
  14226. */
  14227. color: Color3;
  14228. /**
  14229. * Creates a new color3 gradient
  14230. * @param gradient gets or sets the gradient value (between 0 and 1)
  14231. * @param color gets or sets associated color
  14232. */
  14233. constructor(
  14234. /**
  14235. * Gets or sets the gradient value (between 0 and 1)
  14236. */
  14237. gradient: number,
  14238. /**
  14239. * Gets or sets the associated color
  14240. */
  14241. color: Color3);
  14242. }
  14243. /** Class used to store factor gradient */
  14244. export class FactorGradient implements IValueGradient {
  14245. /**
  14246. * Gets or sets the gradient value (between 0 and 1)
  14247. */
  14248. gradient: number;
  14249. /**
  14250. * Gets or sets first associated factor
  14251. */
  14252. factor1: number;
  14253. /**
  14254. * Gets or sets second associated factor
  14255. */
  14256. factor2?: number | undefined;
  14257. /**
  14258. * Creates a new factor gradient
  14259. * @param gradient gets or sets the gradient value (between 0 and 1)
  14260. * @param factor1 gets or sets first associated factor
  14261. * @param factor2 gets or sets second associated factor
  14262. */
  14263. constructor(
  14264. /**
  14265. * Gets or sets the gradient value (between 0 and 1)
  14266. */
  14267. gradient: number,
  14268. /**
  14269. * Gets or sets first associated factor
  14270. */
  14271. factor1: number,
  14272. /**
  14273. * Gets or sets second associated factor
  14274. */
  14275. factor2?: number | undefined);
  14276. /**
  14277. * Will get a number picked randomly between factor1 and factor2.
  14278. * If factor2 is undefined then factor1 will be used
  14279. * @returns the picked number
  14280. */
  14281. getFactor(): number;
  14282. }
  14283. /**
  14284. * Helper used to simplify some generic gradient tasks
  14285. */
  14286. export class GradientHelper {
  14287. /**
  14288. * Gets the current gradient from an array of IValueGradient
  14289. * @param ratio defines the current ratio to get
  14290. * @param gradients defines the array of IValueGradient
  14291. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14292. */
  14293. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14294. }
  14295. }
  14296. declare module BABYLON {
  14297. interface ThinEngine {
  14298. /**
  14299. * Creates a raw texture
  14300. * @param data defines the data to store in the texture
  14301. * @param width defines the width of the texture
  14302. * @param height defines the height of the texture
  14303. * @param format defines the format of the data
  14304. * @param generateMipMaps defines if the engine should generate the mip levels
  14305. * @param invertY defines if data must be stored with Y axis inverted
  14306. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14307. * @param compression defines the compression used (null by default)
  14308. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14309. * @returns the raw texture inside an InternalTexture
  14310. */
  14311. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14312. /**
  14313. * Update a raw texture
  14314. * @param texture defines the texture to update
  14315. * @param data defines the data to store in the texture
  14316. * @param format defines the format of the data
  14317. * @param invertY defines if data must be stored with Y axis inverted
  14318. */
  14319. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14320. /**
  14321. * Update a raw texture
  14322. * @param texture defines the texture to update
  14323. * @param data defines the data to store in the texture
  14324. * @param format defines the format of the data
  14325. * @param invertY defines if data must be stored with Y axis inverted
  14326. * @param compression defines the compression used (null by default)
  14327. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14328. */
  14329. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14330. /**
  14331. * Creates a new raw cube texture
  14332. * @param data defines the array of data to use to create each face
  14333. * @param size defines the size of the textures
  14334. * @param format defines the format of the data
  14335. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14336. * @param generateMipMaps defines if the engine should generate the mip levels
  14337. * @param invertY defines if data must be stored with Y axis inverted
  14338. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14339. * @param compression defines the compression used (null by default)
  14340. * @returns the cube texture as an InternalTexture
  14341. */
  14342. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14343. /**
  14344. * Update a raw cube texture
  14345. * @param texture defines the texture to udpdate
  14346. * @param data defines the data to store
  14347. * @param format defines the data format
  14348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14349. * @param invertY defines if data must be stored with Y axis inverted
  14350. */
  14351. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14352. /**
  14353. * Update a raw cube texture
  14354. * @param texture defines the texture to udpdate
  14355. * @param data defines the data to store
  14356. * @param format defines the data format
  14357. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14358. * @param invertY defines if data must be stored with Y axis inverted
  14359. * @param compression defines the compression used (null by default)
  14360. */
  14361. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14362. /**
  14363. * Update a raw cube texture
  14364. * @param texture defines the texture to udpdate
  14365. * @param data defines the data to store
  14366. * @param format defines the data format
  14367. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14368. * @param invertY defines if data must be stored with Y axis inverted
  14369. * @param compression defines the compression used (null by default)
  14370. * @param level defines which level of the texture to update
  14371. */
  14372. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14373. /**
  14374. * Creates a new raw cube texture from a specified url
  14375. * @param url defines the url where the data is located
  14376. * @param scene defines the current scene
  14377. * @param size defines the size of the textures
  14378. * @param format defines the format of the data
  14379. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14380. * @param noMipmap defines if the engine should avoid generating the mip levels
  14381. * @param callback defines a callback used to extract texture data from loaded data
  14382. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14383. * @param onLoad defines a callback called when texture is loaded
  14384. * @param onError defines a callback called if there is an error
  14385. * @returns the cube texture as an InternalTexture
  14386. */
  14387. 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;
  14388. /**
  14389. * Creates a new raw cube texture from a specified url
  14390. * @param url defines the url where the data is located
  14391. * @param scene defines the current scene
  14392. * @param size defines the size of the textures
  14393. * @param format defines the format of the data
  14394. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14395. * @param noMipmap defines if the engine should avoid generating the mip levels
  14396. * @param callback defines a callback used to extract texture data from loaded data
  14397. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14398. * @param onLoad defines a callback called when texture is loaded
  14399. * @param onError defines a callback called if there is an error
  14400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14401. * @param invertY defines if data must be stored with Y axis inverted
  14402. * @returns the cube texture as an InternalTexture
  14403. */
  14404. 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;
  14405. /**
  14406. * Creates a new raw 3D texture
  14407. * @param data defines the data used to create the texture
  14408. * @param width defines the width of the texture
  14409. * @param height defines the height of the texture
  14410. * @param depth defines the depth of the texture
  14411. * @param format defines the format of the texture
  14412. * @param generateMipMaps defines if the engine must generate mip levels
  14413. * @param invertY defines if data must be stored with Y axis inverted
  14414. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14415. * @param compression defines the compressed used (can be null)
  14416. * @param textureType defines the compressed used (can be null)
  14417. * @returns a new raw 3D texture (stored in an InternalTexture)
  14418. */
  14419. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14420. /**
  14421. * Update a raw 3D texture
  14422. * @param texture defines the texture to update
  14423. * @param data defines the data to store
  14424. * @param format defines the data format
  14425. * @param invertY defines if data must be stored with Y axis inverted
  14426. */
  14427. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14428. /**
  14429. * Update a raw 3D texture
  14430. * @param texture defines the texture to update
  14431. * @param data defines the data to store
  14432. * @param format defines the data format
  14433. * @param invertY defines if data must be stored with Y axis inverted
  14434. * @param compression defines the used compression (can be null)
  14435. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14436. */
  14437. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14438. /**
  14439. * Creates a new raw 2D array texture
  14440. * @param data defines the data used to create the texture
  14441. * @param width defines the width of the texture
  14442. * @param height defines the height of the texture
  14443. * @param depth defines the number of layers of the texture
  14444. * @param format defines the format of the texture
  14445. * @param generateMipMaps defines if the engine must generate mip levels
  14446. * @param invertY defines if data must be stored with Y axis inverted
  14447. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14448. * @param compression defines the compressed used (can be null)
  14449. * @param textureType defines the compressed used (can be null)
  14450. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14451. */
  14452. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14453. /**
  14454. * Update a raw 2D array texture
  14455. * @param texture defines the texture to update
  14456. * @param data defines the data to store
  14457. * @param format defines the data format
  14458. * @param invertY defines if data must be stored with Y axis inverted
  14459. */
  14460. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14461. /**
  14462. * Update a raw 2D array texture
  14463. * @param texture defines the texture to update
  14464. * @param data defines the data to store
  14465. * @param format defines the data format
  14466. * @param invertY defines if data must be stored with Y axis inverted
  14467. * @param compression defines the used compression (can be null)
  14468. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14469. */
  14470. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14471. }
  14472. }
  14473. declare module BABYLON {
  14474. /**
  14475. * Raw texture can help creating a texture directly from an array of data.
  14476. * This can be super useful if you either get the data from an uncompressed source or
  14477. * if you wish to create your texture pixel by pixel.
  14478. */
  14479. export class RawTexture extends Texture {
  14480. /**
  14481. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14482. */
  14483. format: number;
  14484. /**
  14485. * Instantiates a new RawTexture.
  14486. * Raw texture can help creating a texture directly from an array of data.
  14487. * This can be super useful if you either get the data from an uncompressed source or
  14488. * if you wish to create your texture pixel by pixel.
  14489. * @param data define the array of data to use to create the texture
  14490. * @param width define the width of the texture
  14491. * @param height define the height of the texture
  14492. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14493. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14494. * @param generateMipMaps define whether mip maps should be generated or not
  14495. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14496. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14497. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14498. */
  14499. constructor(data: ArrayBufferView, width: number, height: number,
  14500. /**
  14501. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14502. */
  14503. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14504. /**
  14505. * Updates the texture underlying data.
  14506. * @param data Define the new data of the texture
  14507. */
  14508. update(data: ArrayBufferView): void;
  14509. /**
  14510. * Creates a luminance texture from some data.
  14511. * @param data Define the texture data
  14512. * @param width Define the width of the texture
  14513. * @param height Define the height of the texture
  14514. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14515. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14516. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14517. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14518. * @returns the luminance texture
  14519. */
  14520. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14521. /**
  14522. * Creates a luminance alpha texture from some data.
  14523. * @param data Define the texture data
  14524. * @param width Define the width of the texture
  14525. * @param height Define the height of the texture
  14526. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14527. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14528. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14529. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14530. * @returns the luminance alpha texture
  14531. */
  14532. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14533. /**
  14534. * Creates an alpha texture from some data.
  14535. * @param data Define the texture data
  14536. * @param width Define the width of the texture
  14537. * @param height Define the height of the texture
  14538. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14539. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14540. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14541. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14542. * @returns the alpha texture
  14543. */
  14544. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14545. /**
  14546. * Creates a RGB texture from some data.
  14547. * @param data Define the texture data
  14548. * @param width Define the width of the texture
  14549. * @param height Define the height of the texture
  14550. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14551. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14552. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14553. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14554. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14555. * @returns the RGB alpha texture
  14556. */
  14557. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14558. /**
  14559. * Creates a RGBA texture from some data.
  14560. * @param data Define the texture data
  14561. * @param width Define the width of the texture
  14562. * @param height Define the height of the texture
  14563. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14567. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14568. * @returns the RGBA texture
  14569. */
  14570. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14571. /**
  14572. * Creates a R texture from some data.
  14573. * @param data Define the texture data
  14574. * @param width Define the width of the texture
  14575. * @param height Define the height of the texture
  14576. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14577. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14578. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14579. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14580. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14581. * @returns the R texture
  14582. */
  14583. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14584. }
  14585. }
  14586. declare module BABYLON {
  14587. interface ThinEngine {
  14588. /**
  14589. * Update a dynamic index buffer
  14590. * @param indexBuffer defines the target index buffer
  14591. * @param indices defines the data to update
  14592. * @param offset defines the offset in the target index buffer where update should start
  14593. */
  14594. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14595. /**
  14596. * Updates a dynamic vertex buffer.
  14597. * @param vertexBuffer the vertex buffer to update
  14598. * @param data the data used to update the vertex buffer
  14599. * @param byteOffset the byte offset of the data
  14600. * @param byteLength the byte length of the data
  14601. */
  14602. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14603. }
  14604. }
  14605. declare module BABYLON {
  14606. interface AbstractScene {
  14607. /**
  14608. * The list of procedural textures added to the scene
  14609. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14610. */
  14611. proceduralTextures: Array<ProceduralTexture>;
  14612. }
  14613. /**
  14614. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14615. * in a given scene.
  14616. */
  14617. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14618. /**
  14619. * The component name helpfull to identify the component in the list of scene components.
  14620. */
  14621. readonly name: string;
  14622. /**
  14623. * The scene the component belongs to.
  14624. */
  14625. scene: Scene;
  14626. /**
  14627. * Creates a new instance of the component for the given scene
  14628. * @param scene Defines the scene to register the component in
  14629. */
  14630. constructor(scene: Scene);
  14631. /**
  14632. * Registers the component in a given scene
  14633. */
  14634. register(): void;
  14635. /**
  14636. * Rebuilds the elements related to this component in case of
  14637. * context lost for instance.
  14638. */
  14639. rebuild(): void;
  14640. /**
  14641. * Disposes the component and the associated ressources.
  14642. */
  14643. dispose(): void;
  14644. private _beforeClear;
  14645. }
  14646. }
  14647. declare module BABYLON {
  14648. interface ThinEngine {
  14649. /**
  14650. * Creates a new render target cube texture
  14651. * @param size defines the size of the texture
  14652. * @param options defines the options used to create the texture
  14653. * @returns a new render target cube texture stored in an InternalTexture
  14654. */
  14655. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14656. }
  14657. }
  14658. declare module BABYLON {
  14659. /** @hidden */
  14660. export var proceduralVertexShader: {
  14661. name: string;
  14662. shader: string;
  14663. };
  14664. }
  14665. declare module BABYLON {
  14666. /**
  14667. * 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.
  14668. * This is the base class of any Procedural texture and contains most of the shareable code.
  14669. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14670. */
  14671. export class ProceduralTexture extends Texture {
  14672. /**
  14673. * Define if the texture is enabled or not (disabled texture will not render)
  14674. */
  14675. isEnabled: boolean;
  14676. /**
  14677. * Define if the texture must be cleared before rendering (default is true)
  14678. */
  14679. autoClear: boolean;
  14680. /**
  14681. * Callback called when the texture is generated
  14682. */
  14683. onGenerated: () => void;
  14684. /**
  14685. * Event raised when the texture is generated
  14686. */
  14687. onGeneratedObservable: Observable<ProceduralTexture>;
  14688. /**
  14689. * Event raised before the texture is generated
  14690. */
  14691. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14692. /**
  14693. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14694. */
  14695. nodeMaterialSource: Nullable<NodeMaterial>;
  14696. /** @hidden */
  14697. _generateMipMaps: boolean;
  14698. /** @hidden **/
  14699. _effect: Effect;
  14700. /** @hidden */
  14701. _textures: {
  14702. [key: string]: Texture;
  14703. };
  14704. /** @hidden */
  14705. protected _fallbackTexture: Nullable<Texture>;
  14706. private _size;
  14707. private _textureType;
  14708. private _currentRefreshId;
  14709. private _frameId;
  14710. private _refreshRate;
  14711. private _vertexBuffers;
  14712. private _indexBuffer;
  14713. private _uniforms;
  14714. private _samplers;
  14715. private _fragment;
  14716. private _floats;
  14717. private _ints;
  14718. private _floatsArrays;
  14719. private _colors3;
  14720. private _colors4;
  14721. private _vectors2;
  14722. private _vectors3;
  14723. private _matrices;
  14724. private _fallbackTextureUsed;
  14725. private _fullEngine;
  14726. private _cachedDefines;
  14727. private _contentUpdateId;
  14728. private _contentData;
  14729. /**
  14730. * Instantiates a new procedural texture.
  14731. * 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.
  14732. * This is the base class of any Procedural texture and contains most of the shareable code.
  14733. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14734. * @param name Define the name of the texture
  14735. * @param size Define the size of the texture to create
  14736. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14737. * @param scene Define the scene the texture belongs to
  14738. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14739. * @param generateMipMaps Define if the texture should creates mip maps or not
  14740. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14741. * @param textureType The FBO internal texture type
  14742. */
  14743. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14744. /**
  14745. * The effect that is created when initializing the post process.
  14746. * @returns The created effect corresponding the the postprocess.
  14747. */
  14748. getEffect(): Effect;
  14749. /**
  14750. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14751. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14752. */
  14753. getContent(): Nullable<Promise<ArrayBufferView>>;
  14754. private _createIndexBuffer;
  14755. /** @hidden */
  14756. _rebuild(): void;
  14757. /**
  14758. * Resets the texture in order to recreate its associated resources.
  14759. * This can be called in case of context loss
  14760. */
  14761. reset(): void;
  14762. protected _getDefines(): string;
  14763. /**
  14764. * Is the texture ready to be used ? (rendered at least once)
  14765. * @returns true if ready, otherwise, false.
  14766. */
  14767. isReady(): boolean;
  14768. /**
  14769. * Resets the refresh counter of the texture and start bak from scratch.
  14770. * Could be useful to regenerate the texture if it is setup to render only once.
  14771. */
  14772. resetRefreshCounter(): void;
  14773. /**
  14774. * Set the fragment shader to use in order to render the texture.
  14775. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14776. */
  14777. setFragment(fragment: any): void;
  14778. /**
  14779. * Define the refresh rate of the texture or the rendering frequency.
  14780. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14781. */
  14782. get refreshRate(): number;
  14783. set refreshRate(value: number);
  14784. /** @hidden */
  14785. _shouldRender(): boolean;
  14786. /**
  14787. * Get the size the texture is rendering at.
  14788. * @returns the size (on cube texture it is always squared)
  14789. */
  14790. getRenderSize(): RenderTargetTextureSize;
  14791. /**
  14792. * Resize the texture to new value.
  14793. * @param size Define the new size the texture should have
  14794. * @param generateMipMaps Define whether the new texture should create mip maps
  14795. */
  14796. resize(size: number, generateMipMaps: boolean): void;
  14797. private _checkUniform;
  14798. /**
  14799. * Set a texture in the shader program used to render.
  14800. * @param name Define the name of the uniform samplers as defined in the shader
  14801. * @param texture Define the texture to bind to this sampler
  14802. * @return the texture itself allowing "fluent" like uniform updates
  14803. */
  14804. setTexture(name: string, texture: Texture): ProceduralTexture;
  14805. /**
  14806. * Set a float in the shader.
  14807. * @param name Define the name of the uniform as defined in the shader
  14808. * @param value Define the value to give to the uniform
  14809. * @return the texture itself allowing "fluent" like uniform updates
  14810. */
  14811. setFloat(name: string, value: number): ProceduralTexture;
  14812. /**
  14813. * Set a int in the shader.
  14814. * @param name Define the name of the uniform as defined in the shader
  14815. * @param value Define the value to give to the uniform
  14816. * @return the texture itself allowing "fluent" like uniform updates
  14817. */
  14818. setInt(name: string, value: number): ProceduralTexture;
  14819. /**
  14820. * Set an array of floats in the shader.
  14821. * @param name Define the name of the uniform as defined in the shader
  14822. * @param value Define the value to give to the uniform
  14823. * @return the texture itself allowing "fluent" like uniform updates
  14824. */
  14825. setFloats(name: string, value: number[]): ProceduralTexture;
  14826. /**
  14827. * Set a vec3 in the shader from a Color3.
  14828. * @param name Define the name of the uniform as defined in the shader
  14829. * @param value Define the value to give to the uniform
  14830. * @return the texture itself allowing "fluent" like uniform updates
  14831. */
  14832. setColor3(name: string, value: Color3): ProceduralTexture;
  14833. /**
  14834. * Set a vec4 in the shader from a Color4.
  14835. * @param name Define the name of the uniform as defined in the shader
  14836. * @param value Define the value to give to the uniform
  14837. * @return the texture itself allowing "fluent" like uniform updates
  14838. */
  14839. setColor4(name: string, value: Color4): ProceduralTexture;
  14840. /**
  14841. * Set a vec2 in the shader from a Vector2.
  14842. * @param name Define the name of the uniform as defined in the shader
  14843. * @param value Define the value to give to the uniform
  14844. * @return the texture itself allowing "fluent" like uniform updates
  14845. */
  14846. setVector2(name: string, value: Vector2): ProceduralTexture;
  14847. /**
  14848. * Set a vec3 in the shader from a Vector3.
  14849. * @param name Define the name of the uniform as defined in the shader
  14850. * @param value Define the value to give to the uniform
  14851. * @return the texture itself allowing "fluent" like uniform updates
  14852. */
  14853. setVector3(name: string, value: Vector3): ProceduralTexture;
  14854. /**
  14855. * Set a mat4 in the shader from a MAtrix.
  14856. * @param name Define the name of the uniform as defined in the shader
  14857. * @param value Define the value to give to the uniform
  14858. * @return the texture itself allowing "fluent" like uniform updates
  14859. */
  14860. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14861. /**
  14862. * Render the texture to its associated render target.
  14863. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14864. */
  14865. render(useCameraPostProcess?: boolean): void;
  14866. /**
  14867. * Clone the texture.
  14868. * @returns the cloned texture
  14869. */
  14870. clone(): ProceduralTexture;
  14871. /**
  14872. * Dispose the texture and release its asoociated resources.
  14873. */
  14874. dispose(): void;
  14875. }
  14876. }
  14877. declare module BABYLON {
  14878. /**
  14879. * This represents the base class for particle system in Babylon.
  14880. * 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.
  14881. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14882. * @example https://doc.babylonjs.com/babylon101/particles
  14883. */
  14884. export class BaseParticleSystem {
  14885. /**
  14886. * Source color is added to the destination color without alpha affecting the result
  14887. */
  14888. static BLENDMODE_ONEONE: number;
  14889. /**
  14890. * Blend current color and particle color using particle’s alpha
  14891. */
  14892. static BLENDMODE_STANDARD: number;
  14893. /**
  14894. * Add current color and particle color multiplied by particle’s alpha
  14895. */
  14896. static BLENDMODE_ADD: number;
  14897. /**
  14898. * Multiply current color with particle color
  14899. */
  14900. static BLENDMODE_MULTIPLY: number;
  14901. /**
  14902. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14903. */
  14904. static BLENDMODE_MULTIPLYADD: number;
  14905. /**
  14906. * List of animations used by the particle system.
  14907. */
  14908. animations: Animation[];
  14909. /**
  14910. * Gets or sets the unique id of the particle system
  14911. */
  14912. uniqueId: number;
  14913. /**
  14914. * The id of the Particle system.
  14915. */
  14916. id: string;
  14917. /**
  14918. * The friendly name of the Particle system.
  14919. */
  14920. name: string;
  14921. /**
  14922. * Snippet ID if the particle system was created from the snippet server
  14923. */
  14924. snippetId: string;
  14925. /**
  14926. * The rendering group used by the Particle system to chose when to render.
  14927. */
  14928. renderingGroupId: number;
  14929. /**
  14930. * The emitter represents the Mesh or position we are attaching the particle system to.
  14931. */
  14932. emitter: Nullable<AbstractMesh | Vector3>;
  14933. /**
  14934. * The maximum number of particles to emit per frame
  14935. */
  14936. emitRate: number;
  14937. /**
  14938. * If you want to launch only a few particles at once, that can be done, as well.
  14939. */
  14940. manualEmitCount: number;
  14941. /**
  14942. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14943. */
  14944. updateSpeed: number;
  14945. /**
  14946. * The amount of time the particle system is running (depends of the overall update speed).
  14947. */
  14948. targetStopDuration: number;
  14949. /**
  14950. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14951. */
  14952. disposeOnStop: boolean;
  14953. /**
  14954. * Minimum power of emitting particles.
  14955. */
  14956. minEmitPower: number;
  14957. /**
  14958. * Maximum power of emitting particles.
  14959. */
  14960. maxEmitPower: number;
  14961. /**
  14962. * Minimum life time of emitting particles.
  14963. */
  14964. minLifeTime: number;
  14965. /**
  14966. * Maximum life time of emitting particles.
  14967. */
  14968. maxLifeTime: number;
  14969. /**
  14970. * Minimum Size of emitting particles.
  14971. */
  14972. minSize: number;
  14973. /**
  14974. * Maximum Size of emitting particles.
  14975. */
  14976. maxSize: number;
  14977. /**
  14978. * Minimum scale of emitting particles on X axis.
  14979. */
  14980. minScaleX: number;
  14981. /**
  14982. * Maximum scale of emitting particles on X axis.
  14983. */
  14984. maxScaleX: number;
  14985. /**
  14986. * Minimum scale of emitting particles on Y axis.
  14987. */
  14988. minScaleY: number;
  14989. /**
  14990. * Maximum scale of emitting particles on Y axis.
  14991. */
  14992. maxScaleY: number;
  14993. /**
  14994. * Gets or sets the minimal initial rotation in radians.
  14995. */
  14996. minInitialRotation: number;
  14997. /**
  14998. * Gets or sets the maximal initial rotation in radians.
  14999. */
  15000. maxInitialRotation: number;
  15001. /**
  15002. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15003. */
  15004. minAngularSpeed: number;
  15005. /**
  15006. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15007. */
  15008. maxAngularSpeed: number;
  15009. /**
  15010. * The texture used to render each particle. (this can be a spritesheet)
  15011. */
  15012. particleTexture: Nullable<BaseTexture>;
  15013. /**
  15014. * The layer mask we are rendering the particles through.
  15015. */
  15016. layerMask: number;
  15017. /**
  15018. * This can help using your own shader to render the particle system.
  15019. * The according effect will be created
  15020. */
  15021. customShader: any;
  15022. /**
  15023. * By default particle system starts as soon as they are created. This prevents the
  15024. * automatic start to happen and let you decide when to start emitting particles.
  15025. */
  15026. preventAutoStart: boolean;
  15027. private _noiseTexture;
  15028. /**
  15029. * Gets or sets a texture used to add random noise to particle positions
  15030. */
  15031. get noiseTexture(): Nullable<ProceduralTexture>;
  15032. set noiseTexture(value: Nullable<ProceduralTexture>);
  15033. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15034. noiseStrength: Vector3;
  15035. /**
  15036. * Callback triggered when the particle animation is ending.
  15037. */
  15038. onAnimationEnd: Nullable<() => void>;
  15039. /**
  15040. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15041. */
  15042. blendMode: number;
  15043. /**
  15044. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15045. * to override the particles.
  15046. */
  15047. forceDepthWrite: boolean;
  15048. /** 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 */
  15049. preWarmCycles: number;
  15050. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15051. preWarmStepOffset: number;
  15052. /**
  15053. * 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)
  15054. */
  15055. spriteCellChangeSpeed: number;
  15056. /**
  15057. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15058. */
  15059. startSpriteCellID: number;
  15060. /**
  15061. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15062. */
  15063. endSpriteCellID: number;
  15064. /**
  15065. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15066. */
  15067. spriteCellWidth: number;
  15068. /**
  15069. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15070. */
  15071. spriteCellHeight: number;
  15072. /**
  15073. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15074. */
  15075. spriteRandomStartCell: boolean;
  15076. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15077. translationPivot: Vector2;
  15078. /** @hidden */
  15079. protected _isAnimationSheetEnabled: boolean;
  15080. /**
  15081. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15082. */
  15083. beginAnimationOnStart: boolean;
  15084. /**
  15085. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15086. */
  15087. beginAnimationFrom: number;
  15088. /**
  15089. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15090. */
  15091. beginAnimationTo: number;
  15092. /**
  15093. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15094. */
  15095. beginAnimationLoop: boolean;
  15096. /**
  15097. * Gets or sets a world offset applied to all particles
  15098. */
  15099. worldOffset: Vector3;
  15100. /**
  15101. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15102. */
  15103. get isAnimationSheetEnabled(): boolean;
  15104. set isAnimationSheetEnabled(value: boolean);
  15105. /**
  15106. * Get hosting scene
  15107. * @returns the scene
  15108. */
  15109. getScene(): Nullable<Scene>;
  15110. /**
  15111. * You can use gravity if you want to give an orientation to your particles.
  15112. */
  15113. gravity: Vector3;
  15114. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15115. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15116. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15117. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15118. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15119. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15120. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15121. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15122. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15123. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15124. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15125. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15126. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15127. /**
  15128. * Defines the delay in milliseconds before starting the system (0 by default)
  15129. */
  15130. startDelay: number;
  15131. /**
  15132. * Gets the current list of drag gradients.
  15133. * You must use addDragGradient and removeDragGradient to udpate this list
  15134. * @returns the list of drag gradients
  15135. */
  15136. getDragGradients(): Nullable<Array<FactorGradient>>;
  15137. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15138. limitVelocityDamping: number;
  15139. /**
  15140. * Gets the current list of limit velocity gradients.
  15141. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15142. * @returns the list of limit velocity gradients
  15143. */
  15144. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15145. /**
  15146. * Gets the current list of color gradients.
  15147. * You must use addColorGradient and removeColorGradient to udpate this list
  15148. * @returns the list of color gradients
  15149. */
  15150. getColorGradients(): Nullable<Array<ColorGradient>>;
  15151. /**
  15152. * Gets the current list of size gradients.
  15153. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15154. * @returns the list of size gradients
  15155. */
  15156. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15157. /**
  15158. * Gets the current list of color remap gradients.
  15159. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15160. * @returns the list of color remap gradients
  15161. */
  15162. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15163. /**
  15164. * Gets the current list of alpha remap gradients.
  15165. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15166. * @returns the list of alpha remap gradients
  15167. */
  15168. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15169. /**
  15170. * Gets the current list of life time gradients.
  15171. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15172. * @returns the list of life time gradients
  15173. */
  15174. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15175. /**
  15176. * Gets the current list of angular speed gradients.
  15177. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15178. * @returns the list of angular speed gradients
  15179. */
  15180. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15181. /**
  15182. * Gets the current list of velocity gradients.
  15183. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15184. * @returns the list of velocity gradients
  15185. */
  15186. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15187. /**
  15188. * Gets the current list of start size gradients.
  15189. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15190. * @returns the list of start size gradients
  15191. */
  15192. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15193. /**
  15194. * Gets the current list of emit rate gradients.
  15195. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15196. * @returns the list of emit rate gradients
  15197. */
  15198. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15199. /**
  15200. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15201. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15202. */
  15203. get direction1(): Vector3;
  15204. set direction1(value: Vector3);
  15205. /**
  15206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15207. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15208. */
  15209. get direction2(): Vector3;
  15210. set direction2(value: Vector3);
  15211. /**
  15212. * 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.
  15213. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15214. */
  15215. get minEmitBox(): Vector3;
  15216. set minEmitBox(value: Vector3);
  15217. /**
  15218. * 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.
  15219. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15220. */
  15221. get maxEmitBox(): Vector3;
  15222. set maxEmitBox(value: Vector3);
  15223. /**
  15224. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15225. */
  15226. color1: Color4;
  15227. /**
  15228. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15229. */
  15230. color2: Color4;
  15231. /**
  15232. * Color the particle will have at the end of its lifetime
  15233. */
  15234. colorDead: Color4;
  15235. /**
  15236. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15237. */
  15238. textureMask: Color4;
  15239. /**
  15240. * The particle emitter type defines the emitter used by the particle system.
  15241. * It can be for example box, sphere, or cone...
  15242. */
  15243. particleEmitterType: IParticleEmitterType;
  15244. /** @hidden */
  15245. _isSubEmitter: boolean;
  15246. /**
  15247. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15248. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15249. */
  15250. billboardMode: number;
  15251. protected _isBillboardBased: boolean;
  15252. /**
  15253. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15254. */
  15255. get isBillboardBased(): boolean;
  15256. set isBillboardBased(value: boolean);
  15257. /**
  15258. * The scene the particle system belongs to.
  15259. */
  15260. protected _scene: Nullable<Scene>;
  15261. /**
  15262. * The engine the particle system belongs to.
  15263. */
  15264. protected _engine: ThinEngine;
  15265. /**
  15266. * Local cache of defines for image processing.
  15267. */
  15268. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15269. /**
  15270. * Default configuration related to image processing available in the standard Material.
  15271. */
  15272. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15273. /**
  15274. * Gets the image processing configuration used either in this material.
  15275. */
  15276. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15277. /**
  15278. * Sets the Default image processing configuration used either in the this material.
  15279. *
  15280. * If sets to null, the scene one is in use.
  15281. */
  15282. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15283. /**
  15284. * Attaches a new image processing configuration to the Standard Material.
  15285. * @param configuration
  15286. */
  15287. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15288. /** @hidden */
  15289. protected _reset(): void;
  15290. /** @hidden */
  15291. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15292. /**
  15293. * Instantiates a particle system.
  15294. * 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.
  15295. * @param name The name of the particle system
  15296. */
  15297. constructor(name: string);
  15298. /**
  15299. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15300. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15301. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15302. * @returns the emitter
  15303. */
  15304. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15305. /**
  15306. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15307. * @param radius The radius of the hemisphere to emit from
  15308. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15309. * @returns the emitter
  15310. */
  15311. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15312. /**
  15313. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15314. * @param radius The radius of the sphere to emit from
  15315. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15316. * @returns the emitter
  15317. */
  15318. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15319. /**
  15320. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15321. * @param radius The radius of the sphere to emit from
  15322. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15323. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15324. * @returns the emitter
  15325. */
  15326. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15327. /**
  15328. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15329. * @param radius The radius of the emission cylinder
  15330. * @param height The height of the emission cylinder
  15331. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15332. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15333. * @returns the emitter
  15334. */
  15335. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15336. /**
  15337. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15338. * @param radius The radius of the cylinder to emit from
  15339. * @param height The height of the emission cylinder
  15340. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15343. * @returns the emitter
  15344. */
  15345. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15346. /**
  15347. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15348. * @param radius The radius of the cone to emit from
  15349. * @param angle The base angle of the cone
  15350. * @returns the emitter
  15351. */
  15352. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15353. /**
  15354. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15355. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15356. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15357. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15358. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15359. * @returns the emitter
  15360. */
  15361. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15362. }
  15363. }
  15364. declare module BABYLON {
  15365. /**
  15366. * Type of sub emitter
  15367. */
  15368. export enum SubEmitterType {
  15369. /**
  15370. * Attached to the particle over it's lifetime
  15371. */
  15372. ATTACHED = 0,
  15373. /**
  15374. * Created when the particle dies
  15375. */
  15376. END = 1
  15377. }
  15378. /**
  15379. * Sub emitter class used to emit particles from an existing particle
  15380. */
  15381. export class SubEmitter {
  15382. /**
  15383. * the particle system to be used by the sub emitter
  15384. */
  15385. particleSystem: ParticleSystem;
  15386. /**
  15387. * Type of the submitter (Default: END)
  15388. */
  15389. type: SubEmitterType;
  15390. /**
  15391. * 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)
  15392. * Note: This only is supported when using an emitter of type Mesh
  15393. */
  15394. inheritDirection: boolean;
  15395. /**
  15396. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15397. */
  15398. inheritedVelocityAmount: number;
  15399. /**
  15400. * Creates a sub emitter
  15401. * @param particleSystem the particle system to be used by the sub emitter
  15402. */
  15403. constructor(
  15404. /**
  15405. * the particle system to be used by the sub emitter
  15406. */
  15407. particleSystem: ParticleSystem);
  15408. /**
  15409. * Clones the sub emitter
  15410. * @returns the cloned sub emitter
  15411. */
  15412. clone(): SubEmitter;
  15413. /**
  15414. * Serialize current object to a JSON object
  15415. * @returns the serialized object
  15416. */
  15417. serialize(): any;
  15418. /** @hidden */
  15419. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15420. /**
  15421. * Creates a new SubEmitter from a serialized JSON version
  15422. * @param serializationObject defines the JSON object to read from
  15423. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15424. * @param rootUrl defines the rootUrl for data loading
  15425. * @returns a new SubEmitter
  15426. */
  15427. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15428. /** Release associated resources */
  15429. dispose(): void;
  15430. }
  15431. }
  15432. declare module BABYLON {
  15433. /** @hidden */
  15434. export var clipPlaneFragmentDeclaration: {
  15435. name: string;
  15436. shader: string;
  15437. };
  15438. }
  15439. declare module BABYLON {
  15440. /** @hidden */
  15441. export var imageProcessingDeclaration: {
  15442. name: string;
  15443. shader: string;
  15444. };
  15445. }
  15446. declare module BABYLON {
  15447. /** @hidden */
  15448. export var imageProcessingFunctions: {
  15449. name: string;
  15450. shader: string;
  15451. };
  15452. }
  15453. declare module BABYLON {
  15454. /** @hidden */
  15455. export var clipPlaneFragment: {
  15456. name: string;
  15457. shader: string;
  15458. };
  15459. }
  15460. declare module BABYLON {
  15461. /** @hidden */
  15462. export var particlesPixelShader: {
  15463. name: string;
  15464. shader: string;
  15465. };
  15466. }
  15467. declare module BABYLON {
  15468. /** @hidden */
  15469. export var clipPlaneVertexDeclaration: {
  15470. name: string;
  15471. shader: string;
  15472. };
  15473. }
  15474. declare module BABYLON {
  15475. /** @hidden */
  15476. export var clipPlaneVertex: {
  15477. name: string;
  15478. shader: string;
  15479. };
  15480. }
  15481. declare module BABYLON {
  15482. /** @hidden */
  15483. export var particlesVertexShader: {
  15484. name: string;
  15485. shader: string;
  15486. };
  15487. }
  15488. declare module BABYLON {
  15489. /**
  15490. * Interface used to define entities containing multiple clip planes
  15491. */
  15492. export interface IClipPlanesHolder {
  15493. /**
  15494. * Gets or sets the active clipplane 1
  15495. */
  15496. clipPlane: Nullable<Plane>;
  15497. /**
  15498. * Gets or sets the active clipplane 2
  15499. */
  15500. clipPlane2: Nullable<Plane>;
  15501. /**
  15502. * Gets or sets the active clipplane 3
  15503. */
  15504. clipPlane3: Nullable<Plane>;
  15505. /**
  15506. * Gets or sets the active clipplane 4
  15507. */
  15508. clipPlane4: Nullable<Plane>;
  15509. /**
  15510. * Gets or sets the active clipplane 5
  15511. */
  15512. clipPlane5: Nullable<Plane>;
  15513. /**
  15514. * Gets or sets the active clipplane 6
  15515. */
  15516. clipPlane6: Nullable<Plane>;
  15517. }
  15518. }
  15519. declare module BABYLON {
  15520. /**
  15521. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15522. *
  15523. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15524. *
  15525. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15526. */
  15527. export class ThinMaterialHelper {
  15528. /**
  15529. * Binds the clip plane information from the holder to the effect.
  15530. * @param effect The effect we are binding the data to
  15531. * @param holder The entity containing the clip plane information
  15532. */
  15533. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15534. }
  15535. }
  15536. declare module BABYLON {
  15537. interface ThinEngine {
  15538. /**
  15539. * Sets alpha constants used by some alpha blending modes
  15540. * @param r defines the red component
  15541. * @param g defines the green component
  15542. * @param b defines the blue component
  15543. * @param a defines the alpha component
  15544. */
  15545. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15546. /**
  15547. * Sets the current alpha mode
  15548. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15549. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15550. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15551. */
  15552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15553. /**
  15554. * Gets the current alpha mode
  15555. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15556. * @returns the current alpha mode
  15557. */
  15558. getAlphaMode(): number;
  15559. /**
  15560. * Sets the current alpha equation
  15561. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15562. */
  15563. setAlphaEquation(equation: number): void;
  15564. /**
  15565. * Gets the current alpha equation.
  15566. * @returns the current alpha equation
  15567. */
  15568. getAlphaEquation(): number;
  15569. }
  15570. }
  15571. declare module BABYLON {
  15572. /**
  15573. * This represents a particle system in Babylon.
  15574. * 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.
  15575. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15576. * @example https://doc.babylonjs.com/babylon101/particles
  15577. */
  15578. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15579. /**
  15580. * Billboard mode will only apply to Y axis
  15581. */
  15582. static readonly BILLBOARDMODE_Y: number;
  15583. /**
  15584. * Billboard mode will apply to all axes
  15585. */
  15586. static readonly BILLBOARDMODE_ALL: number;
  15587. /**
  15588. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15589. */
  15590. static readonly BILLBOARDMODE_STRETCHED: number;
  15591. /**
  15592. * This function can be defined to provide custom update for active particles.
  15593. * This function will be called instead of regular update (age, position, color, etc.).
  15594. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15595. */
  15596. updateFunction: (particles: Particle[]) => void;
  15597. private _emitterWorldMatrix;
  15598. /**
  15599. * This function can be defined to specify initial direction for every new particle.
  15600. * It by default use the emitterType defined function
  15601. */
  15602. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15603. /**
  15604. * This function can be defined to specify initial position for every new particle.
  15605. * It by default use the emitterType defined function
  15606. */
  15607. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15608. /**
  15609. * @hidden
  15610. */
  15611. _inheritedVelocityOffset: Vector3;
  15612. /**
  15613. * An event triggered when the system is disposed
  15614. */
  15615. onDisposeObservable: Observable<IParticleSystem>;
  15616. /**
  15617. * An event triggered when the system is stopped
  15618. */
  15619. onStoppedObservable: Observable<IParticleSystem>;
  15620. private _onDisposeObserver;
  15621. /**
  15622. * Sets a callback that will be triggered when the system is disposed
  15623. */
  15624. set onDispose(callback: () => void);
  15625. private _particles;
  15626. private _epsilon;
  15627. private _capacity;
  15628. private _stockParticles;
  15629. private _newPartsExcess;
  15630. private _vertexData;
  15631. private _vertexBuffer;
  15632. private _vertexBuffers;
  15633. private _spriteBuffer;
  15634. private _indexBuffer;
  15635. private _effect;
  15636. private _customEffect;
  15637. private _cachedDefines;
  15638. private _scaledColorStep;
  15639. private _colorDiff;
  15640. private _scaledDirection;
  15641. private _scaledGravity;
  15642. private _currentRenderId;
  15643. private _alive;
  15644. private _useInstancing;
  15645. private _vertexArrayObject;
  15646. private _started;
  15647. private _stopped;
  15648. private _actualFrame;
  15649. private _scaledUpdateSpeed;
  15650. private _vertexBufferSize;
  15651. /** @hidden */
  15652. _currentEmitRateGradient: Nullable<FactorGradient>;
  15653. /** @hidden */
  15654. _currentEmitRate1: number;
  15655. /** @hidden */
  15656. _currentEmitRate2: number;
  15657. /** @hidden */
  15658. _currentStartSizeGradient: Nullable<FactorGradient>;
  15659. /** @hidden */
  15660. _currentStartSize1: number;
  15661. /** @hidden */
  15662. _currentStartSize2: number;
  15663. private readonly _rawTextureWidth;
  15664. private _rampGradientsTexture;
  15665. private _useRampGradients;
  15666. /** Gets or sets a matrix to use to compute projection */
  15667. defaultProjectionMatrix: Matrix;
  15668. /** Gets or sets a matrix to use to compute view */
  15669. defaultViewMatrix: Matrix;
  15670. /** Gets or sets a boolean indicating that ramp gradients must be used
  15671. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15672. */
  15673. get useRampGradients(): boolean;
  15674. set useRampGradients(value: boolean);
  15675. /**
  15676. * 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.
  15677. * 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: [])
  15678. */
  15679. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15680. private _subEmitters;
  15681. /**
  15682. * @hidden
  15683. * If the particle systems emitter should be disposed when the particle system is disposed
  15684. */
  15685. _disposeEmitterOnDispose: boolean;
  15686. /**
  15687. * The current active Sub-systems, this property is used by the root particle system only.
  15688. */
  15689. activeSubSystems: Array<ParticleSystem>;
  15690. /**
  15691. * Specifies if the particles are updated in emitter local space or world space
  15692. */
  15693. isLocal: boolean;
  15694. private _rootParticleSystem;
  15695. /**
  15696. * Gets the current list of active particles
  15697. */
  15698. get particles(): Particle[];
  15699. /**
  15700. * Gets the number of particles active at the same time.
  15701. * @returns The number of active particles.
  15702. */
  15703. getActiveCount(): number;
  15704. /**
  15705. * Returns the string "ParticleSystem"
  15706. * @returns a string containing the class name
  15707. */
  15708. getClassName(): string;
  15709. /**
  15710. * Gets a boolean indicating that the system is stopping
  15711. * @returns true if the system is currently stopping
  15712. */
  15713. isStopping(): boolean;
  15714. /**
  15715. * Gets the custom effect used to render the particles
  15716. * @param blendMode Blend mode for which the effect should be retrieved
  15717. * @returns The effect
  15718. */
  15719. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15720. /**
  15721. * Sets the custom effect used to render the particles
  15722. * @param effect The effect to set
  15723. * @param blendMode Blend mode for which the effect should be set
  15724. */
  15725. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15726. /** @hidden */
  15727. private _onBeforeDrawParticlesObservable;
  15728. /**
  15729. * Observable that will be called just before the particles are drawn
  15730. */
  15731. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15732. /**
  15733. * Gets the name of the particle vertex shader
  15734. */
  15735. get vertexShaderName(): string;
  15736. /**
  15737. * Instantiates a particle system.
  15738. * 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.
  15739. * @param name The name of the particle system
  15740. * @param capacity The max number of particles alive at the same time
  15741. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15742. * @param customEffect a custom effect used to change the way particles are rendered by default
  15743. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15744. * @param epsilon Offset used to render the particles
  15745. */
  15746. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15747. private _addFactorGradient;
  15748. private _removeFactorGradient;
  15749. /**
  15750. * Adds a new life time gradient
  15751. * @param gradient defines the gradient to use (between 0 and 1)
  15752. * @param factor defines the life time factor to affect to the specified gradient
  15753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15754. * @returns the current particle system
  15755. */
  15756. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15757. /**
  15758. * Remove a specific life time gradient
  15759. * @param gradient defines the gradient to remove
  15760. * @returns the current particle system
  15761. */
  15762. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15763. /**
  15764. * Adds a new size gradient
  15765. * @param gradient defines the gradient to use (between 0 and 1)
  15766. * @param factor defines the size factor to affect to the specified gradient
  15767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15768. * @returns the current particle system
  15769. */
  15770. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15771. /**
  15772. * Remove a specific size gradient
  15773. * @param gradient defines the gradient to remove
  15774. * @returns the current particle system
  15775. */
  15776. removeSizeGradient(gradient: number): IParticleSystem;
  15777. /**
  15778. * Adds a new color remap gradient
  15779. * @param gradient defines the gradient to use (between 0 and 1)
  15780. * @param min defines the color remap minimal range
  15781. * @param max defines the color remap maximal range
  15782. * @returns the current particle system
  15783. */
  15784. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15785. /**
  15786. * Remove a specific color remap gradient
  15787. * @param gradient defines the gradient to remove
  15788. * @returns the current particle system
  15789. */
  15790. removeColorRemapGradient(gradient: number): IParticleSystem;
  15791. /**
  15792. * Adds a new alpha remap gradient
  15793. * @param gradient defines the gradient to use (between 0 and 1)
  15794. * @param min defines the alpha remap minimal range
  15795. * @param max defines the alpha remap maximal range
  15796. * @returns the current particle system
  15797. */
  15798. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15799. /**
  15800. * Remove a specific alpha remap gradient
  15801. * @param gradient defines the gradient to remove
  15802. * @returns the current particle system
  15803. */
  15804. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15805. /**
  15806. * Adds a new angular speed gradient
  15807. * @param gradient defines the gradient to use (between 0 and 1)
  15808. * @param factor defines the angular speed to affect to the specified gradient
  15809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15810. * @returns the current particle system
  15811. */
  15812. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15813. /**
  15814. * Remove a specific angular speed gradient
  15815. * @param gradient defines the gradient to remove
  15816. * @returns the current particle system
  15817. */
  15818. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15819. /**
  15820. * Adds a new velocity gradient
  15821. * @param gradient defines the gradient to use (between 0 and 1)
  15822. * @param factor defines the velocity to affect to the specified gradient
  15823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15824. * @returns the current particle system
  15825. */
  15826. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15827. /**
  15828. * Remove a specific velocity gradient
  15829. * @param gradient defines the gradient to remove
  15830. * @returns the current particle system
  15831. */
  15832. removeVelocityGradient(gradient: number): IParticleSystem;
  15833. /**
  15834. * Adds a new limit velocity gradient
  15835. * @param gradient defines the gradient to use (between 0 and 1)
  15836. * @param factor defines the limit velocity value to affect to the specified gradient
  15837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15838. * @returns the current particle system
  15839. */
  15840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15841. /**
  15842. * Remove a specific limit velocity gradient
  15843. * @param gradient defines the gradient to remove
  15844. * @returns the current particle system
  15845. */
  15846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15847. /**
  15848. * Adds a new drag gradient
  15849. * @param gradient defines the gradient to use (between 0 and 1)
  15850. * @param factor defines the drag value to affect to the specified gradient
  15851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15852. * @returns the current particle system
  15853. */
  15854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15855. /**
  15856. * Remove a specific drag gradient
  15857. * @param gradient defines the gradient to remove
  15858. * @returns the current particle system
  15859. */
  15860. removeDragGradient(gradient: number): IParticleSystem;
  15861. /**
  15862. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15863. * @param gradient defines the gradient to use (between 0 and 1)
  15864. * @param factor defines the emit rate value to affect to the specified gradient
  15865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15866. * @returns the current particle system
  15867. */
  15868. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15869. /**
  15870. * Remove a specific emit rate gradient
  15871. * @param gradient defines the gradient to remove
  15872. * @returns the current particle system
  15873. */
  15874. removeEmitRateGradient(gradient: number): IParticleSystem;
  15875. /**
  15876. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15877. * @param gradient defines the gradient to use (between 0 and 1)
  15878. * @param factor defines the start size value to affect to the specified gradient
  15879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15880. * @returns the current particle system
  15881. */
  15882. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15883. /**
  15884. * Remove a specific start size gradient
  15885. * @param gradient defines the gradient to remove
  15886. * @returns the current particle system
  15887. */
  15888. removeStartSizeGradient(gradient: number): IParticleSystem;
  15889. private _createRampGradientTexture;
  15890. /**
  15891. * Gets the current list of ramp gradients.
  15892. * You must use addRampGradient and removeRampGradient to udpate this list
  15893. * @returns the list of ramp gradients
  15894. */
  15895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15896. /** Force the system to rebuild all gradients that need to be resync */
  15897. forceRefreshGradients(): void;
  15898. private _syncRampGradientTexture;
  15899. /**
  15900. * Adds a new ramp gradient used to remap particle colors
  15901. * @param gradient defines the gradient to use (between 0 and 1)
  15902. * @param color defines the color to affect to the specified gradient
  15903. * @returns the current particle system
  15904. */
  15905. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15906. /**
  15907. * Remove a specific ramp gradient
  15908. * @param gradient defines the gradient to remove
  15909. * @returns the current particle system
  15910. */
  15911. removeRampGradient(gradient: number): ParticleSystem;
  15912. /**
  15913. * Adds a new color gradient
  15914. * @param gradient defines the gradient to use (between 0 and 1)
  15915. * @param color1 defines the color to affect to the specified gradient
  15916. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15917. * @returns this particle system
  15918. */
  15919. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15920. /**
  15921. * Remove a specific color gradient
  15922. * @param gradient defines the gradient to remove
  15923. * @returns this particle system
  15924. */
  15925. removeColorGradient(gradient: number): IParticleSystem;
  15926. private _fetchR;
  15927. protected _reset(): void;
  15928. private _resetEffect;
  15929. private _createVertexBuffers;
  15930. private _createIndexBuffer;
  15931. /**
  15932. * Gets the maximum number of particles active at the same time.
  15933. * @returns The max number of active particles.
  15934. */
  15935. getCapacity(): number;
  15936. /**
  15937. * Gets whether there are still active particles in the system.
  15938. * @returns True if it is alive, otherwise false.
  15939. */
  15940. isAlive(): boolean;
  15941. /**
  15942. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15943. * @returns True if it has been started, otherwise false.
  15944. */
  15945. isStarted(): boolean;
  15946. private _prepareSubEmitterInternalArray;
  15947. /**
  15948. * Starts the particle system and begins to emit
  15949. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15950. */
  15951. start(delay?: number): void;
  15952. /**
  15953. * Stops the particle system.
  15954. * @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.
  15955. */
  15956. stop(stopSubEmitters?: boolean): void;
  15957. /**
  15958. * Remove all active particles
  15959. */
  15960. reset(): void;
  15961. /**
  15962. * @hidden (for internal use only)
  15963. */
  15964. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15965. /**
  15966. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15967. * Its lifetime will start back at 0.
  15968. */
  15969. recycleParticle: (particle: Particle) => void;
  15970. private _stopSubEmitters;
  15971. private _createParticle;
  15972. private _removeFromRoot;
  15973. private _emitFromParticle;
  15974. private _update;
  15975. /** @hidden */
  15976. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15977. /** @hidden */
  15978. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15979. /**
  15980. * Fill the defines array according to the current settings of the particle system
  15981. * @param defines Array to be updated
  15982. * @param blendMode blend mode to take into account when updating the array
  15983. */
  15984. fillDefines(defines: Array<string>, blendMode: number): void;
  15985. /**
  15986. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15987. * @param uniforms Uniforms array to fill
  15988. * @param attributes Attributes array to fill
  15989. * @param samplers Samplers array to fill
  15990. */
  15991. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15992. /** @hidden */
  15993. private _getEffect;
  15994. /**
  15995. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15996. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15997. */
  15998. animate(preWarmOnly?: boolean): void;
  15999. private _appendParticleVertices;
  16000. /**
  16001. * Rebuilds the particle system.
  16002. */
  16003. rebuild(): void;
  16004. /**
  16005. * Is this system ready to be used/rendered
  16006. * @return true if the system is ready
  16007. */
  16008. isReady(): boolean;
  16009. private _render;
  16010. /**
  16011. * Renders the particle system in its current state.
  16012. * @returns the current number of particles
  16013. */
  16014. render(): number;
  16015. /**
  16016. * Disposes the particle system and free the associated resources
  16017. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16018. */
  16019. dispose(disposeTexture?: boolean): void;
  16020. /**
  16021. * Clones the particle system.
  16022. * @param name The name of the cloned object
  16023. * @param newEmitter The new emitter to use
  16024. * @returns the cloned particle system
  16025. */
  16026. clone(name: string, newEmitter: any): ParticleSystem;
  16027. /**
  16028. * Serializes the particle system to a JSON object
  16029. * @param serializeTexture defines if the texture must be serialized as well
  16030. * @returns the JSON object
  16031. */
  16032. serialize(serializeTexture?: boolean): any;
  16033. /** @hidden */
  16034. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16035. /** @hidden */
  16036. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16037. /**
  16038. * Parses a JSON object to create a particle system.
  16039. * @param parsedParticleSystem The JSON object to parse
  16040. * @param sceneOrEngine The scene or the engine to create the particle system in
  16041. * @param rootUrl The root url to use to load external dependencies like texture
  16042. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16043. * @returns the Parsed particle system
  16044. */
  16045. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16046. }
  16047. }
  16048. declare module BABYLON {
  16049. /**
  16050. * A particle represents one of the element emitted by a particle system.
  16051. * This is mainly define by its coordinates, direction, velocity and age.
  16052. */
  16053. export class Particle {
  16054. /**
  16055. * The particle system the particle belongs to.
  16056. */
  16057. particleSystem: ParticleSystem;
  16058. private static _Count;
  16059. /**
  16060. * Unique ID of the particle
  16061. */
  16062. id: number;
  16063. /**
  16064. * The world position of the particle in the scene.
  16065. */
  16066. position: Vector3;
  16067. /**
  16068. * The world direction of the particle in the scene.
  16069. */
  16070. direction: Vector3;
  16071. /**
  16072. * The color of the particle.
  16073. */
  16074. color: Color4;
  16075. /**
  16076. * The color change of the particle per step.
  16077. */
  16078. colorStep: Color4;
  16079. /**
  16080. * Defines how long will the life of the particle be.
  16081. */
  16082. lifeTime: number;
  16083. /**
  16084. * The current age of the particle.
  16085. */
  16086. age: number;
  16087. /**
  16088. * The current size of the particle.
  16089. */
  16090. size: number;
  16091. /**
  16092. * The current scale of the particle.
  16093. */
  16094. scale: Vector2;
  16095. /**
  16096. * The current angle of the particle.
  16097. */
  16098. angle: number;
  16099. /**
  16100. * Defines how fast is the angle changing.
  16101. */
  16102. angularSpeed: number;
  16103. /**
  16104. * Defines the cell index used by the particle to be rendered from a sprite.
  16105. */
  16106. cellIndex: number;
  16107. /**
  16108. * The information required to support color remapping
  16109. */
  16110. remapData: Vector4;
  16111. /** @hidden */
  16112. _randomCellOffset?: number;
  16113. /** @hidden */
  16114. _initialDirection: Nullable<Vector3>;
  16115. /** @hidden */
  16116. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16117. /** @hidden */
  16118. _initialStartSpriteCellID: number;
  16119. /** @hidden */
  16120. _initialEndSpriteCellID: number;
  16121. /** @hidden */
  16122. _currentColorGradient: Nullable<ColorGradient>;
  16123. /** @hidden */
  16124. _currentColor1: Color4;
  16125. /** @hidden */
  16126. _currentColor2: Color4;
  16127. /** @hidden */
  16128. _currentSizeGradient: Nullable<FactorGradient>;
  16129. /** @hidden */
  16130. _currentSize1: number;
  16131. /** @hidden */
  16132. _currentSize2: number;
  16133. /** @hidden */
  16134. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16135. /** @hidden */
  16136. _currentAngularSpeed1: number;
  16137. /** @hidden */
  16138. _currentAngularSpeed2: number;
  16139. /** @hidden */
  16140. _currentVelocityGradient: Nullable<FactorGradient>;
  16141. /** @hidden */
  16142. _currentVelocity1: number;
  16143. /** @hidden */
  16144. _currentVelocity2: number;
  16145. /** @hidden */
  16146. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16147. /** @hidden */
  16148. _currentLimitVelocity1: number;
  16149. /** @hidden */
  16150. _currentLimitVelocity2: number;
  16151. /** @hidden */
  16152. _currentDragGradient: Nullable<FactorGradient>;
  16153. /** @hidden */
  16154. _currentDrag1: number;
  16155. /** @hidden */
  16156. _currentDrag2: number;
  16157. /** @hidden */
  16158. _randomNoiseCoordinates1: Vector3;
  16159. /** @hidden */
  16160. _randomNoiseCoordinates2: Vector3;
  16161. /** @hidden */
  16162. _localPosition?: Vector3;
  16163. /**
  16164. * Creates a new instance Particle
  16165. * @param particleSystem the particle system the particle belongs to
  16166. */
  16167. constructor(
  16168. /**
  16169. * The particle system the particle belongs to.
  16170. */
  16171. particleSystem: ParticleSystem);
  16172. private updateCellInfoFromSystem;
  16173. /**
  16174. * Defines how the sprite cell index is updated for the particle
  16175. */
  16176. updateCellIndex(): void;
  16177. /** @hidden */
  16178. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16179. /** @hidden */
  16180. _inheritParticleInfoToSubEmitters(): void;
  16181. /** @hidden */
  16182. _reset(): void;
  16183. /**
  16184. * Copy the properties of particle to another one.
  16185. * @param other the particle to copy the information to.
  16186. */
  16187. copyTo(other: Particle): void;
  16188. }
  16189. }
  16190. declare module BABYLON {
  16191. /**
  16192. * Particle emitter represents a volume emitting particles.
  16193. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16194. */
  16195. export interface IParticleEmitterType {
  16196. /**
  16197. * Called by the particle System when the direction is computed for the created particle.
  16198. * @param worldMatrix is the world matrix of the particle system
  16199. * @param directionToUpdate is the direction vector to update with the result
  16200. * @param particle is the particle we are computed the direction for
  16201. * @param isLocal defines if the direction should be set in local space
  16202. */
  16203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16204. /**
  16205. * Called by the particle System when the position is computed for the created particle.
  16206. * @param worldMatrix is the world matrix of the particle system
  16207. * @param positionToUpdate is the position vector to update with the result
  16208. * @param particle is the particle we are computed the position for
  16209. * @param isLocal defines if the position should be set in local space
  16210. */
  16211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16212. /**
  16213. * Clones the current emitter and returns a copy of it
  16214. * @returns the new emitter
  16215. */
  16216. clone(): IParticleEmitterType;
  16217. /**
  16218. * Called by the GPUParticleSystem to setup the update shader
  16219. * @param effect defines the update shader
  16220. */
  16221. applyToShader(effect: Effect): void;
  16222. /**
  16223. * Returns a string to use to update the GPU particles update shader
  16224. * @returns the effect defines string
  16225. */
  16226. getEffectDefines(): string;
  16227. /**
  16228. * Returns a string representing the class name
  16229. * @returns a string containing the class name
  16230. */
  16231. getClassName(): string;
  16232. /**
  16233. * Serializes the particle system to a JSON object.
  16234. * @returns the JSON object
  16235. */
  16236. serialize(): any;
  16237. /**
  16238. * Parse properties from a JSON object
  16239. * @param serializationObject defines the JSON object
  16240. * @param scene defines the hosting scene
  16241. */
  16242. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16243. }
  16244. }
  16245. declare module BABYLON {
  16246. /**
  16247. * Particle emitter emitting particles from the inside of a box.
  16248. * It emits the particles randomly between 2 given directions.
  16249. */
  16250. export class BoxParticleEmitter implements IParticleEmitterType {
  16251. /**
  16252. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16253. */
  16254. direction1: Vector3;
  16255. /**
  16256. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16257. */
  16258. direction2: Vector3;
  16259. /**
  16260. * 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.
  16261. */
  16262. minEmitBox: Vector3;
  16263. /**
  16264. * 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.
  16265. */
  16266. maxEmitBox: Vector3;
  16267. /**
  16268. * Creates a new instance BoxParticleEmitter
  16269. */
  16270. constructor();
  16271. /**
  16272. * Called by the particle System when the direction is computed for the created particle.
  16273. * @param worldMatrix is the world matrix of the particle system
  16274. * @param directionToUpdate is the direction vector to update with the result
  16275. * @param particle is the particle we are computed the direction for
  16276. * @param isLocal defines if the direction should be set in local space
  16277. */
  16278. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16279. /**
  16280. * Called by the particle System when the position is computed for the created particle.
  16281. * @param worldMatrix is the world matrix of the particle system
  16282. * @param positionToUpdate is the position vector to update with the result
  16283. * @param particle is the particle we are computed the position for
  16284. * @param isLocal defines if the position should be set in local space
  16285. */
  16286. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16287. /**
  16288. * Clones the current emitter and returns a copy of it
  16289. * @returns the new emitter
  16290. */
  16291. clone(): BoxParticleEmitter;
  16292. /**
  16293. * Called by the GPUParticleSystem to setup the update shader
  16294. * @param effect defines the update shader
  16295. */
  16296. applyToShader(effect: Effect): void;
  16297. /**
  16298. * Returns a string to use to update the GPU particles update shader
  16299. * @returns a string containng the defines string
  16300. */
  16301. getEffectDefines(): string;
  16302. /**
  16303. * Returns the string "BoxParticleEmitter"
  16304. * @returns a string containing the class name
  16305. */
  16306. getClassName(): string;
  16307. /**
  16308. * Serializes the particle system to a JSON object.
  16309. * @returns the JSON object
  16310. */
  16311. serialize(): any;
  16312. /**
  16313. * Parse properties from a JSON object
  16314. * @param serializationObject defines the JSON object
  16315. */
  16316. parse(serializationObject: any): void;
  16317. }
  16318. }
  16319. declare module BABYLON {
  16320. /**
  16321. * Particle emitter emitting particles from the inside of a cone.
  16322. * It emits the particles alongside the cone volume from the base to the particle.
  16323. * The emission direction might be randomized.
  16324. */
  16325. export class ConeParticleEmitter implements IParticleEmitterType {
  16326. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16327. directionRandomizer: number;
  16328. private _radius;
  16329. private _angle;
  16330. private _height;
  16331. /**
  16332. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16333. */
  16334. radiusRange: number;
  16335. /**
  16336. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16337. */
  16338. heightRange: number;
  16339. /**
  16340. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16341. */
  16342. emitFromSpawnPointOnly: boolean;
  16343. /**
  16344. * Gets or sets the radius of the emission cone
  16345. */
  16346. get radius(): number;
  16347. set radius(value: number);
  16348. /**
  16349. * Gets or sets the angle of the emission cone
  16350. */
  16351. get angle(): number;
  16352. set angle(value: number);
  16353. private _buildHeight;
  16354. /**
  16355. * Creates a new instance ConeParticleEmitter
  16356. * @param radius the radius of the emission cone (1 by default)
  16357. * @param angle the cone base angle (PI by default)
  16358. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16359. */
  16360. constructor(radius?: number, angle?: number,
  16361. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16362. directionRandomizer?: number);
  16363. /**
  16364. * Called by the particle System when the direction is computed for the created particle.
  16365. * @param worldMatrix is the world matrix of the particle system
  16366. * @param directionToUpdate is the direction vector to update with the result
  16367. * @param particle is the particle we are computed the direction for
  16368. * @param isLocal defines if the direction should be set in local space
  16369. */
  16370. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16371. /**
  16372. * Called by the particle System when the position is computed for the created particle.
  16373. * @param worldMatrix is the world matrix of the particle system
  16374. * @param positionToUpdate is the position vector to update with the result
  16375. * @param particle is the particle we are computed the position for
  16376. * @param isLocal defines if the position should be set in local space
  16377. */
  16378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16379. /**
  16380. * Clones the current emitter and returns a copy of it
  16381. * @returns the new emitter
  16382. */
  16383. clone(): ConeParticleEmitter;
  16384. /**
  16385. * Called by the GPUParticleSystem to setup the update shader
  16386. * @param effect defines the update shader
  16387. */
  16388. applyToShader(effect: Effect): void;
  16389. /**
  16390. * Returns a string to use to update the GPU particles update shader
  16391. * @returns a string containng the defines string
  16392. */
  16393. getEffectDefines(): string;
  16394. /**
  16395. * Returns the string "ConeParticleEmitter"
  16396. * @returns a string containing the class name
  16397. */
  16398. getClassName(): string;
  16399. /**
  16400. * Serializes the particle system to a JSON object.
  16401. * @returns the JSON object
  16402. */
  16403. serialize(): any;
  16404. /**
  16405. * Parse properties from a JSON object
  16406. * @param serializationObject defines the JSON object
  16407. */
  16408. parse(serializationObject: any): void;
  16409. }
  16410. }
  16411. declare module BABYLON {
  16412. /**
  16413. * Particle emitter emitting particles from the inside of a cylinder.
  16414. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16415. */
  16416. export class CylinderParticleEmitter implements IParticleEmitterType {
  16417. /**
  16418. * The radius of the emission cylinder.
  16419. */
  16420. radius: number;
  16421. /**
  16422. * The height of the emission cylinder.
  16423. */
  16424. height: number;
  16425. /**
  16426. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16427. */
  16428. radiusRange: number;
  16429. /**
  16430. * How much to randomize the particle direction [0-1].
  16431. */
  16432. directionRandomizer: number;
  16433. /**
  16434. * Creates a new instance CylinderParticleEmitter
  16435. * @param radius the radius of the emission cylinder (1 by default)
  16436. * @param height the height of the emission cylinder (1 by default)
  16437. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16438. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16439. */
  16440. constructor(
  16441. /**
  16442. * The radius of the emission cylinder.
  16443. */
  16444. radius?: number,
  16445. /**
  16446. * The height of the emission cylinder.
  16447. */
  16448. height?: number,
  16449. /**
  16450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16451. */
  16452. radiusRange?: number,
  16453. /**
  16454. * How much to randomize the particle direction [0-1].
  16455. */
  16456. directionRandomizer?: number);
  16457. /**
  16458. * Called by the particle System when the direction is computed for the created particle.
  16459. * @param worldMatrix is the world matrix of the particle system
  16460. * @param directionToUpdate is the direction vector to update with the result
  16461. * @param particle is the particle we are computed the direction for
  16462. * @param isLocal defines if the direction should be set in local space
  16463. */
  16464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16465. /**
  16466. * Called by the particle System when the position is computed for the created particle.
  16467. * @param worldMatrix is the world matrix of the particle system
  16468. * @param positionToUpdate is the position vector to update with the result
  16469. * @param particle is the particle we are computed the position for
  16470. * @param isLocal defines if the position should be set in local space
  16471. */
  16472. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16473. /**
  16474. * Clones the current emitter and returns a copy of it
  16475. * @returns the new emitter
  16476. */
  16477. clone(): CylinderParticleEmitter;
  16478. /**
  16479. * Called by the GPUParticleSystem to setup the update shader
  16480. * @param effect defines the update shader
  16481. */
  16482. applyToShader(effect: Effect): void;
  16483. /**
  16484. * Returns a string to use to update the GPU particles update shader
  16485. * @returns a string containng the defines string
  16486. */
  16487. getEffectDefines(): string;
  16488. /**
  16489. * Returns the string "CylinderParticleEmitter"
  16490. * @returns a string containing the class name
  16491. */
  16492. getClassName(): string;
  16493. /**
  16494. * Serializes the particle system to a JSON object.
  16495. * @returns the JSON object
  16496. */
  16497. serialize(): any;
  16498. /**
  16499. * Parse properties from a JSON object
  16500. * @param serializationObject defines the JSON object
  16501. */
  16502. parse(serializationObject: any): void;
  16503. }
  16504. /**
  16505. * Particle emitter emitting particles from the inside of a cylinder.
  16506. * It emits the particles randomly between two vectors.
  16507. */
  16508. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16509. /**
  16510. * The min limit of the emission direction.
  16511. */
  16512. direction1: Vector3;
  16513. /**
  16514. * The max limit of the emission direction.
  16515. */
  16516. direction2: Vector3;
  16517. /**
  16518. * Creates a new instance CylinderDirectedParticleEmitter
  16519. * @param radius the radius of the emission cylinder (1 by default)
  16520. * @param height the height of the emission cylinder (1 by default)
  16521. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16522. * @param direction1 the min limit of the emission direction (up vector by default)
  16523. * @param direction2 the max limit of the emission direction (up vector by default)
  16524. */
  16525. constructor(radius?: number, height?: number, radiusRange?: number,
  16526. /**
  16527. * The min limit of the emission direction.
  16528. */
  16529. direction1?: Vector3,
  16530. /**
  16531. * The max limit of the emission direction.
  16532. */
  16533. direction2?: Vector3);
  16534. /**
  16535. * Called by the particle System when the direction is computed for the created particle.
  16536. * @param worldMatrix is the world matrix of the particle system
  16537. * @param directionToUpdate is the direction vector to update with the result
  16538. * @param particle is the particle we are computed the direction for
  16539. */
  16540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16541. /**
  16542. * Clones the current emitter and returns a copy of it
  16543. * @returns the new emitter
  16544. */
  16545. clone(): CylinderDirectedParticleEmitter;
  16546. /**
  16547. * Called by the GPUParticleSystem to setup the update shader
  16548. * @param effect defines the update shader
  16549. */
  16550. applyToShader(effect: Effect): void;
  16551. /**
  16552. * Returns a string to use to update the GPU particles update shader
  16553. * @returns a string containng the defines string
  16554. */
  16555. getEffectDefines(): string;
  16556. /**
  16557. * Returns the string "CylinderDirectedParticleEmitter"
  16558. * @returns a string containing the class name
  16559. */
  16560. getClassName(): string;
  16561. /**
  16562. * Serializes the particle system to a JSON object.
  16563. * @returns the JSON object
  16564. */
  16565. serialize(): any;
  16566. /**
  16567. * Parse properties from a JSON object
  16568. * @param serializationObject defines the JSON object
  16569. */
  16570. parse(serializationObject: any): void;
  16571. }
  16572. }
  16573. declare module BABYLON {
  16574. /**
  16575. * Particle emitter emitting particles from the inside of a hemisphere.
  16576. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16577. */
  16578. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16579. /**
  16580. * The radius of the emission hemisphere.
  16581. */
  16582. radius: number;
  16583. /**
  16584. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16585. */
  16586. radiusRange: number;
  16587. /**
  16588. * How much to randomize the particle direction [0-1].
  16589. */
  16590. directionRandomizer: number;
  16591. /**
  16592. * Creates a new instance HemisphericParticleEmitter
  16593. * @param radius the radius of the emission hemisphere (1 by default)
  16594. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16595. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16596. */
  16597. constructor(
  16598. /**
  16599. * The radius of the emission hemisphere.
  16600. */
  16601. radius?: number,
  16602. /**
  16603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16604. */
  16605. radiusRange?: number,
  16606. /**
  16607. * How much to randomize the particle direction [0-1].
  16608. */
  16609. directionRandomizer?: number);
  16610. /**
  16611. * Called by the particle System when the direction is computed for the created particle.
  16612. * @param worldMatrix is the world matrix of the particle system
  16613. * @param directionToUpdate is the direction vector to update with the result
  16614. * @param particle is the particle we are computed the direction for
  16615. * @param isLocal defines if the direction should be set in local space
  16616. */
  16617. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16618. /**
  16619. * Called by the particle System when the position is computed for the created particle.
  16620. * @param worldMatrix is the world matrix of the particle system
  16621. * @param positionToUpdate is the position vector to update with the result
  16622. * @param particle is the particle we are computed the position for
  16623. * @param isLocal defines if the position should be set in local space
  16624. */
  16625. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16626. /**
  16627. * Clones the current emitter and returns a copy of it
  16628. * @returns the new emitter
  16629. */
  16630. clone(): HemisphericParticleEmitter;
  16631. /**
  16632. * Called by the GPUParticleSystem to setup the update shader
  16633. * @param effect defines the update shader
  16634. */
  16635. applyToShader(effect: Effect): void;
  16636. /**
  16637. * Returns a string to use to update the GPU particles update shader
  16638. * @returns a string containng the defines string
  16639. */
  16640. getEffectDefines(): string;
  16641. /**
  16642. * Returns the string "HemisphericParticleEmitter"
  16643. * @returns a string containing the class name
  16644. */
  16645. getClassName(): string;
  16646. /**
  16647. * Serializes the particle system to a JSON object.
  16648. * @returns the JSON object
  16649. */
  16650. serialize(): any;
  16651. /**
  16652. * Parse properties from a JSON object
  16653. * @param serializationObject defines the JSON object
  16654. */
  16655. parse(serializationObject: any): void;
  16656. }
  16657. }
  16658. declare module BABYLON {
  16659. /**
  16660. * Particle emitter emitting particles from a point.
  16661. * It emits the particles randomly between 2 given directions.
  16662. */
  16663. export class PointParticleEmitter implements IParticleEmitterType {
  16664. /**
  16665. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16666. */
  16667. direction1: Vector3;
  16668. /**
  16669. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16670. */
  16671. direction2: Vector3;
  16672. /**
  16673. * Creates a new instance PointParticleEmitter
  16674. */
  16675. constructor();
  16676. /**
  16677. * Called by the particle System when the direction is computed for the created particle.
  16678. * @param worldMatrix is the world matrix of the particle system
  16679. * @param directionToUpdate is the direction vector to update with the result
  16680. * @param particle is the particle we are computed the direction for
  16681. * @param isLocal defines if the direction should be set in local space
  16682. */
  16683. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16684. /**
  16685. * Called by the particle System when the position is computed for the created particle.
  16686. * @param worldMatrix is the world matrix of the particle system
  16687. * @param positionToUpdate is the position vector to update with the result
  16688. * @param particle is the particle we are computed the position for
  16689. * @param isLocal defines if the position should be set in local space
  16690. */
  16691. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16692. /**
  16693. * Clones the current emitter and returns a copy of it
  16694. * @returns the new emitter
  16695. */
  16696. clone(): PointParticleEmitter;
  16697. /**
  16698. * Called by the GPUParticleSystem to setup the update shader
  16699. * @param effect defines the update shader
  16700. */
  16701. applyToShader(effect: Effect): void;
  16702. /**
  16703. * Returns a string to use to update the GPU particles update shader
  16704. * @returns a string containng the defines string
  16705. */
  16706. getEffectDefines(): string;
  16707. /**
  16708. * Returns the string "PointParticleEmitter"
  16709. * @returns a string containing the class name
  16710. */
  16711. getClassName(): string;
  16712. /**
  16713. * Serializes the particle system to a JSON object.
  16714. * @returns the JSON object
  16715. */
  16716. serialize(): any;
  16717. /**
  16718. * Parse properties from a JSON object
  16719. * @param serializationObject defines the JSON object
  16720. */
  16721. parse(serializationObject: any): void;
  16722. }
  16723. }
  16724. declare module BABYLON {
  16725. /**
  16726. * Particle emitter emitting particles from the inside of a sphere.
  16727. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16728. */
  16729. export class SphereParticleEmitter implements IParticleEmitterType {
  16730. /**
  16731. * The radius of the emission sphere.
  16732. */
  16733. radius: number;
  16734. /**
  16735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16736. */
  16737. radiusRange: number;
  16738. /**
  16739. * How much to randomize the particle direction [0-1].
  16740. */
  16741. directionRandomizer: number;
  16742. /**
  16743. * Creates a new instance SphereParticleEmitter
  16744. * @param radius the radius of the emission sphere (1 by default)
  16745. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16747. */
  16748. constructor(
  16749. /**
  16750. * The radius of the emission sphere.
  16751. */
  16752. radius?: number,
  16753. /**
  16754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16755. */
  16756. radiusRange?: number,
  16757. /**
  16758. * How much to randomize the particle direction [0-1].
  16759. */
  16760. directionRandomizer?: number);
  16761. /**
  16762. * Called by the particle System when the direction is computed for the created particle.
  16763. * @param worldMatrix is the world matrix of the particle system
  16764. * @param directionToUpdate is the direction vector to update with the result
  16765. * @param particle is the particle we are computed the direction for
  16766. * @param isLocal defines if the direction should be set in local space
  16767. */
  16768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16769. /**
  16770. * Called by the particle System when the position is computed for the created particle.
  16771. * @param worldMatrix is the world matrix of the particle system
  16772. * @param positionToUpdate is the position vector to update with the result
  16773. * @param particle is the particle we are computed the position for
  16774. * @param isLocal defines if the position should be set in local space
  16775. */
  16776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16777. /**
  16778. * Clones the current emitter and returns a copy of it
  16779. * @returns the new emitter
  16780. */
  16781. clone(): SphereParticleEmitter;
  16782. /**
  16783. * Called by the GPUParticleSystem to setup the update shader
  16784. * @param effect defines the update shader
  16785. */
  16786. applyToShader(effect: Effect): void;
  16787. /**
  16788. * Returns a string to use to update the GPU particles update shader
  16789. * @returns a string containng the defines string
  16790. */
  16791. getEffectDefines(): string;
  16792. /**
  16793. * Returns the string "SphereParticleEmitter"
  16794. * @returns a string containing the class name
  16795. */
  16796. getClassName(): string;
  16797. /**
  16798. * Serializes the particle system to a JSON object.
  16799. * @returns the JSON object
  16800. */
  16801. serialize(): any;
  16802. /**
  16803. * Parse properties from a JSON object
  16804. * @param serializationObject defines the JSON object
  16805. */
  16806. parse(serializationObject: any): void;
  16807. }
  16808. /**
  16809. * Particle emitter emitting particles from the inside of a sphere.
  16810. * It emits the particles randomly between two vectors.
  16811. */
  16812. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16813. /**
  16814. * The min limit of the emission direction.
  16815. */
  16816. direction1: Vector3;
  16817. /**
  16818. * The max limit of the emission direction.
  16819. */
  16820. direction2: Vector3;
  16821. /**
  16822. * Creates a new instance SphereDirectedParticleEmitter
  16823. * @param radius the radius of the emission sphere (1 by default)
  16824. * @param direction1 the min limit of the emission direction (up vector by default)
  16825. * @param direction2 the max limit of the emission direction (up vector by default)
  16826. */
  16827. constructor(radius?: number,
  16828. /**
  16829. * The min limit of the emission direction.
  16830. */
  16831. direction1?: Vector3,
  16832. /**
  16833. * The max limit of the emission direction.
  16834. */
  16835. direction2?: Vector3);
  16836. /**
  16837. * Called by the particle System when the direction is computed for the created particle.
  16838. * @param worldMatrix is the world matrix of the particle system
  16839. * @param directionToUpdate is the direction vector to update with the result
  16840. * @param particle is the particle we are computed the direction for
  16841. */
  16842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16843. /**
  16844. * Clones the current emitter and returns a copy of it
  16845. * @returns the new emitter
  16846. */
  16847. clone(): SphereDirectedParticleEmitter;
  16848. /**
  16849. * Called by the GPUParticleSystem to setup the update shader
  16850. * @param effect defines the update shader
  16851. */
  16852. applyToShader(effect: Effect): void;
  16853. /**
  16854. * Returns a string to use to update the GPU particles update shader
  16855. * @returns a string containng the defines string
  16856. */
  16857. getEffectDefines(): string;
  16858. /**
  16859. * Returns the string "SphereDirectedParticleEmitter"
  16860. * @returns a string containing the class name
  16861. */
  16862. getClassName(): string;
  16863. /**
  16864. * Serializes the particle system to a JSON object.
  16865. * @returns the JSON object
  16866. */
  16867. serialize(): any;
  16868. /**
  16869. * Parse properties from a JSON object
  16870. * @param serializationObject defines the JSON object
  16871. */
  16872. parse(serializationObject: any): void;
  16873. }
  16874. }
  16875. declare module BABYLON {
  16876. /**
  16877. * Particle emitter emitting particles from a custom list of positions.
  16878. */
  16879. export class CustomParticleEmitter implements IParticleEmitterType {
  16880. /**
  16881. * Gets or sets the position generator that will create the inital position of each particle.
  16882. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16883. */
  16884. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16885. /**
  16886. * Gets or sets the destination generator that will create the final destination of each particle.
  16887. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16888. */
  16889. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16890. /**
  16891. * Creates a new instance CustomParticleEmitter
  16892. */
  16893. constructor();
  16894. /**
  16895. * Called by the particle System when the direction is computed for the created particle.
  16896. * @param worldMatrix is the world matrix of the particle system
  16897. * @param directionToUpdate is the direction vector to update with the result
  16898. * @param particle is the particle we are computed the direction for
  16899. * @param isLocal defines if the direction should be set in local space
  16900. */
  16901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16902. /**
  16903. * Called by the particle System when the position is computed for the created particle.
  16904. * @param worldMatrix is the world matrix of the particle system
  16905. * @param positionToUpdate is the position vector to update with the result
  16906. * @param particle is the particle we are computed the position for
  16907. * @param isLocal defines if the position should be set in local space
  16908. */
  16909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16910. /**
  16911. * Clones the current emitter and returns a copy of it
  16912. * @returns the new emitter
  16913. */
  16914. clone(): CustomParticleEmitter;
  16915. /**
  16916. * Called by the GPUParticleSystem to setup the update shader
  16917. * @param effect defines the update shader
  16918. */
  16919. applyToShader(effect: Effect): void;
  16920. /**
  16921. * Returns a string to use to update the GPU particles update shader
  16922. * @returns a string containng the defines string
  16923. */
  16924. getEffectDefines(): string;
  16925. /**
  16926. * Returns the string "PointParticleEmitter"
  16927. * @returns a string containing the class name
  16928. */
  16929. getClassName(): string;
  16930. /**
  16931. * Serializes the particle system to a JSON object.
  16932. * @returns the JSON object
  16933. */
  16934. serialize(): any;
  16935. /**
  16936. * Parse properties from a JSON object
  16937. * @param serializationObject defines the JSON object
  16938. */
  16939. parse(serializationObject: any): void;
  16940. }
  16941. }
  16942. declare module BABYLON {
  16943. /**
  16944. * Particle emitter emitting particles from the inside of a box.
  16945. * It emits the particles randomly between 2 given directions.
  16946. */
  16947. export class MeshParticleEmitter implements IParticleEmitterType {
  16948. private _indices;
  16949. private _positions;
  16950. private _normals;
  16951. private _storedNormal;
  16952. private _mesh;
  16953. /**
  16954. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16955. */
  16956. direction1: Vector3;
  16957. /**
  16958. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16959. */
  16960. direction2: Vector3;
  16961. /**
  16962. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16963. */
  16964. useMeshNormalsForDirection: boolean;
  16965. /** Defines the mesh to use as source */
  16966. get mesh(): Nullable<AbstractMesh>;
  16967. set mesh(value: Nullable<AbstractMesh>);
  16968. /**
  16969. * Creates a new instance MeshParticleEmitter
  16970. * @param mesh defines the mesh to use as source
  16971. */
  16972. constructor(mesh?: Nullable<AbstractMesh>);
  16973. /**
  16974. * Called by the particle System when the direction is computed for the created particle.
  16975. * @param worldMatrix is the world matrix of the particle system
  16976. * @param directionToUpdate is the direction vector to update with the result
  16977. * @param particle is the particle we are computed the direction for
  16978. * @param isLocal defines if the direction should be set in local space
  16979. */
  16980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16981. /**
  16982. * Called by the particle System when the position is computed for the created particle.
  16983. * @param worldMatrix is the world matrix of the particle system
  16984. * @param positionToUpdate is the position vector to update with the result
  16985. * @param particle is the particle we are computed the position for
  16986. * @param isLocal defines if the position should be set in local space
  16987. */
  16988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16989. /**
  16990. * Clones the current emitter and returns a copy of it
  16991. * @returns the new emitter
  16992. */
  16993. clone(): MeshParticleEmitter;
  16994. /**
  16995. * Called by the GPUParticleSystem to setup the update shader
  16996. * @param effect defines the update shader
  16997. */
  16998. applyToShader(effect: Effect): void;
  16999. /**
  17000. * Returns a string to use to update the GPU particles update shader
  17001. * @returns a string containng the defines string
  17002. */
  17003. getEffectDefines(): string;
  17004. /**
  17005. * Returns the string "BoxParticleEmitter"
  17006. * @returns a string containing the class name
  17007. */
  17008. getClassName(): string;
  17009. /**
  17010. * Serializes the particle system to a JSON object.
  17011. * @returns the JSON object
  17012. */
  17013. serialize(): any;
  17014. /**
  17015. * Parse properties from a JSON object
  17016. * @param serializationObject defines the JSON object
  17017. * @param scene defines the hosting scene
  17018. */
  17019. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17020. }
  17021. }
  17022. declare module BABYLON {
  17023. /**
  17024. * Interface representing a particle system in Babylon.js.
  17025. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17026. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17027. */
  17028. export interface IParticleSystem {
  17029. /**
  17030. * List of animations used by the particle system.
  17031. */
  17032. animations: Animation[];
  17033. /**
  17034. * The id of the Particle system.
  17035. */
  17036. id: string;
  17037. /**
  17038. * The name of the Particle system.
  17039. */
  17040. name: string;
  17041. /**
  17042. * The emitter represents the Mesh or position we are attaching the particle system to.
  17043. */
  17044. emitter: Nullable<AbstractMesh | Vector3>;
  17045. /**
  17046. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17047. */
  17048. isBillboardBased: boolean;
  17049. /**
  17050. * The rendering group used by the Particle system to chose when to render.
  17051. */
  17052. renderingGroupId: number;
  17053. /**
  17054. * The layer mask we are rendering the particles through.
  17055. */
  17056. layerMask: number;
  17057. /**
  17058. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17059. */
  17060. updateSpeed: number;
  17061. /**
  17062. * The amount of time the particle system is running (depends of the overall update speed).
  17063. */
  17064. targetStopDuration: number;
  17065. /**
  17066. * The texture used to render each particle. (this can be a spritesheet)
  17067. */
  17068. particleTexture: Nullable<BaseTexture>;
  17069. /**
  17070. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17071. */
  17072. blendMode: number;
  17073. /**
  17074. * Minimum life time of emitting particles.
  17075. */
  17076. minLifeTime: number;
  17077. /**
  17078. * Maximum life time of emitting particles.
  17079. */
  17080. maxLifeTime: number;
  17081. /**
  17082. * Minimum Size of emitting particles.
  17083. */
  17084. minSize: number;
  17085. /**
  17086. * Maximum Size of emitting particles.
  17087. */
  17088. maxSize: number;
  17089. /**
  17090. * Minimum scale of emitting particles on X axis.
  17091. */
  17092. minScaleX: number;
  17093. /**
  17094. * Maximum scale of emitting particles on X axis.
  17095. */
  17096. maxScaleX: number;
  17097. /**
  17098. * Minimum scale of emitting particles on Y axis.
  17099. */
  17100. minScaleY: number;
  17101. /**
  17102. * Maximum scale of emitting particles on Y axis.
  17103. */
  17104. maxScaleY: number;
  17105. /**
  17106. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17107. */
  17108. color1: Color4;
  17109. /**
  17110. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17111. */
  17112. color2: Color4;
  17113. /**
  17114. * Color the particle will have at the end of its lifetime.
  17115. */
  17116. colorDead: Color4;
  17117. /**
  17118. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17119. */
  17120. emitRate: number;
  17121. /**
  17122. * You can use gravity if you want to give an orientation to your particles.
  17123. */
  17124. gravity: Vector3;
  17125. /**
  17126. * Minimum power of emitting particles.
  17127. */
  17128. minEmitPower: number;
  17129. /**
  17130. * Maximum power of emitting particles.
  17131. */
  17132. maxEmitPower: number;
  17133. /**
  17134. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17135. */
  17136. minAngularSpeed: number;
  17137. /**
  17138. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17139. */
  17140. maxAngularSpeed: number;
  17141. /**
  17142. * Gets or sets the minimal initial rotation in radians.
  17143. */
  17144. minInitialRotation: number;
  17145. /**
  17146. * Gets or sets the maximal initial rotation in radians.
  17147. */
  17148. maxInitialRotation: number;
  17149. /**
  17150. * The particle emitter type defines the emitter used by the particle system.
  17151. * It can be for example box, sphere, or cone...
  17152. */
  17153. particleEmitterType: Nullable<IParticleEmitterType>;
  17154. /**
  17155. * Defines the delay in milliseconds before starting the system (0 by default)
  17156. */
  17157. startDelay: number;
  17158. /**
  17159. * 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
  17160. */
  17161. preWarmCycles: number;
  17162. /**
  17163. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17164. */
  17165. preWarmStepOffset: number;
  17166. /**
  17167. * 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)
  17168. */
  17169. spriteCellChangeSpeed: number;
  17170. /**
  17171. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17172. */
  17173. startSpriteCellID: number;
  17174. /**
  17175. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17176. */
  17177. endSpriteCellID: number;
  17178. /**
  17179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17180. */
  17181. spriteCellWidth: number;
  17182. /**
  17183. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17184. */
  17185. spriteCellHeight: number;
  17186. /**
  17187. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17188. */
  17189. spriteRandomStartCell: boolean;
  17190. /**
  17191. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17192. */
  17193. isAnimationSheetEnabled: boolean;
  17194. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17195. translationPivot: Vector2;
  17196. /**
  17197. * Gets or sets a texture used to add random noise to particle positions
  17198. */
  17199. noiseTexture: Nullable<BaseTexture>;
  17200. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17201. noiseStrength: Vector3;
  17202. /**
  17203. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17204. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17205. */
  17206. billboardMode: number;
  17207. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17208. limitVelocityDamping: number;
  17209. /**
  17210. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17211. */
  17212. beginAnimationOnStart: boolean;
  17213. /**
  17214. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17215. */
  17216. beginAnimationFrom: number;
  17217. /**
  17218. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17219. */
  17220. beginAnimationTo: number;
  17221. /**
  17222. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17223. */
  17224. beginAnimationLoop: boolean;
  17225. /**
  17226. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17227. */
  17228. disposeOnStop: boolean;
  17229. /**
  17230. * Specifies if the particles are updated in emitter local space or world space
  17231. */
  17232. isLocal: boolean;
  17233. /** Snippet ID if the particle system was created from the snippet server */
  17234. snippetId: string;
  17235. /** Gets or sets a matrix to use to compute projection */
  17236. defaultProjectionMatrix: Matrix;
  17237. /**
  17238. * Gets the maximum number of particles active at the same time.
  17239. * @returns The max number of active particles.
  17240. */
  17241. getCapacity(): number;
  17242. /**
  17243. * Gets the number of particles active at the same time.
  17244. * @returns The number of active particles.
  17245. */
  17246. getActiveCount(): number;
  17247. /**
  17248. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17249. * @returns True if it has been started, otherwise false.
  17250. */
  17251. isStarted(): boolean;
  17252. /**
  17253. * Animates the particle system for this frame.
  17254. */
  17255. animate(): void;
  17256. /**
  17257. * Renders the particle system in its current state.
  17258. * @returns the current number of particles
  17259. */
  17260. render(): number;
  17261. /**
  17262. * Dispose the particle system and frees its associated resources.
  17263. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17264. */
  17265. dispose(disposeTexture?: boolean): void;
  17266. /**
  17267. * An event triggered when the system is disposed
  17268. */
  17269. onDisposeObservable: Observable<IParticleSystem>;
  17270. /**
  17271. * An event triggered when the system is stopped
  17272. */
  17273. onStoppedObservable: Observable<IParticleSystem>;
  17274. /**
  17275. * Clones the particle system.
  17276. * @param name The name of the cloned object
  17277. * @param newEmitter The new emitter to use
  17278. * @returns the cloned particle system
  17279. */
  17280. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17281. /**
  17282. * Serializes the particle system to a JSON object
  17283. * @param serializeTexture defines if the texture must be serialized as well
  17284. * @returns the JSON object
  17285. */
  17286. serialize(serializeTexture: boolean): any;
  17287. /**
  17288. * Rebuild the particle system
  17289. */
  17290. rebuild(): void;
  17291. /** Force the system to rebuild all gradients that need to be resync */
  17292. forceRefreshGradients(): void;
  17293. /**
  17294. * Starts the particle system and begins to emit
  17295. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17296. */
  17297. start(delay?: number): void;
  17298. /**
  17299. * Stops the particle system.
  17300. */
  17301. stop(): void;
  17302. /**
  17303. * Remove all active particles
  17304. */
  17305. reset(): void;
  17306. /**
  17307. * Gets a boolean indicating that the system is stopping
  17308. * @returns true if the system is currently stopping
  17309. */
  17310. isStopping(): boolean;
  17311. /**
  17312. * Is this system ready to be used/rendered
  17313. * @return true if the system is ready
  17314. */
  17315. isReady(): boolean;
  17316. /**
  17317. * Returns the string "ParticleSystem"
  17318. * @returns a string containing the class name
  17319. */
  17320. getClassName(): string;
  17321. /**
  17322. * Gets the custom effect used to render the particles
  17323. * @param blendMode Blend mode for which the effect should be retrieved
  17324. * @returns The effect
  17325. */
  17326. getCustomEffect(blendMode: number): Nullable<Effect>;
  17327. /**
  17328. * Sets the custom effect used to render the particles
  17329. * @param effect The effect to set
  17330. * @param blendMode Blend mode for which the effect should be set
  17331. */
  17332. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17333. /**
  17334. * Fill the defines array according to the current settings of the particle system
  17335. * @param defines Array to be updated
  17336. * @param blendMode blend mode to take into account when updating the array
  17337. */
  17338. fillDefines(defines: Array<string>, blendMode: number): void;
  17339. /**
  17340. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17341. * @param uniforms Uniforms array to fill
  17342. * @param attributes Attributes array to fill
  17343. * @param samplers Samplers array to fill
  17344. */
  17345. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17346. /**
  17347. * Observable that will be called just before the particles are drawn
  17348. */
  17349. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17350. /**
  17351. * Gets the name of the particle vertex shader
  17352. */
  17353. vertexShaderName: string;
  17354. /**
  17355. * Adds a new color gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param color1 defines the color to affect to the specified gradient
  17358. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17359. * @returns the current particle system
  17360. */
  17361. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17362. /**
  17363. * Remove a specific color gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeColorGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Adds a new size gradient
  17370. * @param gradient defines the gradient to use (between 0 and 1)
  17371. * @param factor defines the size factor to affect to the specified gradient
  17372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17373. * @returns the current particle system
  17374. */
  17375. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17376. /**
  17377. * Remove a specific size gradient
  17378. * @param gradient defines the gradient to remove
  17379. * @returns the current particle system
  17380. */
  17381. removeSizeGradient(gradient: number): IParticleSystem;
  17382. /**
  17383. * Gets the current list of color gradients.
  17384. * You must use addColorGradient and removeColorGradient to udpate this list
  17385. * @returns the list of color gradients
  17386. */
  17387. getColorGradients(): Nullable<Array<ColorGradient>>;
  17388. /**
  17389. * Gets the current list of size gradients.
  17390. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17391. * @returns the list of size gradients
  17392. */
  17393. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17394. /**
  17395. * Gets the current list of angular speed gradients.
  17396. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17397. * @returns the list of angular speed gradients
  17398. */
  17399. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17400. /**
  17401. * Adds a new angular speed gradient
  17402. * @param gradient defines the gradient to use (between 0 and 1)
  17403. * @param factor defines the angular speed to affect to the specified gradient
  17404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17405. * @returns the current particle system
  17406. */
  17407. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17408. /**
  17409. * Remove a specific angular speed gradient
  17410. * @param gradient defines the gradient to remove
  17411. * @returns the current particle system
  17412. */
  17413. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17414. /**
  17415. * Gets the current list of velocity gradients.
  17416. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17417. * @returns the list of velocity gradients
  17418. */
  17419. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17420. /**
  17421. * Adds a new velocity gradient
  17422. * @param gradient defines the gradient to use (between 0 and 1)
  17423. * @param factor defines the velocity to affect to the specified gradient
  17424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17425. * @returns the current particle system
  17426. */
  17427. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17428. /**
  17429. * Remove a specific velocity gradient
  17430. * @param gradient defines the gradient to remove
  17431. * @returns the current particle system
  17432. */
  17433. removeVelocityGradient(gradient: number): IParticleSystem;
  17434. /**
  17435. * Gets the current list of limit velocity gradients.
  17436. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17437. * @returns the list of limit velocity gradients
  17438. */
  17439. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17440. /**
  17441. * Adds a new limit velocity gradient
  17442. * @param gradient defines the gradient to use (between 0 and 1)
  17443. * @param factor defines the limit velocity 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17448. /**
  17449. * Remove a specific limit velocity gradient
  17450. * @param gradient defines the gradient to remove
  17451. * @returns the current particle system
  17452. */
  17453. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17454. /**
  17455. * Adds a new drag gradient
  17456. * @param gradient defines the gradient to use (between 0 and 1)
  17457. * @param factor defines the drag to affect to the specified gradient
  17458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17459. * @returns the current particle system
  17460. */
  17461. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17462. /**
  17463. * Remove a specific drag gradient
  17464. * @param gradient defines the gradient to remove
  17465. * @returns the current particle system
  17466. */
  17467. removeDragGradient(gradient: number): IParticleSystem;
  17468. /**
  17469. * Gets the current list of drag gradients.
  17470. * You must use addDragGradient and removeDragGradient to udpate this list
  17471. * @returns the list of drag gradients
  17472. */
  17473. getDragGradients(): Nullable<Array<FactorGradient>>;
  17474. /**
  17475. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17476. * @param gradient defines the gradient to use (between 0 and 1)
  17477. * @param factor defines the emit rate to affect to the specified gradient
  17478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17479. * @returns the current particle system
  17480. */
  17481. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17482. /**
  17483. * Remove a specific emit rate gradient
  17484. * @param gradient defines the gradient to remove
  17485. * @returns the current particle system
  17486. */
  17487. removeEmitRateGradient(gradient: number): IParticleSystem;
  17488. /**
  17489. * Gets the current list of emit rate gradients.
  17490. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17491. * @returns the list of emit rate gradients
  17492. */
  17493. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17494. /**
  17495. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17496. * @param gradient defines the gradient to use (between 0 and 1)
  17497. * @param factor defines the start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17502. /**
  17503. * Remove a specific start size gradient
  17504. * @param gradient defines the gradient to remove
  17505. * @returns the current particle system
  17506. */
  17507. removeStartSizeGradient(gradient: number): IParticleSystem;
  17508. /**
  17509. * Gets the current list of start size gradients.
  17510. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17511. * @returns the list of start size gradients
  17512. */
  17513. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17514. /**
  17515. * Adds a new life time gradient
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17522. /**
  17523. * Remove a specific life time gradient
  17524. * @param gradient defines the gradient to remove
  17525. * @returns the current particle system
  17526. */
  17527. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17528. /**
  17529. * Gets the current list of life time gradients.
  17530. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17531. * @returns the list of life time gradients
  17532. */
  17533. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17534. /**
  17535. * Gets the current list of color gradients.
  17536. * You must use addColorGradient and removeColorGradient to udpate this list
  17537. * @returns the list of color gradients
  17538. */
  17539. getColorGradients(): Nullable<Array<ColorGradient>>;
  17540. /**
  17541. * Adds a new ramp gradient used to remap particle colors
  17542. * @param gradient defines the gradient to use (between 0 and 1)
  17543. * @param color defines the color to affect to the specified gradient
  17544. * @returns the current particle system
  17545. */
  17546. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17547. /**
  17548. * Gets the current list of ramp gradients.
  17549. * You must use addRampGradient and removeRampGradient to udpate this list
  17550. * @returns the list of ramp gradients
  17551. */
  17552. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17553. /** Gets or sets a boolean indicating that ramp gradients must be used
  17554. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17555. */
  17556. useRampGradients: boolean;
  17557. /**
  17558. * Adds a new color remap gradient
  17559. * @param gradient defines the gradient to use (between 0 and 1)
  17560. * @param min defines the color remap minimal range
  17561. * @param max defines the color remap maximal range
  17562. * @returns the current particle system
  17563. */
  17564. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17565. /**
  17566. * Gets the current list of color remap gradients.
  17567. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17568. * @returns the list of color remap gradients
  17569. */
  17570. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17571. /**
  17572. * Adds a new alpha remap gradient
  17573. * @param gradient defines the gradient to use (between 0 and 1)
  17574. * @param min defines the alpha remap minimal range
  17575. * @param max defines the alpha remap maximal range
  17576. * @returns the current particle system
  17577. */
  17578. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17579. /**
  17580. * Gets the current list of alpha remap gradients.
  17581. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17582. * @returns the list of alpha remap gradients
  17583. */
  17584. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17585. /**
  17586. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17589. * @returns the emitter
  17590. */
  17591. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17592. /**
  17593. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17594. * @param radius The radius of the hemisphere to emit from
  17595. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17596. * @returns the emitter
  17597. */
  17598. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17599. /**
  17600. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17601. * @param radius The radius of the sphere to emit from
  17602. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17603. * @returns the emitter
  17604. */
  17605. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17606. /**
  17607. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17608. * @param radius The radius of the sphere to emit from
  17609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17611. * @returns the emitter
  17612. */
  17613. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17614. /**
  17615. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17616. * @param radius The radius of the emission cylinder
  17617. * @param height The height of the emission cylinder
  17618. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17619. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17620. * @returns the emitter
  17621. */
  17622. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17623. /**
  17624. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17625. * @param radius The radius of the cylinder to emit from
  17626. * @param height The height of the emission cylinder
  17627. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17630. * @returns the emitter
  17631. */
  17632. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17633. /**
  17634. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17635. * @param radius The radius of the cone to emit from
  17636. * @param angle The base angle of the cone
  17637. * @returns the emitter
  17638. */
  17639. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17640. /**
  17641. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17644. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17645. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17646. * @returns the emitter
  17647. */
  17648. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17649. /**
  17650. * Get hosting scene
  17651. * @returns the scene
  17652. */
  17653. getScene(): Nullable<Scene>;
  17654. }
  17655. }
  17656. declare module BABYLON {
  17657. /**
  17658. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17659. */
  17660. export class ColorSplitterBlock extends NodeMaterialBlock {
  17661. /**
  17662. * Create a new ColorSplitterBlock
  17663. * @param name defines the block name
  17664. */
  17665. constructor(name: string);
  17666. /**
  17667. * Gets the current class name
  17668. * @returns the class name
  17669. */
  17670. getClassName(): string;
  17671. /**
  17672. * Gets the rgba component (input)
  17673. */
  17674. get rgba(): NodeMaterialConnectionPoint;
  17675. /**
  17676. * Gets the rgb component (input)
  17677. */
  17678. get rgbIn(): NodeMaterialConnectionPoint;
  17679. /**
  17680. * Gets the rgb component (output)
  17681. */
  17682. get rgbOut(): NodeMaterialConnectionPoint;
  17683. /**
  17684. * Gets the r component (output)
  17685. */
  17686. get r(): NodeMaterialConnectionPoint;
  17687. /**
  17688. * Gets the g component (output)
  17689. */
  17690. get g(): NodeMaterialConnectionPoint;
  17691. /**
  17692. * Gets the b component (output)
  17693. */
  17694. get b(): NodeMaterialConnectionPoint;
  17695. /**
  17696. * Gets the a component (output)
  17697. */
  17698. get a(): NodeMaterialConnectionPoint;
  17699. protected _inputRename(name: string): string;
  17700. protected _outputRename(name: string): string;
  17701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17702. }
  17703. }
  17704. declare module BABYLON {
  17705. /**
  17706. * Operations supported by the Trigonometry block
  17707. */
  17708. export enum TrigonometryBlockOperations {
  17709. /** Cos */
  17710. Cos = 0,
  17711. /** Sin */
  17712. Sin = 1,
  17713. /** Abs */
  17714. Abs = 2,
  17715. /** Exp */
  17716. Exp = 3,
  17717. /** Exp2 */
  17718. Exp2 = 4,
  17719. /** Round */
  17720. Round = 5,
  17721. /** Floor */
  17722. Floor = 6,
  17723. /** Ceiling */
  17724. Ceiling = 7,
  17725. /** Square root */
  17726. Sqrt = 8,
  17727. /** Log */
  17728. Log = 9,
  17729. /** Tangent */
  17730. Tan = 10,
  17731. /** Arc tangent */
  17732. ArcTan = 11,
  17733. /** Arc cosinus */
  17734. ArcCos = 12,
  17735. /** Arc sinus */
  17736. ArcSin = 13,
  17737. /** Fraction */
  17738. Fract = 14,
  17739. /** Sign */
  17740. Sign = 15,
  17741. /** To radians (from degrees) */
  17742. Radians = 16,
  17743. /** To degrees (from radians) */
  17744. Degrees = 17
  17745. }
  17746. /**
  17747. * Block used to apply trigonometry operation to floats
  17748. */
  17749. export class TrigonometryBlock extends NodeMaterialBlock {
  17750. /**
  17751. * Gets or sets the operation applied by the block
  17752. */
  17753. operation: TrigonometryBlockOperations;
  17754. /**
  17755. * Creates a new TrigonometryBlock
  17756. * @param name defines the block name
  17757. */
  17758. constructor(name: string);
  17759. /**
  17760. * Gets the current class name
  17761. * @returns the class name
  17762. */
  17763. getClassName(): string;
  17764. /**
  17765. * Gets the input component
  17766. */
  17767. get input(): NodeMaterialConnectionPoint;
  17768. /**
  17769. * Gets the output component
  17770. */
  17771. get output(): NodeMaterialConnectionPoint;
  17772. protected _buildBlock(state: NodeMaterialBuildState): this;
  17773. serialize(): any;
  17774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17775. protected _dumpPropertiesCode(): string;
  17776. }
  17777. }
  17778. declare module BABYLON {
  17779. /**
  17780. * Interface used to configure the node material editor
  17781. */
  17782. export interface INodeMaterialEditorOptions {
  17783. /** Define the URl to load node editor script */
  17784. editorURL?: string;
  17785. }
  17786. /** @hidden */
  17787. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17788. NORMAL: boolean;
  17789. TANGENT: boolean;
  17790. UV1: boolean;
  17791. /** BONES */
  17792. NUM_BONE_INFLUENCERS: number;
  17793. BonesPerMesh: number;
  17794. BONETEXTURE: boolean;
  17795. /** MORPH TARGETS */
  17796. MORPHTARGETS: boolean;
  17797. MORPHTARGETS_NORMAL: boolean;
  17798. MORPHTARGETS_TANGENT: boolean;
  17799. MORPHTARGETS_UV: boolean;
  17800. NUM_MORPH_INFLUENCERS: number;
  17801. /** IMAGE PROCESSING */
  17802. IMAGEPROCESSING: boolean;
  17803. VIGNETTE: boolean;
  17804. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17805. VIGNETTEBLENDMODEOPAQUE: boolean;
  17806. TONEMAPPING: boolean;
  17807. TONEMAPPING_ACES: boolean;
  17808. CONTRAST: boolean;
  17809. EXPOSURE: boolean;
  17810. COLORCURVES: boolean;
  17811. COLORGRADING: boolean;
  17812. COLORGRADING3D: boolean;
  17813. SAMPLER3DGREENDEPTH: boolean;
  17814. SAMPLER3DBGRMAP: boolean;
  17815. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17816. /** MISC. */
  17817. BUMPDIRECTUV: number;
  17818. constructor();
  17819. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17820. }
  17821. /**
  17822. * Class used to configure NodeMaterial
  17823. */
  17824. export interface INodeMaterialOptions {
  17825. /**
  17826. * Defines if blocks should emit comments
  17827. */
  17828. emitComments: boolean;
  17829. }
  17830. /**
  17831. * Class used to create a node based material built by assembling shader blocks
  17832. */
  17833. export class NodeMaterial extends PushMaterial {
  17834. private static _BuildIdGenerator;
  17835. private _options;
  17836. private _vertexCompilationState;
  17837. private _fragmentCompilationState;
  17838. private _sharedData;
  17839. private _buildId;
  17840. private _buildWasSuccessful;
  17841. private _cachedWorldViewMatrix;
  17842. private _cachedWorldViewProjectionMatrix;
  17843. private _optimizers;
  17844. private _animationFrame;
  17845. /** Define the Url to load node editor script */
  17846. static EditorURL: string;
  17847. /** Define the Url to load snippets */
  17848. static SnippetUrl: string;
  17849. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17850. static IgnoreTexturesAtLoadTime: boolean;
  17851. private BJSNODEMATERIALEDITOR;
  17852. /** Get the inspector from bundle or global */
  17853. private _getGlobalNodeMaterialEditor;
  17854. /**
  17855. * Snippet ID if the material was created from the snippet server
  17856. */
  17857. snippetId: string;
  17858. /**
  17859. * Gets or sets data used by visual editor
  17860. * @see https://nme.babylonjs.com
  17861. */
  17862. editorData: any;
  17863. /**
  17864. * 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)
  17865. */
  17866. ignoreAlpha: boolean;
  17867. /**
  17868. * Defines the maximum number of lights that can be used in the material
  17869. */
  17870. maxSimultaneousLights: number;
  17871. /**
  17872. * Observable raised when the material is built
  17873. */
  17874. onBuildObservable: Observable<NodeMaterial>;
  17875. /**
  17876. * Gets or sets the root nodes of the material vertex shader
  17877. */
  17878. _vertexOutputNodes: NodeMaterialBlock[];
  17879. /**
  17880. * Gets or sets the root nodes of the material fragment (pixel) shader
  17881. */
  17882. _fragmentOutputNodes: NodeMaterialBlock[];
  17883. /** Gets or sets options to control the node material overall behavior */
  17884. get options(): INodeMaterialOptions;
  17885. set options(options: INodeMaterialOptions);
  17886. /**
  17887. * Default configuration related to image processing available in the standard Material.
  17888. */
  17889. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17890. /**
  17891. * Gets the image processing configuration used either in this material.
  17892. */
  17893. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17894. /**
  17895. * Sets the Default image processing configuration used either in the this material.
  17896. *
  17897. * If sets to null, the scene one is in use.
  17898. */
  17899. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17900. /**
  17901. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17902. */
  17903. attachedBlocks: NodeMaterialBlock[];
  17904. /**
  17905. * Specifies the mode of the node material
  17906. * @hidden
  17907. */
  17908. _mode: NodeMaterialModes;
  17909. /**
  17910. * Gets the mode property
  17911. */
  17912. get mode(): NodeMaterialModes;
  17913. /**
  17914. * A free comment about the material
  17915. */
  17916. comment: string;
  17917. /**
  17918. * Create a new node based material
  17919. * @param name defines the material name
  17920. * @param scene defines the hosting scene
  17921. * @param options defines creation option
  17922. */
  17923. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17924. /**
  17925. * Gets the current class name of the material e.g. "NodeMaterial"
  17926. * @returns the class name
  17927. */
  17928. getClassName(): string;
  17929. /**
  17930. * Keep track of the image processing observer to allow dispose and replace.
  17931. */
  17932. private _imageProcessingObserver;
  17933. /**
  17934. * Attaches a new image processing configuration to the Standard Material.
  17935. * @param configuration
  17936. */
  17937. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17938. /**
  17939. * Get a block by its name
  17940. * @param name defines the name of the block to retrieve
  17941. * @returns the required block or null if not found
  17942. */
  17943. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17944. /**
  17945. * Get a block by its name
  17946. * @param predicate defines the predicate used to find the good candidate
  17947. * @returns the required block or null if not found
  17948. */
  17949. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17950. /**
  17951. * Get an input block by its name
  17952. * @param predicate defines the predicate used to find the good candidate
  17953. * @returns the required input block or null if not found
  17954. */
  17955. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17956. /**
  17957. * Gets the list of input blocks attached to this material
  17958. * @returns an array of InputBlocks
  17959. */
  17960. getInputBlocks(): InputBlock[];
  17961. /**
  17962. * Adds a new optimizer to the list of optimizers
  17963. * @param optimizer defines the optimizers to add
  17964. * @returns the current material
  17965. */
  17966. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17967. /**
  17968. * Remove an optimizer from the list of optimizers
  17969. * @param optimizer defines the optimizers to remove
  17970. * @returns the current material
  17971. */
  17972. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17973. /**
  17974. * Add a new block to the list of output nodes
  17975. * @param node defines the node to add
  17976. * @returns the current material
  17977. */
  17978. addOutputNode(node: NodeMaterialBlock): this;
  17979. /**
  17980. * Remove a block from the list of root nodes
  17981. * @param node defines the node to remove
  17982. * @returns the current material
  17983. */
  17984. removeOutputNode(node: NodeMaterialBlock): this;
  17985. private _addVertexOutputNode;
  17986. private _removeVertexOutputNode;
  17987. private _addFragmentOutputNode;
  17988. private _removeFragmentOutputNode;
  17989. /**
  17990. * Specifies if the material will require alpha blending
  17991. * @returns a boolean specifying if alpha blending is needed
  17992. */
  17993. needAlphaBlending(): boolean;
  17994. /**
  17995. * Specifies if this material should be rendered in alpha test mode
  17996. * @returns a boolean specifying if an alpha test is needed.
  17997. */
  17998. needAlphaTesting(): boolean;
  17999. private _initializeBlock;
  18000. private _resetDualBlocks;
  18001. /**
  18002. * Remove a block from the current node material
  18003. * @param block defines the block to remove
  18004. */
  18005. removeBlock(block: NodeMaterialBlock): void;
  18006. /**
  18007. * Build the material and generates the inner effect
  18008. * @param verbose defines if the build should log activity
  18009. */
  18010. build(verbose?: boolean): void;
  18011. /**
  18012. * Runs an otpimization phase to try to improve the shader code
  18013. */
  18014. optimize(): void;
  18015. private _prepareDefinesForAttributes;
  18016. /**
  18017. * Create a post process from the material
  18018. * @param camera The camera to apply the render pass to.
  18019. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18021. * @param engine The engine which the post process will be applied. (default: current engine)
  18022. * @param reusable If the post process can be reused on the same frame. (default: false)
  18023. * @param textureType Type of textures used when performing the post process. (default: 0)
  18024. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18025. * @returns the post process created
  18026. */
  18027. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18028. /**
  18029. * Create the post process effect from the material
  18030. * @param postProcess The post process to create the effect for
  18031. */
  18032. createEffectForPostProcess(postProcess: PostProcess): void;
  18033. private _createEffectForPostProcess;
  18034. /**
  18035. * Create a new procedural texture based on this node material
  18036. * @param size defines the size of the texture
  18037. * @param scene defines the hosting scene
  18038. * @returns the new procedural texture attached to this node material
  18039. */
  18040. createProceduralTexture(size: number | {
  18041. width: number;
  18042. height: number;
  18043. layers?: number;
  18044. }, scene: Scene): Nullable<ProceduralTexture>;
  18045. private _createEffectForParticles;
  18046. private _checkInternals;
  18047. /**
  18048. * Create the effect to be used as the custom effect for a particle system
  18049. * @param particleSystem Particle system to create the effect for
  18050. * @param onCompiled defines a function to call when the effect creation is successful
  18051. * @param onError defines a function to call when the effect creation has failed
  18052. */
  18053. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18054. private _processDefines;
  18055. /**
  18056. * Get if the submesh is ready to be used and all its information available.
  18057. * Child classes can use it to update shaders
  18058. * @param mesh defines the mesh to check
  18059. * @param subMesh defines which submesh to check
  18060. * @param useInstances specifies that instances should be used
  18061. * @returns a boolean indicating that the submesh is ready or not
  18062. */
  18063. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18064. /**
  18065. * Get a string representing the shaders built by the current node graph
  18066. */
  18067. get compiledShaders(): string;
  18068. /**
  18069. * Binds the world matrix to the material
  18070. * @param world defines the world transformation matrix
  18071. */
  18072. bindOnlyWorldMatrix(world: Matrix): void;
  18073. /**
  18074. * Binds the submesh to this material by preparing the effect and shader to draw
  18075. * @param world defines the world transformation matrix
  18076. * @param mesh defines the mesh containing the submesh
  18077. * @param subMesh defines the submesh to bind the material to
  18078. */
  18079. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18080. /**
  18081. * Gets the active textures from the material
  18082. * @returns an array of textures
  18083. */
  18084. getActiveTextures(): BaseTexture[];
  18085. /**
  18086. * Gets the list of texture blocks
  18087. * @returns an array of texture blocks
  18088. */
  18089. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18090. /**
  18091. * Specifies if the material uses a texture
  18092. * @param texture defines the texture to check against the material
  18093. * @returns a boolean specifying if the material uses the texture
  18094. */
  18095. hasTexture(texture: BaseTexture): boolean;
  18096. /**
  18097. * Disposes the material
  18098. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18099. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18100. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18101. */
  18102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18103. /** Creates the node editor window. */
  18104. private _createNodeEditor;
  18105. /**
  18106. * Launch the node material editor
  18107. * @param config Define the configuration of the editor
  18108. * @return a promise fulfilled when the node editor is visible
  18109. */
  18110. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18111. /**
  18112. * Clear the current material
  18113. */
  18114. clear(): void;
  18115. /**
  18116. * Clear the current material and set it to a default state
  18117. */
  18118. setToDefault(): void;
  18119. /**
  18120. * Clear the current material and set it to a default state for post process
  18121. */
  18122. setToDefaultPostProcess(): void;
  18123. /**
  18124. * Clear the current material and set it to a default state for procedural texture
  18125. */
  18126. setToDefaultProceduralTexture(): void;
  18127. /**
  18128. * Clear the current material and set it to a default state for particle
  18129. */
  18130. setToDefaultParticle(): void;
  18131. /**
  18132. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18133. * @param url defines the url to load from
  18134. * @returns a promise that will fullfil when the material is fully loaded
  18135. */
  18136. loadAsync(url: string): Promise<void>;
  18137. private _gatherBlocks;
  18138. /**
  18139. * Generate a string containing the code declaration required to create an equivalent of this material
  18140. * @returns a string
  18141. */
  18142. generateCode(): string;
  18143. /**
  18144. * Serializes this material in a JSON representation
  18145. * @returns the serialized material object
  18146. */
  18147. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18148. private _restoreConnections;
  18149. /**
  18150. * Clear the current graph and load a new one from a serialization object
  18151. * @param source defines the JSON representation of the material
  18152. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18153. * @param merge defines whether or not the source must be merged or replace the current content
  18154. */
  18155. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18156. /**
  18157. * Makes a duplicate of the current material.
  18158. * @param name - name to use for the new material.
  18159. */
  18160. clone(name: string): NodeMaterial;
  18161. /**
  18162. * Creates a node material from parsed material data
  18163. * @param source defines the JSON representation of the material
  18164. * @param scene defines the hosting scene
  18165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18166. * @returns a new node material
  18167. */
  18168. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18169. /**
  18170. * Creates a node material from a snippet saved in a remote file
  18171. * @param name defines the name of the material to create
  18172. * @param url defines the url to load from
  18173. * @param scene defines the hosting scene
  18174. * @returns a promise that will resolve to the new node material
  18175. */
  18176. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18177. /**
  18178. * Creates a node material from a snippet saved by the node material editor
  18179. * @param snippetId defines the snippet to load
  18180. * @param scene defines the hosting scene
  18181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18182. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18183. * @returns a promise that will resolve to the new node material
  18184. */
  18185. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18186. /**
  18187. * Creates a new node material set to default basic configuration
  18188. * @param name defines the name of the material
  18189. * @param scene defines the hosting scene
  18190. * @returns a new NodeMaterial
  18191. */
  18192. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18193. }
  18194. }
  18195. declare module BABYLON {
  18196. interface ThinEngine {
  18197. /**
  18198. * Unbind a list of render target textures from the webGL context
  18199. * This is used only when drawBuffer extension or webGL2 are active
  18200. * @param textures defines the render target textures to unbind
  18201. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18202. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18203. */
  18204. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18205. /**
  18206. * Create a multi render target texture
  18207. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18208. * @param size defines the size of the texture
  18209. * @param options defines the creation options
  18210. * @returns the cube texture as an InternalTexture
  18211. */
  18212. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18213. /**
  18214. * Update the sample count for a given multiple render target texture
  18215. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18216. * @param textures defines the textures to update
  18217. * @param samples defines the sample count to set
  18218. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18219. */
  18220. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18221. /**
  18222. * Select a subsets of attachments to draw to.
  18223. * @param attachments gl attachments
  18224. */
  18225. bindAttachments(attachments: number[]): void;
  18226. /**
  18227. * Creates a layout object to draw/clear on specific textures in a MRT
  18228. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18229. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18230. */
  18231. buildTextureLayout(textureStatus: boolean[]): number[];
  18232. /**
  18233. * Restores the webgl state to only draw on the main color attachment
  18234. */
  18235. restoreSingleAttachment(): void;
  18236. /**
  18237. * Clears a list of attachments
  18238. * @param attachments list of the attachments
  18239. * @param colorMain clear color for the main attachment (the first one)
  18240. * @param colorOthers clear color for the other attachments
  18241. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18242. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18243. */
  18244. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18245. }
  18246. }
  18247. declare module BABYLON {
  18248. /**
  18249. * Creation options of the multi render target texture.
  18250. */
  18251. export interface IMultiRenderTargetOptions {
  18252. /**
  18253. * Define if the texture needs to create mip maps after render.
  18254. */
  18255. generateMipMaps?: boolean;
  18256. /**
  18257. * Define the types of all the draw buffers we want to create
  18258. */
  18259. types?: number[];
  18260. /**
  18261. * Define the sampling modes of all the draw buffers we want to create
  18262. */
  18263. samplingModes?: number[];
  18264. /**
  18265. * Define if a depth buffer is required
  18266. */
  18267. generateDepthBuffer?: boolean;
  18268. /**
  18269. * Define if a stencil buffer is required
  18270. */
  18271. generateStencilBuffer?: boolean;
  18272. /**
  18273. * Define if a depth texture is required instead of a depth buffer
  18274. */
  18275. generateDepthTexture?: boolean;
  18276. /**
  18277. * Define the number of desired draw buffers
  18278. */
  18279. textureCount?: number;
  18280. /**
  18281. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18282. */
  18283. doNotChangeAspectRatio?: boolean;
  18284. /**
  18285. * Define the default type of the buffers we are creating
  18286. */
  18287. defaultType?: number;
  18288. }
  18289. /**
  18290. * A multi render target, like a render target provides the ability to render to a texture.
  18291. * Unlike the render target, it can render to several draw buffers in one draw.
  18292. * This is specially interesting in deferred rendering or for any effects requiring more than
  18293. * just one color from a single pass.
  18294. */
  18295. export class MultiRenderTarget extends RenderTargetTexture {
  18296. private _internalTextures;
  18297. private _textures;
  18298. private _multiRenderTargetOptions;
  18299. private _count;
  18300. /**
  18301. * Get if draw buffers are currently supported by the used hardware and browser.
  18302. */
  18303. get isSupported(): boolean;
  18304. /**
  18305. * Get the list of textures generated by the multi render target.
  18306. */
  18307. get textures(): Texture[];
  18308. /**
  18309. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18310. */
  18311. get count(): number;
  18312. /**
  18313. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18314. */
  18315. get depthTexture(): Texture;
  18316. /**
  18317. * Set the wrapping mode on U of all the textures we are rendering to.
  18318. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18319. */
  18320. set wrapU(wrap: number);
  18321. /**
  18322. * Set the wrapping mode on V of all the textures we are rendering to.
  18323. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18324. */
  18325. set wrapV(wrap: number);
  18326. /**
  18327. * Instantiate a new multi render target texture.
  18328. * A multi render target, like a render target provides the ability to render to a texture.
  18329. * Unlike the render target, it can render to several draw buffers in one draw.
  18330. * This is specially interesting in deferred rendering or for any effects requiring more than
  18331. * just one color from a single pass.
  18332. * @param name Define the name of the texture
  18333. * @param size Define the size of the buffers to render to
  18334. * @param count Define the number of target we are rendering into
  18335. * @param scene Define the scene the texture belongs to
  18336. * @param options Define the options used to create the multi render target
  18337. */
  18338. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18339. private _initTypes;
  18340. /** @hidden */
  18341. _rebuild(forceFullRebuild?: boolean): void;
  18342. private _createInternalTextures;
  18343. private _createTextures;
  18344. /**
  18345. * Replaces a texture within the MRT.
  18346. * @param texture The new texture to insert in the MRT
  18347. * @param index The index of the texture to replace
  18348. */
  18349. replaceTexture(texture: Texture, index: number): void;
  18350. /**
  18351. * Define the number of samples used if MSAA is enabled.
  18352. */
  18353. get samples(): number;
  18354. set samples(value: number);
  18355. /**
  18356. * Resize all the textures in the multi render target.
  18357. * Be careful as it will recreate all the data in the new texture.
  18358. * @param size Define the new size
  18359. */
  18360. resize(size: any): void;
  18361. /**
  18362. * Changes the number of render targets in this MRT
  18363. * Be careful as it will recreate all the data in the new texture.
  18364. * @param count new texture count
  18365. * @param options Specifies texture types and sampling modes for new textures
  18366. */
  18367. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18368. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18369. /**
  18370. * Dispose the render targets and their associated resources
  18371. */
  18372. dispose(): void;
  18373. /**
  18374. * Release all the underlying texture used as draw buffers.
  18375. */
  18376. releaseInternalTextures(): void;
  18377. }
  18378. }
  18379. declare module BABYLON {
  18380. /** @hidden */
  18381. export var imageProcessingPixelShader: {
  18382. name: string;
  18383. shader: string;
  18384. };
  18385. }
  18386. declare module BABYLON {
  18387. /**
  18388. * ImageProcessingPostProcess
  18389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18390. */
  18391. export class ImageProcessingPostProcess extends PostProcess {
  18392. /**
  18393. * Default configuration related to image processing available in the PBR Material.
  18394. */
  18395. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18396. /**
  18397. * Gets the image processing configuration used either in this material.
  18398. */
  18399. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18400. /**
  18401. * Sets the Default image processing configuration used either in the this material.
  18402. *
  18403. * If sets to null, the scene one is in use.
  18404. */
  18405. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18406. /**
  18407. * Keep track of the image processing observer to allow dispose and replace.
  18408. */
  18409. private _imageProcessingObserver;
  18410. /**
  18411. * Attaches a new image processing configuration to the PBR Material.
  18412. * @param configuration
  18413. */
  18414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18415. /**
  18416. * If the post process is supported.
  18417. */
  18418. get isSupported(): boolean;
  18419. /**
  18420. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18421. */
  18422. get colorCurves(): Nullable<ColorCurves>;
  18423. /**
  18424. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18425. */
  18426. set colorCurves(value: Nullable<ColorCurves>);
  18427. /**
  18428. * Gets wether the color curves effect is enabled.
  18429. */
  18430. get colorCurvesEnabled(): boolean;
  18431. /**
  18432. * Sets wether the color curves effect is enabled.
  18433. */
  18434. set colorCurvesEnabled(value: boolean);
  18435. /**
  18436. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18437. */
  18438. get colorGradingTexture(): Nullable<BaseTexture>;
  18439. /**
  18440. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18441. */
  18442. set colorGradingTexture(value: Nullable<BaseTexture>);
  18443. /**
  18444. * Gets wether the color grading effect is enabled.
  18445. */
  18446. get colorGradingEnabled(): boolean;
  18447. /**
  18448. * Gets wether the color grading effect is enabled.
  18449. */
  18450. set colorGradingEnabled(value: boolean);
  18451. /**
  18452. * Gets exposure used in the effect.
  18453. */
  18454. get exposure(): number;
  18455. /**
  18456. * Sets exposure used in the effect.
  18457. */
  18458. set exposure(value: number);
  18459. /**
  18460. * Gets wether tonemapping is enabled or not.
  18461. */
  18462. get toneMappingEnabled(): boolean;
  18463. /**
  18464. * Sets wether tonemapping is enabled or not
  18465. */
  18466. set toneMappingEnabled(value: boolean);
  18467. /**
  18468. * Gets the type of tone mapping effect.
  18469. */
  18470. get toneMappingType(): number;
  18471. /**
  18472. * Sets the type of tone mapping effect.
  18473. */
  18474. set toneMappingType(value: number);
  18475. /**
  18476. * Gets contrast used in the effect.
  18477. */
  18478. get contrast(): number;
  18479. /**
  18480. * Sets contrast used in the effect.
  18481. */
  18482. set contrast(value: number);
  18483. /**
  18484. * Gets Vignette stretch size.
  18485. */
  18486. get vignetteStretch(): number;
  18487. /**
  18488. * Sets Vignette stretch size.
  18489. */
  18490. set vignetteStretch(value: number);
  18491. /**
  18492. * Gets Vignette centre X Offset.
  18493. */
  18494. get vignetteCentreX(): number;
  18495. /**
  18496. * Sets Vignette centre X Offset.
  18497. */
  18498. set vignetteCentreX(value: number);
  18499. /**
  18500. * Gets Vignette centre Y Offset.
  18501. */
  18502. get vignetteCentreY(): number;
  18503. /**
  18504. * Sets Vignette centre Y Offset.
  18505. */
  18506. set vignetteCentreY(value: number);
  18507. /**
  18508. * Gets Vignette weight or intensity of the vignette effect.
  18509. */
  18510. get vignetteWeight(): number;
  18511. /**
  18512. * Sets Vignette weight or intensity of the vignette effect.
  18513. */
  18514. set vignetteWeight(value: number);
  18515. /**
  18516. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18517. * if vignetteEnabled is set to true.
  18518. */
  18519. get vignetteColor(): Color4;
  18520. /**
  18521. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18522. * if vignetteEnabled is set to true.
  18523. */
  18524. set vignetteColor(value: Color4);
  18525. /**
  18526. * Gets Camera field of view used by the Vignette effect.
  18527. */
  18528. get vignetteCameraFov(): number;
  18529. /**
  18530. * Sets Camera field of view used by the Vignette effect.
  18531. */
  18532. set vignetteCameraFov(value: number);
  18533. /**
  18534. * Gets the vignette blend mode allowing different kind of effect.
  18535. */
  18536. get vignetteBlendMode(): number;
  18537. /**
  18538. * Sets the vignette blend mode allowing different kind of effect.
  18539. */
  18540. set vignetteBlendMode(value: number);
  18541. /**
  18542. * Gets wether the vignette effect is enabled.
  18543. */
  18544. get vignetteEnabled(): boolean;
  18545. /**
  18546. * Sets wether the vignette effect is enabled.
  18547. */
  18548. set vignetteEnabled(value: boolean);
  18549. private _fromLinearSpace;
  18550. /**
  18551. * Gets wether the input of the processing is in Gamma or Linear Space.
  18552. */
  18553. get fromLinearSpace(): boolean;
  18554. /**
  18555. * Sets wether the input of the processing is in Gamma or Linear Space.
  18556. */
  18557. set fromLinearSpace(value: boolean);
  18558. /**
  18559. * Defines cache preventing GC.
  18560. */
  18561. private _defines;
  18562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18563. /**
  18564. * "ImageProcessingPostProcess"
  18565. * @returns "ImageProcessingPostProcess"
  18566. */
  18567. getClassName(): string;
  18568. /**
  18569. * @hidden
  18570. */
  18571. _updateParameters(): void;
  18572. dispose(camera?: Camera): void;
  18573. }
  18574. }
  18575. declare module BABYLON {
  18576. /**
  18577. * Interface for defining prepass effects in the prepass post-process pipeline
  18578. */
  18579. export interface PrePassEffectConfiguration {
  18580. /**
  18581. * Name of the effect
  18582. */
  18583. name: string;
  18584. /**
  18585. * Post process to attach for this effect
  18586. */
  18587. postProcess?: PostProcess;
  18588. /**
  18589. * Textures required in the MRT
  18590. */
  18591. texturesRequired: number[];
  18592. /**
  18593. * Is the effect enabled
  18594. */
  18595. enabled: boolean;
  18596. /**
  18597. * Disposes the effect configuration
  18598. */
  18599. dispose?: () => void;
  18600. /**
  18601. * Creates the associated post process
  18602. */
  18603. createPostProcess?: () => PostProcess;
  18604. }
  18605. }
  18606. declare module BABYLON {
  18607. /**
  18608. * Options to be used when creating a FresnelParameters.
  18609. */
  18610. export type IFresnelParametersCreationOptions = {
  18611. /**
  18612. * Define the color used on edges (grazing angle)
  18613. */
  18614. leftColor?: Color3;
  18615. /**
  18616. * Define the color used on center
  18617. */
  18618. rightColor?: Color3;
  18619. /**
  18620. * Define bias applied to computed fresnel term
  18621. */
  18622. bias?: number;
  18623. /**
  18624. * Defined the power exponent applied to fresnel term
  18625. */
  18626. power?: number;
  18627. /**
  18628. * Define if the fresnel effect is enable or not.
  18629. */
  18630. isEnabled?: boolean;
  18631. };
  18632. /**
  18633. * Serialized format for FresnelParameters.
  18634. */
  18635. export type IFresnelParametersSerialized = {
  18636. /**
  18637. * Define the color used on edges (grazing angle) [as an array]
  18638. */
  18639. leftColor: number[];
  18640. /**
  18641. * Define the color used on center [as an array]
  18642. */
  18643. rightColor: number[];
  18644. /**
  18645. * Define bias applied to computed fresnel term
  18646. */
  18647. bias: number;
  18648. /**
  18649. * Defined the power exponent applied to fresnel term
  18650. */
  18651. power?: number;
  18652. /**
  18653. * Define if the fresnel effect is enable or not.
  18654. */
  18655. isEnabled: boolean;
  18656. };
  18657. /**
  18658. * This represents all the required information to add a fresnel effect on a material:
  18659. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18660. */
  18661. export class FresnelParameters {
  18662. private _isEnabled;
  18663. /**
  18664. * Define if the fresnel effect is enable or not.
  18665. */
  18666. get isEnabled(): boolean;
  18667. set isEnabled(value: boolean);
  18668. /**
  18669. * Define the color used on edges (grazing angle)
  18670. */
  18671. leftColor: Color3;
  18672. /**
  18673. * Define the color used on center
  18674. */
  18675. rightColor: Color3;
  18676. /**
  18677. * Define bias applied to computed fresnel term
  18678. */
  18679. bias: number;
  18680. /**
  18681. * Defined the power exponent applied to fresnel term
  18682. */
  18683. power: number;
  18684. /**
  18685. * Creates a new FresnelParameters object.
  18686. *
  18687. * @param options provide your own settings to optionally to override defaults
  18688. */
  18689. constructor(options?: IFresnelParametersCreationOptions);
  18690. /**
  18691. * Clones the current fresnel and its valuues
  18692. * @returns a clone fresnel configuration
  18693. */
  18694. clone(): FresnelParameters;
  18695. /**
  18696. * Determines equality between FresnelParameters objects
  18697. * @param otherFresnelParameters defines the second operand
  18698. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18699. */
  18700. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18701. /**
  18702. * Serializes the current fresnel parameters to a JSON representation.
  18703. * @return the JSON serialization
  18704. */
  18705. serialize(): IFresnelParametersSerialized;
  18706. /**
  18707. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18708. * @param parsedFresnelParameters Define the JSON representation
  18709. * @returns the parsed parameters
  18710. */
  18711. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18712. }
  18713. }
  18714. declare module BABYLON {
  18715. /**
  18716. * This groups all the flags used to control the materials channel.
  18717. */
  18718. export class MaterialFlags {
  18719. private static _DiffuseTextureEnabled;
  18720. /**
  18721. * Are diffuse textures enabled in the application.
  18722. */
  18723. static get DiffuseTextureEnabled(): boolean;
  18724. static set DiffuseTextureEnabled(value: boolean);
  18725. private static _DetailTextureEnabled;
  18726. /**
  18727. * Are detail textures enabled in the application.
  18728. */
  18729. static get DetailTextureEnabled(): boolean;
  18730. static set DetailTextureEnabled(value: boolean);
  18731. private static _AmbientTextureEnabled;
  18732. /**
  18733. * Are ambient textures enabled in the application.
  18734. */
  18735. static get AmbientTextureEnabled(): boolean;
  18736. static set AmbientTextureEnabled(value: boolean);
  18737. private static _OpacityTextureEnabled;
  18738. /**
  18739. * Are opacity textures enabled in the application.
  18740. */
  18741. static get OpacityTextureEnabled(): boolean;
  18742. static set OpacityTextureEnabled(value: boolean);
  18743. private static _ReflectionTextureEnabled;
  18744. /**
  18745. * Are reflection textures enabled in the application.
  18746. */
  18747. static get ReflectionTextureEnabled(): boolean;
  18748. static set ReflectionTextureEnabled(value: boolean);
  18749. private static _EmissiveTextureEnabled;
  18750. /**
  18751. * Are emissive textures enabled in the application.
  18752. */
  18753. static get EmissiveTextureEnabled(): boolean;
  18754. static set EmissiveTextureEnabled(value: boolean);
  18755. private static _SpecularTextureEnabled;
  18756. /**
  18757. * Are specular textures enabled in the application.
  18758. */
  18759. static get SpecularTextureEnabled(): boolean;
  18760. static set SpecularTextureEnabled(value: boolean);
  18761. private static _BumpTextureEnabled;
  18762. /**
  18763. * Are bump textures enabled in the application.
  18764. */
  18765. static get BumpTextureEnabled(): boolean;
  18766. static set BumpTextureEnabled(value: boolean);
  18767. private static _LightmapTextureEnabled;
  18768. /**
  18769. * Are lightmap textures enabled in the application.
  18770. */
  18771. static get LightmapTextureEnabled(): boolean;
  18772. static set LightmapTextureEnabled(value: boolean);
  18773. private static _RefractionTextureEnabled;
  18774. /**
  18775. * Are refraction textures enabled in the application.
  18776. */
  18777. static get RefractionTextureEnabled(): boolean;
  18778. static set RefractionTextureEnabled(value: boolean);
  18779. private static _ColorGradingTextureEnabled;
  18780. /**
  18781. * Are color grading textures enabled in the application.
  18782. */
  18783. static get ColorGradingTextureEnabled(): boolean;
  18784. static set ColorGradingTextureEnabled(value: boolean);
  18785. private static _FresnelEnabled;
  18786. /**
  18787. * Are fresnels enabled in the application.
  18788. */
  18789. static get FresnelEnabled(): boolean;
  18790. static set FresnelEnabled(value: boolean);
  18791. private static _ClearCoatTextureEnabled;
  18792. /**
  18793. * Are clear coat textures enabled in the application.
  18794. */
  18795. static get ClearCoatTextureEnabled(): boolean;
  18796. static set ClearCoatTextureEnabled(value: boolean);
  18797. private static _ClearCoatBumpTextureEnabled;
  18798. /**
  18799. * Are clear coat bump textures enabled in the application.
  18800. */
  18801. static get ClearCoatBumpTextureEnabled(): boolean;
  18802. static set ClearCoatBumpTextureEnabled(value: boolean);
  18803. private static _ClearCoatTintTextureEnabled;
  18804. /**
  18805. * Are clear coat tint textures enabled in the application.
  18806. */
  18807. static get ClearCoatTintTextureEnabled(): boolean;
  18808. static set ClearCoatTintTextureEnabled(value: boolean);
  18809. private static _SheenTextureEnabled;
  18810. /**
  18811. * Are sheen textures enabled in the application.
  18812. */
  18813. static get SheenTextureEnabled(): boolean;
  18814. static set SheenTextureEnabled(value: boolean);
  18815. private static _AnisotropicTextureEnabled;
  18816. /**
  18817. * Are anisotropic textures enabled in the application.
  18818. */
  18819. static get AnisotropicTextureEnabled(): boolean;
  18820. static set AnisotropicTextureEnabled(value: boolean);
  18821. private static _ThicknessTextureEnabled;
  18822. /**
  18823. * Are thickness textures enabled in the application.
  18824. */
  18825. static get ThicknessTextureEnabled(): boolean;
  18826. static set ThicknessTextureEnabled(value: boolean);
  18827. }
  18828. }
  18829. declare module BABYLON {
  18830. /** @hidden */
  18831. export var defaultFragmentDeclaration: {
  18832. name: string;
  18833. shader: string;
  18834. };
  18835. }
  18836. declare module BABYLON {
  18837. /** @hidden */
  18838. export var sceneUboDeclaration: {
  18839. name: string;
  18840. shader: string;
  18841. };
  18842. }
  18843. declare module BABYLON {
  18844. /** @hidden */
  18845. export var meshUboDeclaration: {
  18846. name: string;
  18847. shader: string;
  18848. };
  18849. }
  18850. declare module BABYLON {
  18851. /** @hidden */
  18852. export var defaultUboDeclaration: {
  18853. name: string;
  18854. shader: string;
  18855. };
  18856. }
  18857. declare module BABYLON {
  18858. /** @hidden */
  18859. export var prePassDeclaration: {
  18860. name: string;
  18861. shader: string;
  18862. };
  18863. }
  18864. declare module BABYLON {
  18865. /** @hidden */
  18866. export var lightFragmentDeclaration: {
  18867. name: string;
  18868. shader: string;
  18869. };
  18870. }
  18871. declare module BABYLON {
  18872. /** @hidden */
  18873. export var lightUboDeclaration: {
  18874. name: string;
  18875. shader: string;
  18876. };
  18877. }
  18878. declare module BABYLON {
  18879. /** @hidden */
  18880. export var lightsFragmentFunctions: {
  18881. name: string;
  18882. shader: string;
  18883. };
  18884. }
  18885. declare module BABYLON {
  18886. /** @hidden */
  18887. export var shadowsFragmentFunctions: {
  18888. name: string;
  18889. shader: string;
  18890. };
  18891. }
  18892. declare module BABYLON {
  18893. /** @hidden */
  18894. export var fresnelFunction: {
  18895. name: string;
  18896. shader: string;
  18897. };
  18898. }
  18899. declare module BABYLON {
  18900. /** @hidden */
  18901. export var bumpFragmentMainFunctions: {
  18902. name: string;
  18903. shader: string;
  18904. };
  18905. }
  18906. declare module BABYLON {
  18907. /** @hidden */
  18908. export var bumpFragmentFunctions: {
  18909. name: string;
  18910. shader: string;
  18911. };
  18912. }
  18913. declare module BABYLON {
  18914. /** @hidden */
  18915. export var logDepthDeclaration: {
  18916. name: string;
  18917. shader: string;
  18918. };
  18919. }
  18920. declare module BABYLON {
  18921. /** @hidden */
  18922. export var fogFragmentDeclaration: {
  18923. name: string;
  18924. shader: string;
  18925. };
  18926. }
  18927. declare module BABYLON {
  18928. /** @hidden */
  18929. export var bumpFragment: {
  18930. name: string;
  18931. shader: string;
  18932. };
  18933. }
  18934. declare module BABYLON {
  18935. /** @hidden */
  18936. export var depthPrePass: {
  18937. name: string;
  18938. shader: string;
  18939. };
  18940. }
  18941. declare module BABYLON {
  18942. /** @hidden */
  18943. export var lightFragment: {
  18944. name: string;
  18945. shader: string;
  18946. };
  18947. }
  18948. declare module BABYLON {
  18949. /** @hidden */
  18950. export var logDepthFragment: {
  18951. name: string;
  18952. shader: string;
  18953. };
  18954. }
  18955. declare module BABYLON {
  18956. /** @hidden */
  18957. export var fogFragment: {
  18958. name: string;
  18959. shader: string;
  18960. };
  18961. }
  18962. declare module BABYLON {
  18963. /** @hidden */
  18964. export var defaultPixelShader: {
  18965. name: string;
  18966. shader: string;
  18967. };
  18968. }
  18969. declare module BABYLON {
  18970. /** @hidden */
  18971. export var defaultVertexDeclaration: {
  18972. name: string;
  18973. shader: string;
  18974. };
  18975. }
  18976. declare module BABYLON {
  18977. /** @hidden */
  18978. export var bonesDeclaration: {
  18979. name: string;
  18980. shader: string;
  18981. };
  18982. }
  18983. declare module BABYLON {
  18984. /** @hidden */
  18985. export var prePassVertexDeclaration: {
  18986. name: string;
  18987. shader: string;
  18988. };
  18989. }
  18990. declare module BABYLON {
  18991. /** @hidden */
  18992. export var bumpVertexDeclaration: {
  18993. name: string;
  18994. shader: string;
  18995. };
  18996. }
  18997. declare module BABYLON {
  18998. /** @hidden */
  18999. export var fogVertexDeclaration: {
  19000. name: string;
  19001. shader: string;
  19002. };
  19003. }
  19004. declare module BABYLON {
  19005. /** @hidden */
  19006. export var lightVxFragmentDeclaration: {
  19007. name: string;
  19008. shader: string;
  19009. };
  19010. }
  19011. declare module BABYLON {
  19012. /** @hidden */
  19013. export var lightVxUboDeclaration: {
  19014. name: string;
  19015. shader: string;
  19016. };
  19017. }
  19018. declare module BABYLON {
  19019. /** @hidden */
  19020. export var morphTargetsVertexGlobalDeclaration: {
  19021. name: string;
  19022. shader: string;
  19023. };
  19024. }
  19025. declare module BABYLON {
  19026. /** @hidden */
  19027. export var morphTargetsVertexDeclaration: {
  19028. name: string;
  19029. shader: string;
  19030. };
  19031. }
  19032. declare module BABYLON {
  19033. /** @hidden */
  19034. export var morphTargetsVertex: {
  19035. name: string;
  19036. shader: string;
  19037. };
  19038. }
  19039. declare module BABYLON {
  19040. /** @hidden */
  19041. export var instancesVertex: {
  19042. name: string;
  19043. shader: string;
  19044. };
  19045. }
  19046. declare module BABYLON {
  19047. /** @hidden */
  19048. export var bonesVertex: {
  19049. name: string;
  19050. shader: string;
  19051. };
  19052. }
  19053. declare module BABYLON {
  19054. /** @hidden */
  19055. export var prePassVertex: {
  19056. name: string;
  19057. shader: string;
  19058. };
  19059. }
  19060. declare module BABYLON {
  19061. /** @hidden */
  19062. export var bumpVertex: {
  19063. name: string;
  19064. shader: string;
  19065. };
  19066. }
  19067. declare module BABYLON {
  19068. /** @hidden */
  19069. export var fogVertex: {
  19070. name: string;
  19071. shader: string;
  19072. };
  19073. }
  19074. declare module BABYLON {
  19075. /** @hidden */
  19076. export var shadowsVertex: {
  19077. name: string;
  19078. shader: string;
  19079. };
  19080. }
  19081. declare module BABYLON {
  19082. /** @hidden */
  19083. export var pointCloudVertex: {
  19084. name: string;
  19085. shader: string;
  19086. };
  19087. }
  19088. declare module BABYLON {
  19089. /** @hidden */
  19090. export var logDepthVertex: {
  19091. name: string;
  19092. shader: string;
  19093. };
  19094. }
  19095. declare module BABYLON {
  19096. /** @hidden */
  19097. export var defaultVertexShader: {
  19098. name: string;
  19099. shader: string;
  19100. };
  19101. }
  19102. declare module BABYLON {
  19103. /**
  19104. * @hidden
  19105. */
  19106. export interface IMaterialDetailMapDefines {
  19107. DETAIL: boolean;
  19108. DETAILDIRECTUV: number;
  19109. DETAIL_NORMALBLENDMETHOD: number;
  19110. /** @hidden */
  19111. _areTexturesDirty: boolean;
  19112. }
  19113. /**
  19114. * Define the code related to the detail map parameters of a material
  19115. *
  19116. * Inspired from:
  19117. * 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
  19118. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19119. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19120. */
  19121. export class DetailMapConfiguration {
  19122. private _texture;
  19123. /**
  19124. * The detail texture of the material.
  19125. */
  19126. texture: Nullable<BaseTexture>;
  19127. /**
  19128. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19129. * Bigger values mean stronger blending
  19130. */
  19131. diffuseBlendLevel: number;
  19132. /**
  19133. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19134. * Bigger values mean stronger blending. Only used with PBR materials
  19135. */
  19136. roughnessBlendLevel: number;
  19137. /**
  19138. * Defines how strong the bump effect from the detail map is
  19139. * Bigger values mean stronger effect
  19140. */
  19141. bumpLevel: number;
  19142. private _normalBlendMethod;
  19143. /**
  19144. * The method used to blend the bump and detail normals together
  19145. */
  19146. normalBlendMethod: number;
  19147. private _isEnabled;
  19148. /**
  19149. * Enable or disable the detail map on this material
  19150. */
  19151. isEnabled: boolean;
  19152. /** @hidden */
  19153. private _internalMarkAllSubMeshesAsTexturesDirty;
  19154. /** @hidden */
  19155. _markAllSubMeshesAsTexturesDirty(): void;
  19156. /**
  19157. * Instantiate a new detail map
  19158. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19159. */
  19160. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19161. /**
  19162. * Gets whether the submesh is ready to be used or not.
  19163. * @param defines the list of "defines" to update.
  19164. * @param scene defines the scene the material belongs to.
  19165. * @returns - boolean indicating that the submesh is ready or not.
  19166. */
  19167. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19168. /**
  19169. * Update the defines for detail map usage
  19170. * @param defines the list of "defines" to update.
  19171. * @param scene defines the scene the material belongs to.
  19172. */
  19173. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19174. /**
  19175. * Binds the material data.
  19176. * @param uniformBuffer defines the Uniform buffer to fill in.
  19177. * @param scene defines the scene the material belongs to.
  19178. * @param isFrozen defines whether the material is frozen or not.
  19179. */
  19180. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19181. /**
  19182. * Checks to see if a texture is used in the material.
  19183. * @param texture - Base texture to use.
  19184. * @returns - Boolean specifying if a texture is used in the material.
  19185. */
  19186. hasTexture(texture: BaseTexture): boolean;
  19187. /**
  19188. * Returns an array of the actively used textures.
  19189. * @param activeTextures Array of BaseTextures
  19190. */
  19191. getActiveTextures(activeTextures: BaseTexture[]): void;
  19192. /**
  19193. * Returns the animatable textures.
  19194. * @param animatables Array of animatable textures.
  19195. */
  19196. getAnimatables(animatables: IAnimatable[]): void;
  19197. /**
  19198. * Disposes the resources of the material.
  19199. * @param forceDisposeTextures - Forces the disposal of all textures.
  19200. */
  19201. dispose(forceDisposeTextures?: boolean): void;
  19202. /**
  19203. * Get the current class name useful for serialization or dynamic coding.
  19204. * @returns "DetailMap"
  19205. */
  19206. getClassName(): string;
  19207. /**
  19208. * Add the required uniforms to the current list.
  19209. * @param uniforms defines the current uniform list.
  19210. */
  19211. static AddUniforms(uniforms: string[]): void;
  19212. /**
  19213. * Add the required samplers to the current list.
  19214. * @param samplers defines the current sampler list.
  19215. */
  19216. static AddSamplers(samplers: string[]): void;
  19217. /**
  19218. * Add the required uniforms to the current buffer.
  19219. * @param uniformBuffer defines the current uniform buffer.
  19220. */
  19221. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19222. /**
  19223. * Makes a duplicate of the current instance into another one.
  19224. * @param detailMap define the instance where to copy the info
  19225. */
  19226. copyTo(detailMap: DetailMapConfiguration): void;
  19227. /**
  19228. * Serializes this detail map instance
  19229. * @returns - An object with the serialized instance.
  19230. */
  19231. serialize(): any;
  19232. /**
  19233. * Parses a detail map setting from a serialized object.
  19234. * @param source - Serialized object.
  19235. * @param scene Defines the scene we are parsing for
  19236. * @param rootUrl Defines the rootUrl to load from
  19237. */
  19238. parse(source: any, scene: Scene, rootUrl: string): void;
  19239. }
  19240. }
  19241. declare module BABYLON {
  19242. /** @hidden */
  19243. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19244. MAINUV1: boolean;
  19245. MAINUV2: boolean;
  19246. DIFFUSE: boolean;
  19247. DIFFUSEDIRECTUV: number;
  19248. DETAIL: boolean;
  19249. DETAILDIRECTUV: number;
  19250. DETAIL_NORMALBLENDMETHOD: number;
  19251. AMBIENT: boolean;
  19252. AMBIENTDIRECTUV: number;
  19253. OPACITY: boolean;
  19254. OPACITYDIRECTUV: number;
  19255. OPACITYRGB: boolean;
  19256. REFLECTION: boolean;
  19257. EMISSIVE: boolean;
  19258. EMISSIVEDIRECTUV: number;
  19259. SPECULAR: boolean;
  19260. SPECULARDIRECTUV: number;
  19261. BUMP: boolean;
  19262. BUMPDIRECTUV: number;
  19263. PARALLAX: boolean;
  19264. PARALLAXOCCLUSION: boolean;
  19265. SPECULAROVERALPHA: boolean;
  19266. CLIPPLANE: boolean;
  19267. CLIPPLANE2: boolean;
  19268. CLIPPLANE3: boolean;
  19269. CLIPPLANE4: boolean;
  19270. CLIPPLANE5: boolean;
  19271. CLIPPLANE6: boolean;
  19272. ALPHATEST: boolean;
  19273. DEPTHPREPASS: boolean;
  19274. ALPHAFROMDIFFUSE: boolean;
  19275. POINTSIZE: boolean;
  19276. FOG: boolean;
  19277. SPECULARTERM: boolean;
  19278. DIFFUSEFRESNEL: boolean;
  19279. OPACITYFRESNEL: boolean;
  19280. REFLECTIONFRESNEL: boolean;
  19281. REFRACTIONFRESNEL: boolean;
  19282. EMISSIVEFRESNEL: boolean;
  19283. FRESNEL: boolean;
  19284. NORMAL: boolean;
  19285. UV1: boolean;
  19286. UV2: boolean;
  19287. VERTEXCOLOR: boolean;
  19288. VERTEXALPHA: boolean;
  19289. NUM_BONE_INFLUENCERS: number;
  19290. BonesPerMesh: number;
  19291. BONETEXTURE: boolean;
  19292. BONES_VELOCITY_ENABLED: boolean;
  19293. INSTANCES: boolean;
  19294. THIN_INSTANCES: boolean;
  19295. GLOSSINESS: boolean;
  19296. ROUGHNESS: boolean;
  19297. EMISSIVEASILLUMINATION: boolean;
  19298. LINKEMISSIVEWITHDIFFUSE: boolean;
  19299. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19300. LIGHTMAP: boolean;
  19301. LIGHTMAPDIRECTUV: number;
  19302. OBJECTSPACE_NORMALMAP: boolean;
  19303. USELIGHTMAPASSHADOWMAP: boolean;
  19304. REFLECTIONMAP_3D: boolean;
  19305. REFLECTIONMAP_SPHERICAL: boolean;
  19306. REFLECTIONMAP_PLANAR: boolean;
  19307. REFLECTIONMAP_CUBIC: boolean;
  19308. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19309. REFLECTIONMAP_PROJECTION: boolean;
  19310. REFLECTIONMAP_SKYBOX: boolean;
  19311. REFLECTIONMAP_EXPLICIT: boolean;
  19312. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19313. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19314. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19315. INVERTCUBICMAP: boolean;
  19316. LOGARITHMICDEPTH: boolean;
  19317. REFRACTION: boolean;
  19318. REFRACTIONMAP_3D: boolean;
  19319. REFLECTIONOVERALPHA: boolean;
  19320. TWOSIDEDLIGHTING: boolean;
  19321. SHADOWFLOAT: boolean;
  19322. MORPHTARGETS: boolean;
  19323. MORPHTARGETS_NORMAL: boolean;
  19324. MORPHTARGETS_TANGENT: boolean;
  19325. MORPHTARGETS_UV: boolean;
  19326. NUM_MORPH_INFLUENCERS: number;
  19327. NONUNIFORMSCALING: boolean;
  19328. PREMULTIPLYALPHA: boolean;
  19329. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19330. ALPHABLEND: boolean;
  19331. PREPASS: boolean;
  19332. PREPASS_IRRADIANCE: boolean;
  19333. PREPASS_IRRADIANCE_INDEX: number;
  19334. PREPASS_ALBEDO: boolean;
  19335. PREPASS_ALBEDO_INDEX: number;
  19336. PREPASS_DEPTHNORMAL: boolean;
  19337. PREPASS_DEPTHNORMAL_INDEX: number;
  19338. PREPASS_POSITION: boolean;
  19339. PREPASS_POSITION_INDEX: number;
  19340. PREPASS_VELOCITY: boolean;
  19341. PREPASS_VELOCITY_INDEX: number;
  19342. PREPASS_REFLECTIVITY: boolean;
  19343. PREPASS_REFLECTIVITY_INDEX: number;
  19344. SCENE_MRT_COUNT: number;
  19345. RGBDLIGHTMAP: boolean;
  19346. RGBDREFLECTION: boolean;
  19347. RGBDREFRACTION: boolean;
  19348. IMAGEPROCESSING: boolean;
  19349. VIGNETTE: boolean;
  19350. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19351. VIGNETTEBLENDMODEOPAQUE: boolean;
  19352. TONEMAPPING: boolean;
  19353. TONEMAPPING_ACES: boolean;
  19354. CONTRAST: boolean;
  19355. COLORCURVES: boolean;
  19356. COLORGRADING: boolean;
  19357. COLORGRADING3D: boolean;
  19358. SAMPLER3DGREENDEPTH: boolean;
  19359. SAMPLER3DBGRMAP: boolean;
  19360. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19361. MULTIVIEW: boolean;
  19362. /**
  19363. * If the reflection texture on this material is in linear color space
  19364. * @hidden
  19365. */
  19366. IS_REFLECTION_LINEAR: boolean;
  19367. /**
  19368. * If the refraction texture on this material is in linear color space
  19369. * @hidden
  19370. */
  19371. IS_REFRACTION_LINEAR: boolean;
  19372. EXPOSURE: boolean;
  19373. constructor();
  19374. setReflectionMode(modeToEnable: string): void;
  19375. }
  19376. /**
  19377. * This is the default material used in Babylon. It is the best trade off between quality
  19378. * and performances.
  19379. * @see https://doc.babylonjs.com/babylon101/materials
  19380. */
  19381. export class StandardMaterial extends PushMaterial {
  19382. private _diffuseTexture;
  19383. /**
  19384. * The basic texture of the material as viewed under a light.
  19385. */
  19386. diffuseTexture: Nullable<BaseTexture>;
  19387. private _ambientTexture;
  19388. /**
  19389. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19390. */
  19391. ambientTexture: Nullable<BaseTexture>;
  19392. private _opacityTexture;
  19393. /**
  19394. * Define the transparency of the material from a texture.
  19395. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19396. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19397. */
  19398. opacityTexture: Nullable<BaseTexture>;
  19399. private _reflectionTexture;
  19400. /**
  19401. * Define the texture used to display the reflection.
  19402. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19403. */
  19404. reflectionTexture: Nullable<BaseTexture>;
  19405. private _emissiveTexture;
  19406. /**
  19407. * Define texture of the material as if self lit.
  19408. * This will be mixed in the final result even in the absence of light.
  19409. */
  19410. emissiveTexture: Nullable<BaseTexture>;
  19411. private _specularTexture;
  19412. /**
  19413. * Define how the color and intensity of the highlight given by the light in the material.
  19414. */
  19415. specularTexture: Nullable<BaseTexture>;
  19416. private _bumpTexture;
  19417. /**
  19418. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19419. * 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.
  19420. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19421. */
  19422. bumpTexture: Nullable<BaseTexture>;
  19423. private _lightmapTexture;
  19424. /**
  19425. * Complex lighting can be computationally expensive to compute at runtime.
  19426. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19427. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19428. */
  19429. lightmapTexture: Nullable<BaseTexture>;
  19430. private _refractionTexture;
  19431. /**
  19432. * Define the texture used to display the refraction.
  19433. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19434. */
  19435. refractionTexture: Nullable<BaseTexture>;
  19436. /**
  19437. * The color of the material lit by the environmental background lighting.
  19438. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19439. */
  19440. ambientColor: Color3;
  19441. /**
  19442. * The basic color of the material as viewed under a light.
  19443. */
  19444. diffuseColor: Color3;
  19445. /**
  19446. * Define how the color and intensity of the highlight given by the light in the material.
  19447. */
  19448. specularColor: Color3;
  19449. /**
  19450. * Define the color of the material as if self lit.
  19451. * This will be mixed in the final result even in the absence of light.
  19452. */
  19453. emissiveColor: Color3;
  19454. /**
  19455. * Defines how sharp are the highlights in the material.
  19456. * The bigger the value the sharper giving a more glossy feeling to the result.
  19457. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19458. */
  19459. specularPower: number;
  19460. private _useAlphaFromDiffuseTexture;
  19461. /**
  19462. * Does the transparency come from the diffuse texture alpha channel.
  19463. */
  19464. useAlphaFromDiffuseTexture: boolean;
  19465. private _useEmissiveAsIllumination;
  19466. /**
  19467. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19468. */
  19469. useEmissiveAsIllumination: boolean;
  19470. private _linkEmissiveWithDiffuse;
  19471. /**
  19472. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19473. * the emissive level when the final color is close to one.
  19474. */
  19475. linkEmissiveWithDiffuse: boolean;
  19476. private _useSpecularOverAlpha;
  19477. /**
  19478. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19479. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19480. */
  19481. useSpecularOverAlpha: boolean;
  19482. private _useReflectionOverAlpha;
  19483. /**
  19484. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19485. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19486. */
  19487. useReflectionOverAlpha: boolean;
  19488. private _disableLighting;
  19489. /**
  19490. * Does lights from the scene impacts this material.
  19491. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19492. */
  19493. disableLighting: boolean;
  19494. private _useObjectSpaceNormalMap;
  19495. /**
  19496. * Allows using an object space normal map (instead of tangent space).
  19497. */
  19498. useObjectSpaceNormalMap: boolean;
  19499. private _useParallax;
  19500. /**
  19501. * Is parallax enabled or not.
  19502. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19503. */
  19504. useParallax: boolean;
  19505. private _useParallaxOcclusion;
  19506. /**
  19507. * Is parallax occlusion enabled or not.
  19508. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19509. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19510. */
  19511. useParallaxOcclusion: boolean;
  19512. /**
  19513. * 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.
  19514. */
  19515. parallaxScaleBias: number;
  19516. private _roughness;
  19517. /**
  19518. * Helps to define how blurry the reflections should appears in the material.
  19519. */
  19520. roughness: number;
  19521. /**
  19522. * In case of refraction, define the value of the index of refraction.
  19523. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19524. */
  19525. indexOfRefraction: number;
  19526. /**
  19527. * Invert the refraction texture alongside the y axis.
  19528. * It can be useful with procedural textures or probe for instance.
  19529. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19530. */
  19531. invertRefractionY: boolean;
  19532. /**
  19533. * Defines the alpha limits in alpha test mode.
  19534. */
  19535. alphaCutOff: number;
  19536. private _useLightmapAsShadowmap;
  19537. /**
  19538. * In case of light mapping, define whether the map contains light or shadow informations.
  19539. */
  19540. useLightmapAsShadowmap: boolean;
  19541. private _diffuseFresnelParameters;
  19542. /**
  19543. * Define the diffuse fresnel parameters of the material.
  19544. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19545. */
  19546. diffuseFresnelParameters: FresnelParameters;
  19547. private _opacityFresnelParameters;
  19548. /**
  19549. * Define the opacity fresnel parameters of the material.
  19550. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19551. */
  19552. opacityFresnelParameters: FresnelParameters;
  19553. private _reflectionFresnelParameters;
  19554. /**
  19555. * Define the reflection fresnel parameters of the material.
  19556. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19557. */
  19558. reflectionFresnelParameters: FresnelParameters;
  19559. private _refractionFresnelParameters;
  19560. /**
  19561. * Define the refraction fresnel parameters of the material.
  19562. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19563. */
  19564. refractionFresnelParameters: FresnelParameters;
  19565. private _emissiveFresnelParameters;
  19566. /**
  19567. * Define the emissive fresnel parameters of the material.
  19568. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19569. */
  19570. emissiveFresnelParameters: FresnelParameters;
  19571. private _useReflectionFresnelFromSpecular;
  19572. /**
  19573. * If true automatically deducts the fresnels values from the material specularity.
  19574. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19575. */
  19576. useReflectionFresnelFromSpecular: boolean;
  19577. private _useGlossinessFromSpecularMapAlpha;
  19578. /**
  19579. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19580. */
  19581. useGlossinessFromSpecularMapAlpha: boolean;
  19582. private _maxSimultaneousLights;
  19583. /**
  19584. * Defines the maximum number of lights that can be used in the material
  19585. */
  19586. maxSimultaneousLights: number;
  19587. private _invertNormalMapX;
  19588. /**
  19589. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19590. */
  19591. invertNormalMapX: boolean;
  19592. private _invertNormalMapY;
  19593. /**
  19594. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19595. */
  19596. invertNormalMapY: boolean;
  19597. private _twoSidedLighting;
  19598. /**
  19599. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19600. */
  19601. twoSidedLighting: boolean;
  19602. /**
  19603. * Default configuration related to image processing available in the standard Material.
  19604. */
  19605. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19606. /**
  19607. * Gets the image processing configuration used either in this material.
  19608. */
  19609. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19610. /**
  19611. * Sets the Default image processing configuration used either in the this material.
  19612. *
  19613. * If sets to null, the scene one is in use.
  19614. */
  19615. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19616. /**
  19617. * Keep track of the image processing observer to allow dispose and replace.
  19618. */
  19619. private _imageProcessingObserver;
  19620. /**
  19621. * Attaches a new image processing configuration to the Standard Material.
  19622. * @param configuration
  19623. */
  19624. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19625. /**
  19626. * Defines additionnal PrePass parameters for the material.
  19627. */
  19628. readonly prePassConfiguration: PrePassConfiguration;
  19629. /**
  19630. * Gets wether the color curves effect is enabled.
  19631. */
  19632. get cameraColorCurvesEnabled(): boolean;
  19633. /**
  19634. * Sets wether the color curves effect is enabled.
  19635. */
  19636. set cameraColorCurvesEnabled(value: boolean);
  19637. /**
  19638. * Gets wether the color grading effect is enabled.
  19639. */
  19640. get cameraColorGradingEnabled(): boolean;
  19641. /**
  19642. * Gets wether the color grading effect is enabled.
  19643. */
  19644. set cameraColorGradingEnabled(value: boolean);
  19645. /**
  19646. * Gets wether tonemapping is enabled or not.
  19647. */
  19648. get cameraToneMappingEnabled(): boolean;
  19649. /**
  19650. * Sets wether tonemapping is enabled or not
  19651. */
  19652. set cameraToneMappingEnabled(value: boolean);
  19653. /**
  19654. * The camera exposure used on this material.
  19655. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19656. * This corresponds to a photographic exposure.
  19657. */
  19658. get cameraExposure(): number;
  19659. /**
  19660. * The camera exposure used on this material.
  19661. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19662. * This corresponds to a photographic exposure.
  19663. */
  19664. set cameraExposure(value: number);
  19665. /**
  19666. * Gets The camera contrast used on this material.
  19667. */
  19668. get cameraContrast(): number;
  19669. /**
  19670. * Sets The camera contrast used on this material.
  19671. */
  19672. set cameraContrast(value: number);
  19673. /**
  19674. * Gets the Color Grading 2D Lookup Texture.
  19675. */
  19676. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19677. /**
  19678. * Sets the Color Grading 2D Lookup Texture.
  19679. */
  19680. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19681. /**
  19682. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19683. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19684. * 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;
  19685. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19686. */
  19687. get cameraColorCurves(): Nullable<ColorCurves>;
  19688. /**
  19689. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19690. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19691. * 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;
  19692. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19693. */
  19694. set cameraColorCurves(value: Nullable<ColorCurves>);
  19695. /**
  19696. * Can this material render to several textures at once
  19697. */
  19698. get canRenderToMRT(): boolean;
  19699. /**
  19700. * Defines the detail map parameters for the material.
  19701. */
  19702. readonly detailMap: DetailMapConfiguration;
  19703. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19704. protected _worldViewProjectionMatrix: Matrix;
  19705. protected _globalAmbientColor: Color3;
  19706. protected _useLogarithmicDepth: boolean;
  19707. protected _rebuildInParallel: boolean;
  19708. /**
  19709. * Instantiates a new standard material.
  19710. * This is the default material used in Babylon. It is the best trade off between quality
  19711. * and performances.
  19712. * @see https://doc.babylonjs.com/babylon101/materials
  19713. * @param name Define the name of the material in the scene
  19714. * @param scene Define the scene the material belong to
  19715. */
  19716. constructor(name: string, scene: Scene);
  19717. /**
  19718. * Gets a boolean indicating that current material needs to register RTT
  19719. */
  19720. get hasRenderTargetTextures(): boolean;
  19721. /**
  19722. * Gets the current class name of the material e.g. "StandardMaterial"
  19723. * Mainly use in serialization.
  19724. * @returns the class name
  19725. */
  19726. getClassName(): string;
  19727. /**
  19728. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19729. * You can try switching to logarithmic depth.
  19730. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19731. */
  19732. get useLogarithmicDepth(): boolean;
  19733. set useLogarithmicDepth(value: boolean);
  19734. /**
  19735. * Specifies if the material will require alpha blending
  19736. * @returns a boolean specifying if alpha blending is needed
  19737. */
  19738. needAlphaBlending(): boolean;
  19739. /**
  19740. * Specifies if this material should be rendered in alpha test mode
  19741. * @returns a boolean specifying if an alpha test is needed.
  19742. */
  19743. needAlphaTesting(): boolean;
  19744. /**
  19745. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19746. */
  19747. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19748. /**
  19749. * Specifies whether or not there is a usable alpha channel for transparency.
  19750. */
  19751. protected _hasAlphaChannel(): boolean;
  19752. /**
  19753. * Get the texture used for alpha test purpose.
  19754. * @returns the diffuse texture in case of the standard material.
  19755. */
  19756. getAlphaTestTexture(): Nullable<BaseTexture>;
  19757. /**
  19758. * Get if the submesh is ready to be used and all its information available.
  19759. * Child classes can use it to update shaders
  19760. * @param mesh defines the mesh to check
  19761. * @param subMesh defines which submesh to check
  19762. * @param useInstances specifies that instances should be used
  19763. * @returns a boolean indicating that the submesh is ready or not
  19764. */
  19765. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19766. /**
  19767. * Builds the material UBO layouts.
  19768. * Used internally during the effect preparation.
  19769. */
  19770. buildUniformLayout(): void;
  19771. /**
  19772. * Unbinds the material from the mesh
  19773. */
  19774. unbind(): void;
  19775. /**
  19776. * Binds the submesh to this material by preparing the effect and shader to draw
  19777. * @param world defines the world transformation matrix
  19778. * @param mesh defines the mesh containing the submesh
  19779. * @param subMesh defines the submesh to bind the material to
  19780. */
  19781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19782. /**
  19783. * Get the list of animatables in the material.
  19784. * @returns the list of animatables object used in the material
  19785. */
  19786. getAnimatables(): IAnimatable[];
  19787. /**
  19788. * Gets the active textures from the material
  19789. * @returns an array of textures
  19790. */
  19791. getActiveTextures(): BaseTexture[];
  19792. /**
  19793. * Specifies if the material uses a texture
  19794. * @param texture defines the texture to check against the material
  19795. * @returns a boolean specifying if the material uses the texture
  19796. */
  19797. hasTexture(texture: BaseTexture): boolean;
  19798. /**
  19799. * Disposes the material
  19800. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19801. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19802. */
  19803. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19804. /**
  19805. * Makes a duplicate of the material, and gives it a new name
  19806. * @param name defines the new name for the duplicated material
  19807. * @returns the cloned material
  19808. */
  19809. clone(name: string): StandardMaterial;
  19810. /**
  19811. * Serializes this material in a JSON representation
  19812. * @returns the serialized material object
  19813. */
  19814. serialize(): any;
  19815. /**
  19816. * Creates a standard material from parsed material data
  19817. * @param source defines the JSON representation of the material
  19818. * @param scene defines the hosting scene
  19819. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19820. * @returns a new standard material
  19821. */
  19822. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19823. /**
  19824. * Are diffuse textures enabled in the application.
  19825. */
  19826. static get DiffuseTextureEnabled(): boolean;
  19827. static set DiffuseTextureEnabled(value: boolean);
  19828. /**
  19829. * Are detail textures enabled in the application.
  19830. */
  19831. static get DetailTextureEnabled(): boolean;
  19832. static set DetailTextureEnabled(value: boolean);
  19833. /**
  19834. * Are ambient textures enabled in the application.
  19835. */
  19836. static get AmbientTextureEnabled(): boolean;
  19837. static set AmbientTextureEnabled(value: boolean);
  19838. /**
  19839. * Are opacity textures enabled in the application.
  19840. */
  19841. static get OpacityTextureEnabled(): boolean;
  19842. static set OpacityTextureEnabled(value: boolean);
  19843. /**
  19844. * Are reflection textures enabled in the application.
  19845. */
  19846. static get ReflectionTextureEnabled(): boolean;
  19847. static set ReflectionTextureEnabled(value: boolean);
  19848. /**
  19849. * Are emissive textures enabled in the application.
  19850. */
  19851. static get EmissiveTextureEnabled(): boolean;
  19852. static set EmissiveTextureEnabled(value: boolean);
  19853. /**
  19854. * Are specular textures enabled in the application.
  19855. */
  19856. static get SpecularTextureEnabled(): boolean;
  19857. static set SpecularTextureEnabled(value: boolean);
  19858. /**
  19859. * Are bump textures enabled in the application.
  19860. */
  19861. static get BumpTextureEnabled(): boolean;
  19862. static set BumpTextureEnabled(value: boolean);
  19863. /**
  19864. * Are lightmap textures enabled in the application.
  19865. */
  19866. static get LightmapTextureEnabled(): boolean;
  19867. static set LightmapTextureEnabled(value: boolean);
  19868. /**
  19869. * Are refraction textures enabled in the application.
  19870. */
  19871. static get RefractionTextureEnabled(): boolean;
  19872. static set RefractionTextureEnabled(value: boolean);
  19873. /**
  19874. * Are color grading textures enabled in the application.
  19875. */
  19876. static get ColorGradingTextureEnabled(): boolean;
  19877. static set ColorGradingTextureEnabled(value: boolean);
  19878. /**
  19879. * Are fresnels enabled in the application.
  19880. */
  19881. static get FresnelEnabled(): boolean;
  19882. static set FresnelEnabled(value: boolean);
  19883. }
  19884. }
  19885. declare module BABYLON {
  19886. /** @hidden */
  19887. export var rgbdDecodePixelShader: {
  19888. name: string;
  19889. shader: string;
  19890. };
  19891. }
  19892. declare module BABYLON {
  19893. /** @hidden */
  19894. export var passPixelShader: {
  19895. name: string;
  19896. shader: string;
  19897. };
  19898. }
  19899. declare module BABYLON {
  19900. /** @hidden */
  19901. export var passCubePixelShader: {
  19902. name: string;
  19903. shader: string;
  19904. };
  19905. }
  19906. declare module BABYLON {
  19907. /**
  19908. * PassPostProcess which produces an output the same as it's input
  19909. */
  19910. export class PassPostProcess extends PostProcess {
  19911. /**
  19912. * Gets a string identifying the name of the class
  19913. * @returns "PassPostProcess" string
  19914. */
  19915. getClassName(): string;
  19916. /**
  19917. * Creates the PassPostProcess
  19918. * @param name The name of the effect.
  19919. * @param options The required width/height ratio to downsize to before computing the render pass.
  19920. * @param camera The camera to apply the render pass to.
  19921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19922. * @param engine The engine which the post process will be applied. (default: current engine)
  19923. * @param reusable If the post process can be reused on the same frame. (default: false)
  19924. * @param textureType The type of texture to be used when performing the post processing.
  19925. * @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)
  19926. */
  19927. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19928. /** @hidden */
  19929. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  19930. }
  19931. /**
  19932. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  19933. */
  19934. export class PassCubePostProcess extends PostProcess {
  19935. private _face;
  19936. /**
  19937. * Gets or sets the cube face to display.
  19938. * * 0 is +X
  19939. * * 1 is -X
  19940. * * 2 is +Y
  19941. * * 3 is -Y
  19942. * * 4 is +Z
  19943. * * 5 is -Z
  19944. */
  19945. get face(): number;
  19946. set face(value: number);
  19947. /**
  19948. * Gets a string identifying the name of the class
  19949. * @returns "PassCubePostProcess" string
  19950. */
  19951. getClassName(): string;
  19952. /**
  19953. * Creates the PassCubePostProcess
  19954. * @param name The name of the effect.
  19955. * @param options The required width/height ratio to downsize to before computing the render pass.
  19956. * @param camera The camera to apply the render pass to.
  19957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19958. * @param engine The engine which the post process will be applied. (default: current engine)
  19959. * @param reusable If the post process can be reused on the same frame. (default: false)
  19960. * @param textureType The type of texture to be used when performing the post processing.
  19961. * @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)
  19962. */
  19963. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19964. /** @hidden */
  19965. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  19966. }
  19967. }
  19968. declare module BABYLON {
  19969. /**
  19970. * Class used to host texture specific utilities
  19971. */
  19972. export class TextureTools {
  19973. /**
  19974. * Uses the GPU to create a copy texture rescaled at a given size
  19975. * @param texture Texture to copy from
  19976. * @param width defines the desired width
  19977. * @param height defines the desired height
  19978. * @param useBilinearMode defines if bilinear mode has to be used
  19979. * @return the generated texture
  19980. */
  19981. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  19982. /**
  19983. * Apply a post process to a texture
  19984. * @param postProcessName name of the fragment post process
  19985. * @param internalTexture the texture to encode
  19986. * @param scene the scene hosting the texture
  19987. * @param type type of the output texture. If not provided, use the one from internalTexture
  19988. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  19989. * @param format format of the output texture. If not provided, use the one from internalTexture
  19990. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  19991. */
  19992. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  19993. }
  19994. }
  19995. declare module BABYLON {
  19996. /**
  19997. * Class used to host RGBD texture specific utilities
  19998. */
  19999. export class RGBDTextureTools {
  20000. /**
  20001. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20002. * @param texture the texture to expand.
  20003. */
  20004. static ExpandRGBDTexture(texture: Texture): void;
  20005. /**
  20006. * Encode the texture to RGBD if possible.
  20007. * @param internalTexture the texture to encode
  20008. * @param scene the scene hosting the texture
  20009. * @param outputTextureType type of the texture in which the encoding is performed
  20010. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20011. */
  20012. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20013. }
  20014. }
  20015. declare module BABYLON {
  20016. /**
  20017. * Class used to host texture specific utilities
  20018. */
  20019. export class BRDFTextureTools {
  20020. /**
  20021. * Prevents texture cache collision
  20022. */
  20023. private static _instanceNumber;
  20024. /**
  20025. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20026. * @param scene defines the hosting scene
  20027. * @returns the environment BRDF texture
  20028. */
  20029. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20030. private static _environmentBRDFBase64Texture;
  20031. }
  20032. }
  20033. declare module BABYLON {
  20034. /**
  20035. * @hidden
  20036. */
  20037. export interface IMaterialClearCoatDefines {
  20038. CLEARCOAT: boolean;
  20039. CLEARCOAT_DEFAULTIOR: boolean;
  20040. CLEARCOAT_TEXTURE: boolean;
  20041. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20042. CLEARCOAT_TEXTUREDIRECTUV: number;
  20043. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20044. CLEARCOAT_BUMP: boolean;
  20045. CLEARCOAT_BUMPDIRECTUV: number;
  20046. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20047. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20048. CLEARCOAT_REMAP_F0: boolean;
  20049. CLEARCOAT_TINT: boolean;
  20050. CLEARCOAT_TINT_TEXTURE: boolean;
  20051. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20052. /** @hidden */
  20053. _areTexturesDirty: boolean;
  20054. }
  20055. /**
  20056. * Define the code related to the clear coat parameters of the pbr material.
  20057. */
  20058. export class PBRClearCoatConfiguration {
  20059. /**
  20060. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20061. * The default fits with a polyurethane material.
  20062. * @hidden
  20063. */
  20064. static readonly _DefaultIndexOfRefraction: number;
  20065. private _isEnabled;
  20066. /**
  20067. * Defines if the clear coat is enabled in the material.
  20068. */
  20069. isEnabled: boolean;
  20070. /**
  20071. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20072. */
  20073. intensity: number;
  20074. /**
  20075. * Defines the clear coat layer roughness.
  20076. */
  20077. roughness: number;
  20078. private _indexOfRefraction;
  20079. /**
  20080. * Defines the index of refraction of the clear coat.
  20081. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20082. * The default fits with a polyurethane material.
  20083. * Changing the default value is more performance intensive.
  20084. */
  20085. indexOfRefraction: number;
  20086. private _texture;
  20087. /**
  20088. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20089. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20090. * if textureRoughness is not empty, else no texture roughness is used
  20091. */
  20092. texture: Nullable<BaseTexture>;
  20093. private _useRoughnessFromMainTexture;
  20094. /**
  20095. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20096. * If false, the green channel from textureRoughness is used for roughness
  20097. */
  20098. useRoughnessFromMainTexture: boolean;
  20099. private _textureRoughness;
  20100. /**
  20101. * Stores the clear coat roughness in a texture (green channel)
  20102. * Not used if useRoughnessFromMainTexture is true
  20103. */
  20104. textureRoughness: Nullable<BaseTexture>;
  20105. private _remapF0OnInterfaceChange;
  20106. /**
  20107. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20108. */
  20109. remapF0OnInterfaceChange: boolean;
  20110. private _bumpTexture;
  20111. /**
  20112. * Define the clear coat specific bump texture.
  20113. */
  20114. bumpTexture: Nullable<BaseTexture>;
  20115. private _isTintEnabled;
  20116. /**
  20117. * Defines if the clear coat tint is enabled in the material.
  20118. */
  20119. isTintEnabled: boolean;
  20120. /**
  20121. * Defines the clear coat tint of the material.
  20122. * This is only use if tint is enabled
  20123. */
  20124. tintColor: Color3;
  20125. /**
  20126. * Defines the distance at which the tint color should be found in the
  20127. * clear coat media.
  20128. * This is only use if tint is enabled
  20129. */
  20130. tintColorAtDistance: number;
  20131. /**
  20132. * Defines the clear coat layer thickness.
  20133. * This is only use if tint is enabled
  20134. */
  20135. tintThickness: number;
  20136. private _tintTexture;
  20137. /**
  20138. * Stores the clear tint values in a texture.
  20139. * rgb is tint
  20140. * a is a thickness factor
  20141. */
  20142. tintTexture: Nullable<BaseTexture>;
  20143. /** @hidden */
  20144. private _internalMarkAllSubMeshesAsTexturesDirty;
  20145. /** @hidden */
  20146. _markAllSubMeshesAsTexturesDirty(): void;
  20147. /**
  20148. * Instantiate a new istance of clear coat configuration.
  20149. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20150. */
  20151. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20152. /**
  20153. * Gets wehter the submesh is ready to be used or not.
  20154. * @param defines the list of "defines" to update.
  20155. * @param scene defines the scene the material belongs to.
  20156. * @param engine defines the engine the material belongs to.
  20157. * @param disableBumpMap defines wether the material disables bump or not.
  20158. * @returns - boolean indicating that the submesh is ready or not.
  20159. */
  20160. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20161. /**
  20162. * Checks to see if a texture is used in the material.
  20163. * @param defines the list of "defines" to update.
  20164. * @param scene defines the scene to the material belongs to.
  20165. */
  20166. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20167. /**
  20168. * Binds the material data.
  20169. * @param uniformBuffer defines the Uniform buffer to fill in.
  20170. * @param scene defines the scene the material belongs to.
  20171. * @param engine defines the engine the material belongs to.
  20172. * @param disableBumpMap defines wether the material disables bump or not.
  20173. * @param isFrozen defines wether the material is frozen or not.
  20174. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20175. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20176. * @param subMesh the submesh to bind data for
  20177. */
  20178. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20179. /**
  20180. * Checks to see if a texture is used in the material.
  20181. * @param texture - Base texture to use.
  20182. * @returns - Boolean specifying if a texture is used in the material.
  20183. */
  20184. hasTexture(texture: BaseTexture): boolean;
  20185. /**
  20186. * Returns an array of the actively used textures.
  20187. * @param activeTextures Array of BaseTextures
  20188. */
  20189. getActiveTextures(activeTextures: BaseTexture[]): void;
  20190. /**
  20191. * Returns the animatable textures.
  20192. * @param animatables Array of animatable textures.
  20193. */
  20194. getAnimatables(animatables: IAnimatable[]): void;
  20195. /**
  20196. * Disposes the resources of the material.
  20197. * @param forceDisposeTextures - Forces the disposal of all textures.
  20198. */
  20199. dispose(forceDisposeTextures?: boolean): void;
  20200. /**
  20201. * Get the current class name of the texture useful for serialization or dynamic coding.
  20202. * @returns "PBRClearCoatConfiguration"
  20203. */
  20204. getClassName(): string;
  20205. /**
  20206. * Add fallbacks to the effect fallbacks list.
  20207. * @param defines defines the Base texture to use.
  20208. * @param fallbacks defines the current fallback list.
  20209. * @param currentRank defines the current fallback rank.
  20210. * @returns the new fallback rank.
  20211. */
  20212. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20213. /**
  20214. * Add the required uniforms to the current list.
  20215. * @param uniforms defines the current uniform list.
  20216. */
  20217. static AddUniforms(uniforms: string[]): void;
  20218. /**
  20219. * Add the required samplers to the current list.
  20220. * @param samplers defines the current sampler list.
  20221. */
  20222. static AddSamplers(samplers: string[]): void;
  20223. /**
  20224. * Add the required uniforms to the current buffer.
  20225. * @param uniformBuffer defines the current uniform buffer.
  20226. */
  20227. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20228. /**
  20229. * Makes a duplicate of the current configuration into another one.
  20230. * @param clearCoatConfiguration define the config where to copy the info
  20231. */
  20232. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20233. /**
  20234. * Serializes this clear coat configuration.
  20235. * @returns - An object with the serialized config.
  20236. */
  20237. serialize(): any;
  20238. /**
  20239. * Parses a anisotropy Configuration from a serialized object.
  20240. * @param source - Serialized object.
  20241. * @param scene Defines the scene we are parsing for
  20242. * @param rootUrl Defines the rootUrl to load from
  20243. */
  20244. parse(source: any, scene: Scene, rootUrl: string): void;
  20245. }
  20246. }
  20247. declare module BABYLON {
  20248. /**
  20249. * @hidden
  20250. */
  20251. export interface IMaterialAnisotropicDefines {
  20252. ANISOTROPIC: boolean;
  20253. ANISOTROPIC_TEXTURE: boolean;
  20254. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20255. MAINUV1: boolean;
  20256. _areTexturesDirty: boolean;
  20257. _needUVs: boolean;
  20258. }
  20259. /**
  20260. * Define the code related to the anisotropic parameters of the pbr material.
  20261. */
  20262. export class PBRAnisotropicConfiguration {
  20263. private _isEnabled;
  20264. /**
  20265. * Defines if the anisotropy is enabled in the material.
  20266. */
  20267. isEnabled: boolean;
  20268. /**
  20269. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20270. */
  20271. intensity: number;
  20272. /**
  20273. * Defines if the effect is along the tangents, bitangents or in between.
  20274. * By default, the effect is "strectching" the highlights along the tangents.
  20275. */
  20276. direction: Vector2;
  20277. private _texture;
  20278. /**
  20279. * Stores the anisotropy values in a texture.
  20280. * rg is direction (like normal from -1 to 1)
  20281. * b is a intensity
  20282. */
  20283. texture: Nullable<BaseTexture>;
  20284. /** @hidden */
  20285. private _internalMarkAllSubMeshesAsTexturesDirty;
  20286. /** @hidden */
  20287. _markAllSubMeshesAsTexturesDirty(): void;
  20288. /**
  20289. * Instantiate a new istance of anisotropy configuration.
  20290. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20291. */
  20292. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20293. /**
  20294. * Specifies that the submesh is ready to be used.
  20295. * @param defines the list of "defines" to update.
  20296. * @param scene defines the scene the material belongs to.
  20297. * @returns - boolean indicating that the submesh is ready or not.
  20298. */
  20299. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20300. /**
  20301. * Checks to see if a texture is used in the material.
  20302. * @param defines the list of "defines" to update.
  20303. * @param mesh the mesh we are preparing the defines for.
  20304. * @param scene defines the scene the material belongs to.
  20305. */
  20306. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20307. /**
  20308. * Binds the material data.
  20309. * @param uniformBuffer defines the Uniform buffer to fill in.
  20310. * @param scene defines the scene the material belongs to.
  20311. * @param isFrozen defines wether the material is frozen or not.
  20312. */
  20313. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20314. /**
  20315. * Checks to see if a texture is used in the material.
  20316. * @param texture - Base texture to use.
  20317. * @returns - Boolean specifying if a texture is used in the material.
  20318. */
  20319. hasTexture(texture: BaseTexture): boolean;
  20320. /**
  20321. * Returns an array of the actively used textures.
  20322. * @param activeTextures Array of BaseTextures
  20323. */
  20324. getActiveTextures(activeTextures: BaseTexture[]): void;
  20325. /**
  20326. * Returns the animatable textures.
  20327. * @param animatables Array of animatable textures.
  20328. */
  20329. getAnimatables(animatables: IAnimatable[]): void;
  20330. /**
  20331. * Disposes the resources of the material.
  20332. * @param forceDisposeTextures - Forces the disposal of all textures.
  20333. */
  20334. dispose(forceDisposeTextures?: boolean): void;
  20335. /**
  20336. * Get the current class name of the texture useful for serialization or dynamic coding.
  20337. * @returns "PBRAnisotropicConfiguration"
  20338. */
  20339. getClassName(): string;
  20340. /**
  20341. * Add fallbacks to the effect fallbacks list.
  20342. * @param defines defines the Base texture to use.
  20343. * @param fallbacks defines the current fallback list.
  20344. * @param currentRank defines the current fallback rank.
  20345. * @returns the new fallback rank.
  20346. */
  20347. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20348. /**
  20349. * Add the required uniforms to the current list.
  20350. * @param uniforms defines the current uniform list.
  20351. */
  20352. static AddUniforms(uniforms: string[]): void;
  20353. /**
  20354. * Add the required uniforms to the current buffer.
  20355. * @param uniformBuffer defines the current uniform buffer.
  20356. */
  20357. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20358. /**
  20359. * Add the required samplers to the current list.
  20360. * @param samplers defines the current sampler list.
  20361. */
  20362. static AddSamplers(samplers: string[]): void;
  20363. /**
  20364. * Makes a duplicate of the current configuration into another one.
  20365. * @param anisotropicConfiguration define the config where to copy the info
  20366. */
  20367. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20368. /**
  20369. * Serializes this anisotropy configuration.
  20370. * @returns - An object with the serialized config.
  20371. */
  20372. serialize(): any;
  20373. /**
  20374. * Parses a anisotropy Configuration from a serialized object.
  20375. * @param source - Serialized object.
  20376. * @param scene Defines the scene we are parsing for
  20377. * @param rootUrl Defines the rootUrl to load from
  20378. */
  20379. parse(source: any, scene: Scene, rootUrl: string): void;
  20380. }
  20381. }
  20382. declare module BABYLON {
  20383. /**
  20384. * @hidden
  20385. */
  20386. export interface IMaterialBRDFDefines {
  20387. BRDF_V_HEIGHT_CORRELATED: boolean;
  20388. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20389. SPHERICAL_HARMONICS: boolean;
  20390. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20391. /** @hidden */
  20392. _areMiscDirty: boolean;
  20393. }
  20394. /**
  20395. * Define the code related to the BRDF parameters of the pbr material.
  20396. */
  20397. export class PBRBRDFConfiguration {
  20398. /**
  20399. * Default value used for the energy conservation.
  20400. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20401. */
  20402. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20403. /**
  20404. * Default value used for the Smith Visibility Height Correlated mode.
  20405. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20406. */
  20407. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20408. /**
  20409. * Default value used for the IBL diffuse part.
  20410. * This can help switching back to the polynomials mode globally which is a tiny bit
  20411. * less GPU intensive at the drawback of a lower quality.
  20412. */
  20413. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20414. /**
  20415. * Default value used for activating energy conservation for the specular workflow.
  20416. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20417. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20418. */
  20419. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20420. private _useEnergyConservation;
  20421. /**
  20422. * Defines if the material uses energy conservation.
  20423. */
  20424. useEnergyConservation: boolean;
  20425. private _useSmithVisibilityHeightCorrelated;
  20426. /**
  20427. * LEGACY Mode set to false
  20428. * Defines if the material uses height smith correlated visibility term.
  20429. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20430. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20431. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20432. * Not relying on height correlated will also disable energy conservation.
  20433. */
  20434. useSmithVisibilityHeightCorrelated: boolean;
  20435. private _useSphericalHarmonics;
  20436. /**
  20437. * LEGACY Mode set to false
  20438. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20439. * diffuse part of the IBL.
  20440. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20441. * to the ground truth.
  20442. */
  20443. useSphericalHarmonics: boolean;
  20444. private _useSpecularGlossinessInputEnergyConservation;
  20445. /**
  20446. * Defines if the material uses energy conservation, when the specular workflow is active.
  20447. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20448. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20449. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20450. */
  20451. useSpecularGlossinessInputEnergyConservation: boolean;
  20452. /** @hidden */
  20453. private _internalMarkAllSubMeshesAsMiscDirty;
  20454. /** @hidden */
  20455. _markAllSubMeshesAsMiscDirty(): void;
  20456. /**
  20457. * Instantiate a new istance of clear coat configuration.
  20458. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20459. */
  20460. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20461. /**
  20462. * Checks to see if a texture is used in the material.
  20463. * @param defines the list of "defines" to update.
  20464. */
  20465. prepareDefines(defines: IMaterialBRDFDefines): void;
  20466. /**
  20467. * Get the current class name of the texture useful for serialization or dynamic coding.
  20468. * @returns "PBRClearCoatConfiguration"
  20469. */
  20470. getClassName(): string;
  20471. /**
  20472. * Makes a duplicate of the current configuration into another one.
  20473. * @param brdfConfiguration define the config where to copy the info
  20474. */
  20475. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20476. /**
  20477. * Serializes this BRDF configuration.
  20478. * @returns - An object with the serialized config.
  20479. */
  20480. serialize(): any;
  20481. /**
  20482. * Parses a anisotropy Configuration from a serialized object.
  20483. * @param source - Serialized object.
  20484. * @param scene Defines the scene we are parsing for
  20485. * @param rootUrl Defines the rootUrl to load from
  20486. */
  20487. parse(source: any, scene: Scene, rootUrl: string): void;
  20488. }
  20489. }
  20490. declare module BABYLON {
  20491. /**
  20492. * @hidden
  20493. */
  20494. export interface IMaterialSheenDefines {
  20495. SHEEN: boolean;
  20496. SHEEN_TEXTURE: boolean;
  20497. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20498. SHEEN_TEXTUREDIRECTUV: number;
  20499. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20500. SHEEN_LINKWITHALBEDO: boolean;
  20501. SHEEN_ROUGHNESS: boolean;
  20502. SHEEN_ALBEDOSCALING: boolean;
  20503. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20504. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20505. /** @hidden */
  20506. _areTexturesDirty: boolean;
  20507. }
  20508. /**
  20509. * Define the code related to the Sheen parameters of the pbr material.
  20510. */
  20511. export class PBRSheenConfiguration {
  20512. private _isEnabled;
  20513. /**
  20514. * Defines if the material uses sheen.
  20515. */
  20516. isEnabled: boolean;
  20517. private _linkSheenWithAlbedo;
  20518. /**
  20519. * Defines if the sheen is linked to the sheen color.
  20520. */
  20521. linkSheenWithAlbedo: boolean;
  20522. /**
  20523. * Defines the sheen intensity.
  20524. */
  20525. intensity: number;
  20526. /**
  20527. * Defines the sheen color.
  20528. */
  20529. color: Color3;
  20530. private _texture;
  20531. /**
  20532. * Stores the sheen tint values in a texture.
  20533. * rgb is tint
  20534. * 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)
  20535. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20536. */
  20537. texture: Nullable<BaseTexture>;
  20538. private _useRoughnessFromMainTexture;
  20539. /**
  20540. * Indicates that the alpha channel of the texture property will be used for roughness.
  20541. * Has no effect if the roughness (and texture!) property is not defined
  20542. */
  20543. useRoughnessFromMainTexture: boolean;
  20544. private _roughness;
  20545. /**
  20546. * Defines the sheen roughness.
  20547. * It is not taken into account if linkSheenWithAlbedo is true.
  20548. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20549. */
  20550. roughness: Nullable<number>;
  20551. private _textureRoughness;
  20552. /**
  20553. * Stores the sheen roughness in a texture.
  20554. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20555. */
  20556. textureRoughness: Nullable<BaseTexture>;
  20557. private _albedoScaling;
  20558. /**
  20559. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20560. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20561. * making it easier to setup and tweak the effect
  20562. */
  20563. albedoScaling: boolean;
  20564. /** @hidden */
  20565. private _internalMarkAllSubMeshesAsTexturesDirty;
  20566. /** @hidden */
  20567. _markAllSubMeshesAsTexturesDirty(): void;
  20568. /**
  20569. * Instantiate a new istance of clear coat configuration.
  20570. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20571. */
  20572. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20573. /**
  20574. * Specifies that the submesh is ready to be used.
  20575. * @param defines the list of "defines" to update.
  20576. * @param scene defines the scene the material belongs to.
  20577. * @returns - boolean indicating that the submesh is ready or not.
  20578. */
  20579. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20580. /**
  20581. * Checks to see if a texture is used in the material.
  20582. * @param defines the list of "defines" to update.
  20583. * @param scene defines the scene the material belongs to.
  20584. */
  20585. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20586. /**
  20587. * Binds the material data.
  20588. * @param uniformBuffer defines the Uniform buffer to fill in.
  20589. * @param scene defines the scene the material belongs to.
  20590. * @param isFrozen defines wether the material is frozen or not.
  20591. * @param subMesh the submesh to bind data for
  20592. */
  20593. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20594. /**
  20595. * Checks to see if a texture is used in the material.
  20596. * @param texture - Base texture to use.
  20597. * @returns - Boolean specifying if a texture is used in the material.
  20598. */
  20599. hasTexture(texture: BaseTexture): boolean;
  20600. /**
  20601. * Returns an array of the actively used textures.
  20602. * @param activeTextures Array of BaseTextures
  20603. */
  20604. getActiveTextures(activeTextures: BaseTexture[]): void;
  20605. /**
  20606. * Returns the animatable textures.
  20607. * @param animatables Array of animatable textures.
  20608. */
  20609. getAnimatables(animatables: IAnimatable[]): void;
  20610. /**
  20611. * Disposes the resources of the material.
  20612. * @param forceDisposeTextures - Forces the disposal of all textures.
  20613. */
  20614. dispose(forceDisposeTextures?: boolean): void;
  20615. /**
  20616. * Get the current class name of the texture useful for serialization or dynamic coding.
  20617. * @returns "PBRSheenConfiguration"
  20618. */
  20619. getClassName(): string;
  20620. /**
  20621. * Add fallbacks to the effect fallbacks list.
  20622. * @param defines defines the Base texture to use.
  20623. * @param fallbacks defines the current fallback list.
  20624. * @param currentRank defines the current fallback rank.
  20625. * @returns the new fallback rank.
  20626. */
  20627. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20628. /**
  20629. * Add the required uniforms to the current list.
  20630. * @param uniforms defines the current uniform list.
  20631. */
  20632. static AddUniforms(uniforms: string[]): void;
  20633. /**
  20634. * Add the required uniforms to the current buffer.
  20635. * @param uniformBuffer defines the current uniform buffer.
  20636. */
  20637. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20638. /**
  20639. * Add the required samplers to the current list.
  20640. * @param samplers defines the current sampler list.
  20641. */
  20642. static AddSamplers(samplers: string[]): void;
  20643. /**
  20644. * Makes a duplicate of the current configuration into another one.
  20645. * @param sheenConfiguration define the config where to copy the info
  20646. */
  20647. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20648. /**
  20649. * Serializes this BRDF configuration.
  20650. * @returns - An object with the serialized config.
  20651. */
  20652. serialize(): any;
  20653. /**
  20654. * Parses a anisotropy Configuration from a serialized object.
  20655. * @param source - Serialized object.
  20656. * @param scene Defines the scene we are parsing for
  20657. * @param rootUrl Defines the rootUrl to load from
  20658. */
  20659. parse(source: any, scene: Scene, rootUrl: string): void;
  20660. }
  20661. }
  20662. declare module BABYLON {
  20663. /**
  20664. * @hidden
  20665. */
  20666. export interface IMaterialSubSurfaceDefines {
  20667. SUBSURFACE: boolean;
  20668. SS_REFRACTION: boolean;
  20669. SS_TRANSLUCENCY: boolean;
  20670. SS_SCATTERING: boolean;
  20671. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20672. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20673. SS_REFRACTIONMAP_3D: boolean;
  20674. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20675. SS_LODINREFRACTIONALPHA: boolean;
  20676. SS_GAMMAREFRACTION: boolean;
  20677. SS_RGBDREFRACTION: boolean;
  20678. SS_LINEARSPECULARREFRACTION: boolean;
  20679. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20680. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20681. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20682. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20683. /** @hidden */
  20684. _areTexturesDirty: boolean;
  20685. }
  20686. /**
  20687. * Define the code related to the sub surface parameters of the pbr material.
  20688. */
  20689. export class PBRSubSurfaceConfiguration {
  20690. private _isRefractionEnabled;
  20691. /**
  20692. * Defines if the refraction is enabled in the material.
  20693. */
  20694. isRefractionEnabled: boolean;
  20695. private _isTranslucencyEnabled;
  20696. /**
  20697. * Defines if the translucency is enabled in the material.
  20698. */
  20699. isTranslucencyEnabled: boolean;
  20700. private _isScatteringEnabled;
  20701. /**
  20702. * Defines if the sub surface scattering is enabled in the material.
  20703. */
  20704. isScatteringEnabled: boolean;
  20705. private _scatteringDiffusionProfileIndex;
  20706. /**
  20707. * Diffusion profile for subsurface scattering.
  20708. * Useful for better scattering in the skins or foliages.
  20709. */
  20710. get scatteringDiffusionProfile(): Nullable<Color3>;
  20711. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20712. /**
  20713. * Defines the refraction intensity of the material.
  20714. * The refraction when enabled replaces the Diffuse part of the material.
  20715. * The intensity helps transitionning between diffuse and refraction.
  20716. */
  20717. refractionIntensity: number;
  20718. /**
  20719. * Defines the translucency intensity of the material.
  20720. * When translucency has been enabled, this defines how much of the "translucency"
  20721. * is addded to the diffuse part of the material.
  20722. */
  20723. translucencyIntensity: number;
  20724. /**
  20725. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20726. */
  20727. useAlbedoToTintRefraction: boolean;
  20728. private _thicknessTexture;
  20729. /**
  20730. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20731. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20732. * 0 would mean minimumThickness
  20733. * 1 would mean maximumThickness
  20734. * The other channels might be use as a mask to vary the different effects intensity.
  20735. */
  20736. thicknessTexture: Nullable<BaseTexture>;
  20737. private _refractionTexture;
  20738. /**
  20739. * Defines the texture to use for refraction.
  20740. */
  20741. refractionTexture: Nullable<BaseTexture>;
  20742. private _indexOfRefraction;
  20743. /**
  20744. * Index of refraction of the material base layer.
  20745. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20746. *
  20747. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20748. *
  20749. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20750. */
  20751. indexOfRefraction: number;
  20752. private _volumeIndexOfRefraction;
  20753. /**
  20754. * Index of refraction of the material's volume.
  20755. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20756. *
  20757. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20758. * the volume will use the same IOR as the surface.
  20759. */
  20760. get volumeIndexOfRefraction(): number;
  20761. set volumeIndexOfRefraction(value: number);
  20762. private _invertRefractionY;
  20763. /**
  20764. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20765. */
  20766. invertRefractionY: boolean;
  20767. private _linkRefractionWithTransparency;
  20768. /**
  20769. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20770. * Materials half opaque for instance using refraction could benefit from this control.
  20771. */
  20772. linkRefractionWithTransparency: boolean;
  20773. /**
  20774. * Defines the minimum thickness stored in the thickness map.
  20775. * If no thickness map is defined, this value will be used to simulate thickness.
  20776. */
  20777. minimumThickness: number;
  20778. /**
  20779. * Defines the maximum thickness stored in the thickness map.
  20780. */
  20781. maximumThickness: number;
  20782. /**
  20783. * Defines the volume tint of the material.
  20784. * This is used for both translucency and scattering.
  20785. */
  20786. tintColor: Color3;
  20787. /**
  20788. * Defines the distance at which the tint color should be found in the media.
  20789. * This is used for refraction only.
  20790. */
  20791. tintColorAtDistance: number;
  20792. /**
  20793. * Defines how far each channel transmit through the media.
  20794. * It is defined as a color to simplify it selection.
  20795. */
  20796. diffusionDistance: Color3;
  20797. private _useMaskFromThicknessTexture;
  20798. /**
  20799. * Stores the intensity of the different subsurface effects in the thickness texture.
  20800. * * the green channel is the translucency intensity.
  20801. * * the blue channel is the scattering intensity.
  20802. * * the alpha channel is the refraction intensity.
  20803. */
  20804. useMaskFromThicknessTexture: boolean;
  20805. private _scene;
  20806. private _useMaskFromThicknessTextureGltf;
  20807. /**
  20808. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20809. * matches the channel-packing that is used by glTF.
  20810. * * the red channel is the transmission/translucency intensity.
  20811. * * the green channel is the thickness.
  20812. */
  20813. useMaskFromThicknessTextureGltf: boolean;
  20814. /** @hidden */
  20815. private _internalMarkAllSubMeshesAsTexturesDirty;
  20816. private _internalMarkScenePrePassDirty;
  20817. /** @hidden */
  20818. _markAllSubMeshesAsTexturesDirty(): void;
  20819. /** @hidden */
  20820. _markScenePrePassDirty(): void;
  20821. /**
  20822. * Instantiate a new istance of sub surface configuration.
  20823. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20824. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20825. * @param scene The scene
  20826. */
  20827. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20828. /**
  20829. * Gets wehter the submesh is ready to be used or not.
  20830. * @param defines the list of "defines" to update.
  20831. * @param scene defines the scene the material belongs to.
  20832. * @returns - boolean indicating that the submesh is ready or not.
  20833. */
  20834. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20835. /**
  20836. * Checks to see if a texture is used in the material.
  20837. * @param defines the list of "defines" to update.
  20838. * @param scene defines the scene to the material belongs to.
  20839. */
  20840. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20841. /**
  20842. * Binds the material data.
  20843. * @param uniformBuffer defines the Uniform buffer to fill in.
  20844. * @param scene defines the scene the material belongs to.
  20845. * @param engine defines the engine the material belongs to.
  20846. * @param isFrozen defines whether the material is frozen or not.
  20847. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20848. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20849. */
  20850. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20851. /**
  20852. * Unbinds the material from the mesh.
  20853. * @param activeEffect defines the effect that should be unbound from.
  20854. * @returns true if unbound, otherwise false
  20855. */
  20856. unbind(activeEffect: Effect): boolean;
  20857. /**
  20858. * Returns the texture used for refraction or null if none is used.
  20859. * @param scene defines the scene the material belongs to.
  20860. * @returns - Refraction texture if present. If no refraction texture and refraction
  20861. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20862. */
  20863. private _getRefractionTexture;
  20864. /**
  20865. * Returns true if alpha blending should be disabled.
  20866. */
  20867. get disableAlphaBlending(): boolean;
  20868. /**
  20869. * Fills the list of render target textures.
  20870. * @param renderTargets the list of render targets to update
  20871. */
  20872. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20873. /**
  20874. * Checks to see if a texture is used in the material.
  20875. * @param texture - Base texture to use.
  20876. * @returns - Boolean specifying if a texture is used in the material.
  20877. */
  20878. hasTexture(texture: BaseTexture): boolean;
  20879. /**
  20880. * Gets a boolean indicating that current material needs to register RTT
  20881. * @returns true if this uses a render target otherwise false.
  20882. */
  20883. hasRenderTargetTextures(): boolean;
  20884. /**
  20885. * Returns an array of the actively used textures.
  20886. * @param activeTextures Array of BaseTextures
  20887. */
  20888. getActiveTextures(activeTextures: BaseTexture[]): void;
  20889. /**
  20890. * Returns the animatable textures.
  20891. * @param animatables Array of animatable textures.
  20892. */
  20893. getAnimatables(animatables: IAnimatable[]): void;
  20894. /**
  20895. * Disposes the resources of the material.
  20896. * @param forceDisposeTextures - Forces the disposal of all textures.
  20897. */
  20898. dispose(forceDisposeTextures?: boolean): void;
  20899. /**
  20900. * Get the current class name of the texture useful for serialization or dynamic coding.
  20901. * @returns "PBRSubSurfaceConfiguration"
  20902. */
  20903. getClassName(): string;
  20904. /**
  20905. * Add fallbacks to the effect fallbacks list.
  20906. * @param defines defines the Base texture to use.
  20907. * @param fallbacks defines the current fallback list.
  20908. * @param currentRank defines the current fallback rank.
  20909. * @returns the new fallback rank.
  20910. */
  20911. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20912. /**
  20913. * Add the required uniforms to the current list.
  20914. * @param uniforms defines the current uniform list.
  20915. */
  20916. static AddUniforms(uniforms: string[]): void;
  20917. /**
  20918. * Add the required samplers to the current list.
  20919. * @param samplers defines the current sampler list.
  20920. */
  20921. static AddSamplers(samplers: string[]): void;
  20922. /**
  20923. * Add the required uniforms to the current buffer.
  20924. * @param uniformBuffer defines the current uniform buffer.
  20925. */
  20926. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20927. /**
  20928. * Makes a duplicate of the current configuration into another one.
  20929. * @param configuration define the config where to copy the info
  20930. */
  20931. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20932. /**
  20933. * Serializes this Sub Surface configuration.
  20934. * @returns - An object with the serialized config.
  20935. */
  20936. serialize(): any;
  20937. /**
  20938. * Parses a anisotropy Configuration from a serialized object.
  20939. * @param source - Serialized object.
  20940. * @param scene Defines the scene we are parsing for
  20941. * @param rootUrl Defines the rootUrl to load from
  20942. */
  20943. parse(source: any, scene: Scene, rootUrl: string): void;
  20944. }
  20945. }
  20946. declare module BABYLON {
  20947. /**
  20948. * Class representing spherical harmonics coefficients to the 3rd degree
  20949. */
  20950. export class SphericalHarmonics {
  20951. /**
  20952. * Defines whether or not the harmonics have been prescaled for rendering.
  20953. */
  20954. preScaled: boolean;
  20955. /**
  20956. * The l0,0 coefficients of the spherical harmonics
  20957. */
  20958. l00: Vector3;
  20959. /**
  20960. * The l1,-1 coefficients of the spherical harmonics
  20961. */
  20962. l1_1: Vector3;
  20963. /**
  20964. * The l1,0 coefficients of the spherical harmonics
  20965. */
  20966. l10: Vector3;
  20967. /**
  20968. * The l1,1 coefficients of the spherical harmonics
  20969. */
  20970. l11: Vector3;
  20971. /**
  20972. * The l2,-2 coefficients of the spherical harmonics
  20973. */
  20974. l2_2: Vector3;
  20975. /**
  20976. * The l2,-1 coefficients of the spherical harmonics
  20977. */
  20978. l2_1: Vector3;
  20979. /**
  20980. * The l2,0 coefficients of the spherical harmonics
  20981. */
  20982. l20: Vector3;
  20983. /**
  20984. * The l2,1 coefficients of the spherical harmonics
  20985. */
  20986. l21: Vector3;
  20987. /**
  20988. * The l2,2 coefficients of the spherical harmonics
  20989. */
  20990. l22: Vector3;
  20991. /**
  20992. * Adds a light to the spherical harmonics
  20993. * @param direction the direction of the light
  20994. * @param color the color of the light
  20995. * @param deltaSolidAngle the delta solid angle of the light
  20996. */
  20997. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20998. /**
  20999. * Scales the spherical harmonics by the given amount
  21000. * @param scale the amount to scale
  21001. */
  21002. scaleInPlace(scale: number): void;
  21003. /**
  21004. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21005. *
  21006. * ```
  21007. * E_lm = A_l * L_lm
  21008. * ```
  21009. *
  21010. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21011. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21012. * the scaling factors are given in equation 9.
  21013. */
  21014. convertIncidentRadianceToIrradiance(): void;
  21015. /**
  21016. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21017. *
  21018. * ```
  21019. * L = (1/pi) * E * rho
  21020. * ```
  21021. *
  21022. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21023. */
  21024. convertIrradianceToLambertianRadiance(): void;
  21025. /**
  21026. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21027. * required operations at run time.
  21028. *
  21029. * This is simply done by scaling back the SH with Ylm constants parameter.
  21030. * The trigonometric part being applied by the shader at run time.
  21031. */
  21032. preScaleForRendering(): void;
  21033. /**
  21034. * Constructs a spherical harmonics from an array.
  21035. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21036. * @returns the spherical harmonics
  21037. */
  21038. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21039. /**
  21040. * Gets the spherical harmonics from polynomial
  21041. * @param polynomial the spherical polynomial
  21042. * @returns the spherical harmonics
  21043. */
  21044. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21045. }
  21046. /**
  21047. * Class representing spherical polynomial coefficients to the 3rd degree
  21048. */
  21049. export class SphericalPolynomial {
  21050. private _harmonics;
  21051. /**
  21052. * The spherical harmonics used to create the polynomials.
  21053. */
  21054. get preScaledHarmonics(): SphericalHarmonics;
  21055. /**
  21056. * The x coefficients of the spherical polynomial
  21057. */
  21058. x: Vector3;
  21059. /**
  21060. * The y coefficients of the spherical polynomial
  21061. */
  21062. y: Vector3;
  21063. /**
  21064. * The z coefficients of the spherical polynomial
  21065. */
  21066. z: Vector3;
  21067. /**
  21068. * The xx coefficients of the spherical polynomial
  21069. */
  21070. xx: Vector3;
  21071. /**
  21072. * The yy coefficients of the spherical polynomial
  21073. */
  21074. yy: Vector3;
  21075. /**
  21076. * The zz coefficients of the spherical polynomial
  21077. */
  21078. zz: Vector3;
  21079. /**
  21080. * The xy coefficients of the spherical polynomial
  21081. */
  21082. xy: Vector3;
  21083. /**
  21084. * The yz coefficients of the spherical polynomial
  21085. */
  21086. yz: Vector3;
  21087. /**
  21088. * The zx coefficients of the spherical polynomial
  21089. */
  21090. zx: Vector3;
  21091. /**
  21092. * Adds an ambient color to the spherical polynomial
  21093. * @param color the color to add
  21094. */
  21095. addAmbient(color: Color3): void;
  21096. /**
  21097. * Scales the spherical polynomial by the given amount
  21098. * @param scale the amount to scale
  21099. */
  21100. scaleInPlace(scale: number): void;
  21101. /**
  21102. * Gets the spherical polynomial from harmonics
  21103. * @param harmonics the spherical harmonics
  21104. * @returns the spherical polynomial
  21105. */
  21106. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21107. /**
  21108. * Constructs a spherical polynomial from an array.
  21109. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21110. * @returns the spherical polynomial
  21111. */
  21112. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21113. }
  21114. }
  21115. declare module BABYLON {
  21116. /**
  21117. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21118. */
  21119. export interface CubeMapInfo {
  21120. /**
  21121. * The pixel array for the front face.
  21122. * This is stored in format, left to right, up to down format.
  21123. */
  21124. front: Nullable<ArrayBufferView>;
  21125. /**
  21126. * The pixel array for the back face.
  21127. * This is stored in format, left to right, up to down format.
  21128. */
  21129. back: Nullable<ArrayBufferView>;
  21130. /**
  21131. * The pixel array for the left face.
  21132. * This is stored in format, left to right, up to down format.
  21133. */
  21134. left: Nullable<ArrayBufferView>;
  21135. /**
  21136. * The pixel array for the right face.
  21137. * This is stored in format, left to right, up to down format.
  21138. */
  21139. right: Nullable<ArrayBufferView>;
  21140. /**
  21141. * The pixel array for the up face.
  21142. * This is stored in format, left to right, up to down format.
  21143. */
  21144. up: Nullable<ArrayBufferView>;
  21145. /**
  21146. * The pixel array for the down face.
  21147. * This is stored in format, left to right, up to down format.
  21148. */
  21149. down: Nullable<ArrayBufferView>;
  21150. /**
  21151. * The size of the cubemap stored.
  21152. *
  21153. * Each faces will be size * size pixels.
  21154. */
  21155. size: number;
  21156. /**
  21157. * The format of the texture.
  21158. *
  21159. * RGBA, RGB.
  21160. */
  21161. format: number;
  21162. /**
  21163. * The type of the texture data.
  21164. *
  21165. * UNSIGNED_INT, FLOAT.
  21166. */
  21167. type: number;
  21168. /**
  21169. * Specifies whether the texture is in gamma space.
  21170. */
  21171. gammaSpace: boolean;
  21172. }
  21173. /**
  21174. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21175. */
  21176. export class PanoramaToCubeMapTools {
  21177. private static FACE_LEFT;
  21178. private static FACE_RIGHT;
  21179. private static FACE_FRONT;
  21180. private static FACE_BACK;
  21181. private static FACE_DOWN;
  21182. private static FACE_UP;
  21183. /**
  21184. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21185. *
  21186. * @param float32Array The source data.
  21187. * @param inputWidth The width of the input panorama.
  21188. * @param inputHeight The height of the input panorama.
  21189. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21190. * @return The cubemap data
  21191. */
  21192. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21193. private static CreateCubemapTexture;
  21194. private static CalcProjectionSpherical;
  21195. }
  21196. }
  21197. declare module BABYLON {
  21198. /**
  21199. * Helper class dealing with the extraction of spherical polynomial dataArray
  21200. * from a cube map.
  21201. */
  21202. export class CubeMapToSphericalPolynomialTools {
  21203. private static FileFaces;
  21204. /**
  21205. * Converts a texture to the according Spherical Polynomial data.
  21206. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21207. *
  21208. * @param texture The texture to extract the information from.
  21209. * @return The Spherical Polynomial data.
  21210. */
  21211. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21212. /**
  21213. * Converts a cubemap to the according Spherical Polynomial data.
  21214. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21215. *
  21216. * @param cubeInfo The Cube map to extract the information from.
  21217. * @return The Spherical Polynomial data.
  21218. */
  21219. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21220. }
  21221. }
  21222. declare module BABYLON {
  21223. interface BaseTexture {
  21224. /**
  21225. * Get the polynomial representation of the texture data.
  21226. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21227. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21228. */
  21229. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21230. }
  21231. }
  21232. declare module BABYLON {
  21233. /** @hidden */
  21234. export var pbrFragmentDeclaration: {
  21235. name: string;
  21236. shader: string;
  21237. };
  21238. }
  21239. declare module BABYLON {
  21240. /** @hidden */
  21241. export var pbrUboDeclaration: {
  21242. name: string;
  21243. shader: string;
  21244. };
  21245. }
  21246. declare module BABYLON {
  21247. /** @hidden */
  21248. export var pbrFragmentExtraDeclaration: {
  21249. name: string;
  21250. shader: string;
  21251. };
  21252. }
  21253. declare module BABYLON {
  21254. /** @hidden */
  21255. export var pbrFragmentSamplersDeclaration: {
  21256. name: string;
  21257. shader: string;
  21258. };
  21259. }
  21260. declare module BABYLON {
  21261. /** @hidden */
  21262. export var subSurfaceScatteringFunctions: {
  21263. name: string;
  21264. shader: string;
  21265. };
  21266. }
  21267. declare module BABYLON {
  21268. /** @hidden */
  21269. export var importanceSampling: {
  21270. name: string;
  21271. shader: string;
  21272. };
  21273. }
  21274. declare module BABYLON {
  21275. /** @hidden */
  21276. export var pbrHelperFunctions: {
  21277. name: string;
  21278. shader: string;
  21279. };
  21280. }
  21281. declare module BABYLON {
  21282. /** @hidden */
  21283. export var harmonicsFunctions: {
  21284. name: string;
  21285. shader: string;
  21286. };
  21287. }
  21288. declare module BABYLON {
  21289. /** @hidden */
  21290. export var pbrDirectLightingSetupFunctions: {
  21291. name: string;
  21292. shader: string;
  21293. };
  21294. }
  21295. declare module BABYLON {
  21296. /** @hidden */
  21297. export var pbrDirectLightingFalloffFunctions: {
  21298. name: string;
  21299. shader: string;
  21300. };
  21301. }
  21302. declare module BABYLON {
  21303. /** @hidden */
  21304. export var pbrBRDFFunctions: {
  21305. name: string;
  21306. shader: string;
  21307. };
  21308. }
  21309. declare module BABYLON {
  21310. /** @hidden */
  21311. export var hdrFilteringFunctions: {
  21312. name: string;
  21313. shader: string;
  21314. };
  21315. }
  21316. declare module BABYLON {
  21317. /** @hidden */
  21318. export var pbrDirectLightingFunctions: {
  21319. name: string;
  21320. shader: string;
  21321. };
  21322. }
  21323. declare module BABYLON {
  21324. /** @hidden */
  21325. export var pbrIBLFunctions: {
  21326. name: string;
  21327. shader: string;
  21328. };
  21329. }
  21330. declare module BABYLON {
  21331. /** @hidden */
  21332. export var pbrBlockAlbedoOpacity: {
  21333. name: string;
  21334. shader: string;
  21335. };
  21336. }
  21337. declare module BABYLON {
  21338. /** @hidden */
  21339. export var pbrBlockReflectivity: {
  21340. name: string;
  21341. shader: string;
  21342. };
  21343. }
  21344. declare module BABYLON {
  21345. /** @hidden */
  21346. export var pbrBlockAmbientOcclusion: {
  21347. name: string;
  21348. shader: string;
  21349. };
  21350. }
  21351. declare module BABYLON {
  21352. /** @hidden */
  21353. export var pbrBlockAlphaFresnel: {
  21354. name: string;
  21355. shader: string;
  21356. };
  21357. }
  21358. declare module BABYLON {
  21359. /** @hidden */
  21360. export var pbrBlockAnisotropic: {
  21361. name: string;
  21362. shader: string;
  21363. };
  21364. }
  21365. declare module BABYLON {
  21366. /** @hidden */
  21367. export var pbrBlockReflection: {
  21368. name: string;
  21369. shader: string;
  21370. };
  21371. }
  21372. declare module BABYLON {
  21373. /** @hidden */
  21374. export var pbrBlockSheen: {
  21375. name: string;
  21376. shader: string;
  21377. };
  21378. }
  21379. declare module BABYLON {
  21380. /** @hidden */
  21381. export var pbrBlockClearcoat: {
  21382. name: string;
  21383. shader: string;
  21384. };
  21385. }
  21386. declare module BABYLON {
  21387. /** @hidden */
  21388. export var pbrBlockSubSurface: {
  21389. name: string;
  21390. shader: string;
  21391. };
  21392. }
  21393. declare module BABYLON {
  21394. /** @hidden */
  21395. export var pbrBlockNormalGeometric: {
  21396. name: string;
  21397. shader: string;
  21398. };
  21399. }
  21400. declare module BABYLON {
  21401. /** @hidden */
  21402. export var pbrBlockNormalFinal: {
  21403. name: string;
  21404. shader: string;
  21405. };
  21406. }
  21407. declare module BABYLON {
  21408. /** @hidden */
  21409. export var pbrBlockLightmapInit: {
  21410. name: string;
  21411. shader: string;
  21412. };
  21413. }
  21414. declare module BABYLON {
  21415. /** @hidden */
  21416. export var pbrBlockGeometryInfo: {
  21417. name: string;
  21418. shader: string;
  21419. };
  21420. }
  21421. declare module BABYLON {
  21422. /** @hidden */
  21423. export var pbrBlockReflectance0: {
  21424. name: string;
  21425. shader: string;
  21426. };
  21427. }
  21428. declare module BABYLON {
  21429. /** @hidden */
  21430. export var pbrBlockReflectance: {
  21431. name: string;
  21432. shader: string;
  21433. };
  21434. }
  21435. declare module BABYLON {
  21436. /** @hidden */
  21437. export var pbrBlockDirectLighting: {
  21438. name: string;
  21439. shader: string;
  21440. };
  21441. }
  21442. declare module BABYLON {
  21443. /** @hidden */
  21444. export var pbrBlockFinalLitComponents: {
  21445. name: string;
  21446. shader: string;
  21447. };
  21448. }
  21449. declare module BABYLON {
  21450. /** @hidden */
  21451. export var pbrBlockFinalUnlitComponents: {
  21452. name: string;
  21453. shader: string;
  21454. };
  21455. }
  21456. declare module BABYLON {
  21457. /** @hidden */
  21458. export var pbrBlockFinalColorComposition: {
  21459. name: string;
  21460. shader: string;
  21461. };
  21462. }
  21463. declare module BABYLON {
  21464. /** @hidden */
  21465. export var pbrBlockImageProcessing: {
  21466. name: string;
  21467. shader: string;
  21468. };
  21469. }
  21470. declare module BABYLON {
  21471. /** @hidden */
  21472. export var pbrDebug: {
  21473. name: string;
  21474. shader: string;
  21475. };
  21476. }
  21477. declare module BABYLON {
  21478. /** @hidden */
  21479. export var pbrPixelShader: {
  21480. name: string;
  21481. shader: string;
  21482. };
  21483. }
  21484. declare module BABYLON {
  21485. /** @hidden */
  21486. export var pbrVertexDeclaration: {
  21487. name: string;
  21488. shader: string;
  21489. };
  21490. }
  21491. declare module BABYLON {
  21492. /** @hidden */
  21493. export var pbrVertexShader: {
  21494. name: string;
  21495. shader: string;
  21496. };
  21497. }
  21498. declare module BABYLON {
  21499. /**
  21500. * Manages the defines for the PBR Material.
  21501. * @hidden
  21502. */
  21503. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21504. PBR: boolean;
  21505. NUM_SAMPLES: string;
  21506. REALTIME_FILTERING: boolean;
  21507. MAINUV1: boolean;
  21508. MAINUV2: boolean;
  21509. UV1: boolean;
  21510. UV2: boolean;
  21511. ALBEDO: boolean;
  21512. GAMMAALBEDO: boolean;
  21513. ALBEDODIRECTUV: number;
  21514. VERTEXCOLOR: boolean;
  21515. DETAIL: boolean;
  21516. DETAILDIRECTUV: number;
  21517. DETAIL_NORMALBLENDMETHOD: number;
  21518. AMBIENT: boolean;
  21519. AMBIENTDIRECTUV: number;
  21520. AMBIENTINGRAYSCALE: boolean;
  21521. OPACITY: boolean;
  21522. VERTEXALPHA: boolean;
  21523. OPACITYDIRECTUV: number;
  21524. OPACITYRGB: boolean;
  21525. ALPHATEST: boolean;
  21526. DEPTHPREPASS: boolean;
  21527. ALPHABLEND: boolean;
  21528. ALPHAFROMALBEDO: boolean;
  21529. ALPHATESTVALUE: string;
  21530. SPECULAROVERALPHA: boolean;
  21531. RADIANCEOVERALPHA: boolean;
  21532. ALPHAFRESNEL: boolean;
  21533. LINEARALPHAFRESNEL: boolean;
  21534. PREMULTIPLYALPHA: boolean;
  21535. EMISSIVE: boolean;
  21536. EMISSIVEDIRECTUV: number;
  21537. REFLECTIVITY: boolean;
  21538. REFLECTIVITYDIRECTUV: number;
  21539. SPECULARTERM: boolean;
  21540. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21541. MICROSURFACEAUTOMATIC: boolean;
  21542. LODBASEDMICROSFURACE: boolean;
  21543. MICROSURFACEMAP: boolean;
  21544. MICROSURFACEMAPDIRECTUV: number;
  21545. METALLICWORKFLOW: boolean;
  21546. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21547. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21548. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21549. AOSTOREINMETALMAPRED: boolean;
  21550. METALLIC_REFLECTANCE: boolean;
  21551. METALLIC_REFLECTANCEDIRECTUV: number;
  21552. ENVIRONMENTBRDF: boolean;
  21553. ENVIRONMENTBRDF_RGBD: boolean;
  21554. NORMAL: boolean;
  21555. TANGENT: boolean;
  21556. BUMP: boolean;
  21557. BUMPDIRECTUV: number;
  21558. OBJECTSPACE_NORMALMAP: boolean;
  21559. PARALLAX: boolean;
  21560. PARALLAXOCCLUSION: boolean;
  21561. NORMALXYSCALE: boolean;
  21562. LIGHTMAP: boolean;
  21563. LIGHTMAPDIRECTUV: number;
  21564. USELIGHTMAPASSHADOWMAP: boolean;
  21565. GAMMALIGHTMAP: boolean;
  21566. RGBDLIGHTMAP: boolean;
  21567. REFLECTION: boolean;
  21568. REFLECTIONMAP_3D: boolean;
  21569. REFLECTIONMAP_SPHERICAL: boolean;
  21570. REFLECTIONMAP_PLANAR: boolean;
  21571. REFLECTIONMAP_CUBIC: boolean;
  21572. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21573. REFLECTIONMAP_PROJECTION: boolean;
  21574. REFLECTIONMAP_SKYBOX: boolean;
  21575. REFLECTIONMAP_EXPLICIT: boolean;
  21576. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21577. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21578. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21579. INVERTCUBICMAP: boolean;
  21580. USESPHERICALFROMREFLECTIONMAP: boolean;
  21581. USEIRRADIANCEMAP: boolean;
  21582. SPHERICAL_HARMONICS: boolean;
  21583. USESPHERICALINVERTEX: boolean;
  21584. REFLECTIONMAP_OPPOSITEZ: boolean;
  21585. LODINREFLECTIONALPHA: boolean;
  21586. GAMMAREFLECTION: boolean;
  21587. RGBDREFLECTION: boolean;
  21588. LINEARSPECULARREFLECTION: boolean;
  21589. RADIANCEOCCLUSION: boolean;
  21590. HORIZONOCCLUSION: boolean;
  21591. INSTANCES: boolean;
  21592. THIN_INSTANCES: boolean;
  21593. PREPASS: boolean;
  21594. PREPASS_IRRADIANCE: boolean;
  21595. PREPASS_IRRADIANCE_INDEX: number;
  21596. PREPASS_ALBEDO: boolean;
  21597. PREPASS_ALBEDO_INDEX: number;
  21598. PREPASS_DEPTHNORMAL: boolean;
  21599. PREPASS_DEPTHNORMAL_INDEX: number;
  21600. PREPASS_POSITION: boolean;
  21601. PREPASS_POSITION_INDEX: number;
  21602. PREPASS_VELOCITY: boolean;
  21603. PREPASS_VELOCITY_INDEX: number;
  21604. PREPASS_REFLECTIVITY: boolean;
  21605. PREPASS_REFLECTIVITY_INDEX: number;
  21606. SCENE_MRT_COUNT: number;
  21607. NUM_BONE_INFLUENCERS: number;
  21608. BonesPerMesh: number;
  21609. BONETEXTURE: boolean;
  21610. BONES_VELOCITY_ENABLED: boolean;
  21611. NONUNIFORMSCALING: boolean;
  21612. MORPHTARGETS: boolean;
  21613. MORPHTARGETS_NORMAL: boolean;
  21614. MORPHTARGETS_TANGENT: boolean;
  21615. MORPHTARGETS_UV: boolean;
  21616. NUM_MORPH_INFLUENCERS: number;
  21617. IMAGEPROCESSING: boolean;
  21618. VIGNETTE: boolean;
  21619. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21620. VIGNETTEBLENDMODEOPAQUE: boolean;
  21621. TONEMAPPING: boolean;
  21622. TONEMAPPING_ACES: boolean;
  21623. CONTRAST: boolean;
  21624. COLORCURVES: boolean;
  21625. COLORGRADING: boolean;
  21626. COLORGRADING3D: boolean;
  21627. SAMPLER3DGREENDEPTH: boolean;
  21628. SAMPLER3DBGRMAP: boolean;
  21629. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21630. EXPOSURE: boolean;
  21631. MULTIVIEW: boolean;
  21632. USEPHYSICALLIGHTFALLOFF: boolean;
  21633. USEGLTFLIGHTFALLOFF: boolean;
  21634. TWOSIDEDLIGHTING: boolean;
  21635. SHADOWFLOAT: boolean;
  21636. CLIPPLANE: boolean;
  21637. CLIPPLANE2: boolean;
  21638. CLIPPLANE3: boolean;
  21639. CLIPPLANE4: boolean;
  21640. CLIPPLANE5: boolean;
  21641. CLIPPLANE6: boolean;
  21642. POINTSIZE: boolean;
  21643. FOG: boolean;
  21644. LOGARITHMICDEPTH: boolean;
  21645. FORCENORMALFORWARD: boolean;
  21646. SPECULARAA: boolean;
  21647. CLEARCOAT: boolean;
  21648. CLEARCOAT_DEFAULTIOR: boolean;
  21649. CLEARCOAT_TEXTURE: boolean;
  21650. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21651. CLEARCOAT_TEXTUREDIRECTUV: number;
  21652. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21653. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21654. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21655. CLEARCOAT_BUMP: boolean;
  21656. CLEARCOAT_BUMPDIRECTUV: number;
  21657. CLEARCOAT_REMAP_F0: boolean;
  21658. CLEARCOAT_TINT: boolean;
  21659. CLEARCOAT_TINT_TEXTURE: boolean;
  21660. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21661. ANISOTROPIC: boolean;
  21662. ANISOTROPIC_TEXTURE: boolean;
  21663. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21664. BRDF_V_HEIGHT_CORRELATED: boolean;
  21665. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21666. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21667. SHEEN: boolean;
  21668. SHEEN_TEXTURE: boolean;
  21669. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21670. SHEEN_TEXTUREDIRECTUV: number;
  21671. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21672. SHEEN_LINKWITHALBEDO: boolean;
  21673. SHEEN_ROUGHNESS: boolean;
  21674. SHEEN_ALBEDOSCALING: boolean;
  21675. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21676. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21677. SUBSURFACE: boolean;
  21678. SS_REFRACTION: boolean;
  21679. SS_TRANSLUCENCY: boolean;
  21680. SS_SCATTERING: boolean;
  21681. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21682. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21683. SS_REFRACTIONMAP_3D: boolean;
  21684. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21685. SS_LODINREFRACTIONALPHA: boolean;
  21686. SS_GAMMAREFRACTION: boolean;
  21687. SS_RGBDREFRACTION: boolean;
  21688. SS_LINEARSPECULARREFRACTION: boolean;
  21689. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21690. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21691. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21692. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21693. UNLIT: boolean;
  21694. DEBUGMODE: number;
  21695. /**
  21696. * Initializes the PBR Material defines.
  21697. */
  21698. constructor();
  21699. /**
  21700. * Resets the PBR Material defines.
  21701. */
  21702. reset(): void;
  21703. }
  21704. /**
  21705. * The Physically based material base class of BJS.
  21706. *
  21707. * This offers the main features of a standard PBR material.
  21708. * For more information, please refer to the documentation :
  21709. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21710. */
  21711. export abstract class PBRBaseMaterial extends PushMaterial {
  21712. /**
  21713. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21714. */
  21715. static readonly PBRMATERIAL_OPAQUE: number;
  21716. /**
  21717. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21718. */
  21719. static readonly PBRMATERIAL_ALPHATEST: number;
  21720. /**
  21721. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21722. */
  21723. static readonly PBRMATERIAL_ALPHABLEND: number;
  21724. /**
  21725. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21726. * They are also discarded below the alpha cutoff threshold to improve performances.
  21727. */
  21728. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21729. /**
  21730. * Defines the default value of how much AO map is occluding the analytical lights
  21731. * (point spot...).
  21732. */
  21733. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21734. /**
  21735. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21736. */
  21737. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21738. /**
  21739. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21740. * to enhance interoperability with other engines.
  21741. */
  21742. static readonly LIGHTFALLOFF_GLTF: number;
  21743. /**
  21744. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21745. * to enhance interoperability with other materials.
  21746. */
  21747. static readonly LIGHTFALLOFF_STANDARD: number;
  21748. /**
  21749. * Intensity of the direct lights e.g. the four lights available in your scene.
  21750. * This impacts both the direct diffuse and specular highlights.
  21751. */
  21752. protected _directIntensity: number;
  21753. /**
  21754. * Intensity of the emissive part of the material.
  21755. * This helps controlling the emissive effect without modifying the emissive color.
  21756. */
  21757. protected _emissiveIntensity: number;
  21758. /**
  21759. * Intensity of the environment e.g. how much the environment will light the object
  21760. * either through harmonics for rough material or through the refelction for shiny ones.
  21761. */
  21762. protected _environmentIntensity: number;
  21763. /**
  21764. * This is a special control allowing the reduction of the specular highlights coming from the
  21765. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21766. */
  21767. protected _specularIntensity: number;
  21768. /**
  21769. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21770. */
  21771. private _lightingInfos;
  21772. /**
  21773. * Debug Control allowing disabling the bump map on this material.
  21774. */
  21775. protected _disableBumpMap: boolean;
  21776. /**
  21777. * AKA Diffuse Texture in standard nomenclature.
  21778. */
  21779. protected _albedoTexture: Nullable<BaseTexture>;
  21780. /**
  21781. * AKA Occlusion Texture in other nomenclature.
  21782. */
  21783. protected _ambientTexture: Nullable<BaseTexture>;
  21784. /**
  21785. * AKA Occlusion Texture Intensity in other nomenclature.
  21786. */
  21787. protected _ambientTextureStrength: number;
  21788. /**
  21789. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21790. * 1 means it completely occludes it
  21791. * 0 mean it has no impact
  21792. */
  21793. protected _ambientTextureImpactOnAnalyticalLights: number;
  21794. /**
  21795. * Stores the alpha values in a texture.
  21796. */
  21797. protected _opacityTexture: Nullable<BaseTexture>;
  21798. /**
  21799. * Stores the reflection values in a texture.
  21800. */
  21801. protected _reflectionTexture: Nullable<BaseTexture>;
  21802. /**
  21803. * Stores the emissive values in a texture.
  21804. */
  21805. protected _emissiveTexture: Nullable<BaseTexture>;
  21806. /**
  21807. * AKA Specular texture in other nomenclature.
  21808. */
  21809. protected _reflectivityTexture: Nullable<BaseTexture>;
  21810. /**
  21811. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21812. */
  21813. protected _metallicTexture: Nullable<BaseTexture>;
  21814. /**
  21815. * Specifies the metallic scalar of the metallic/roughness workflow.
  21816. * Can also be used to scale the metalness values of the metallic texture.
  21817. */
  21818. protected _metallic: Nullable<number>;
  21819. /**
  21820. * Specifies the roughness scalar of the metallic/roughness workflow.
  21821. * Can also be used to scale the roughness values of the metallic texture.
  21822. */
  21823. protected _roughness: Nullable<number>;
  21824. /**
  21825. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21826. * By default the indexOfrefraction is used to compute F0;
  21827. *
  21828. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21829. *
  21830. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21831. * F90 = metallicReflectanceColor;
  21832. */
  21833. protected _metallicF0Factor: number;
  21834. /**
  21835. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21836. * By default the F90 is always 1;
  21837. *
  21838. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21839. *
  21840. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21841. * F90 = metallicReflectanceColor;
  21842. */
  21843. protected _metallicReflectanceColor: Color3;
  21844. /**
  21845. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21846. * This is multiply against the scalar values defined in the material.
  21847. */
  21848. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21849. /**
  21850. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21851. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21852. */
  21853. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21854. /**
  21855. * Stores surface normal data used to displace a mesh in a texture.
  21856. */
  21857. protected _bumpTexture: Nullable<BaseTexture>;
  21858. /**
  21859. * Stores the pre-calculated light information of a mesh in a texture.
  21860. */
  21861. protected _lightmapTexture: Nullable<BaseTexture>;
  21862. /**
  21863. * The color of a material in ambient lighting.
  21864. */
  21865. protected _ambientColor: Color3;
  21866. /**
  21867. * AKA Diffuse Color in other nomenclature.
  21868. */
  21869. protected _albedoColor: Color3;
  21870. /**
  21871. * AKA Specular Color in other nomenclature.
  21872. */
  21873. protected _reflectivityColor: Color3;
  21874. /**
  21875. * The color applied when light is reflected from a material.
  21876. */
  21877. protected _reflectionColor: Color3;
  21878. /**
  21879. * The color applied when light is emitted from a material.
  21880. */
  21881. protected _emissiveColor: Color3;
  21882. /**
  21883. * AKA Glossiness in other nomenclature.
  21884. */
  21885. protected _microSurface: number;
  21886. /**
  21887. * Specifies that the material will use the light map as a show map.
  21888. */
  21889. protected _useLightmapAsShadowmap: boolean;
  21890. /**
  21891. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21892. * makes the reflect vector face the model (under horizon).
  21893. */
  21894. protected _useHorizonOcclusion: boolean;
  21895. /**
  21896. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21897. * too much the area relying on ambient texture to define their ambient occlusion.
  21898. */
  21899. protected _useRadianceOcclusion: boolean;
  21900. /**
  21901. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21902. */
  21903. protected _useAlphaFromAlbedoTexture: boolean;
  21904. /**
  21905. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21906. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21907. */
  21908. protected _useSpecularOverAlpha: boolean;
  21909. /**
  21910. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21911. */
  21912. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21913. /**
  21914. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21915. */
  21916. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21917. /**
  21918. * Specifies if the metallic texture contains the roughness information in its green channel.
  21919. */
  21920. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21921. /**
  21922. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21923. */
  21924. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21925. /**
  21926. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21927. */
  21928. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21929. /**
  21930. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21931. */
  21932. protected _useAmbientInGrayScale: boolean;
  21933. /**
  21934. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21935. * The material will try to infer what glossiness each pixel should be.
  21936. */
  21937. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21938. /**
  21939. * Defines the falloff type used in this material.
  21940. * It by default is Physical.
  21941. */
  21942. protected _lightFalloff: number;
  21943. /**
  21944. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21945. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21946. */
  21947. protected _useRadianceOverAlpha: boolean;
  21948. /**
  21949. * Allows using an object space normal map (instead of tangent space).
  21950. */
  21951. protected _useObjectSpaceNormalMap: boolean;
  21952. /**
  21953. * Allows using the bump map in parallax mode.
  21954. */
  21955. protected _useParallax: boolean;
  21956. /**
  21957. * Allows using the bump map in parallax occlusion mode.
  21958. */
  21959. protected _useParallaxOcclusion: boolean;
  21960. /**
  21961. * Controls the scale bias of the parallax mode.
  21962. */
  21963. protected _parallaxScaleBias: number;
  21964. /**
  21965. * If sets to true, disables all the lights affecting the material.
  21966. */
  21967. protected _disableLighting: boolean;
  21968. /**
  21969. * Number of Simultaneous lights allowed on the material.
  21970. */
  21971. protected _maxSimultaneousLights: number;
  21972. /**
  21973. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21974. */
  21975. protected _invertNormalMapX: boolean;
  21976. /**
  21977. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21978. */
  21979. protected _invertNormalMapY: boolean;
  21980. /**
  21981. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21982. */
  21983. protected _twoSidedLighting: boolean;
  21984. /**
  21985. * Defines the alpha limits in alpha test mode.
  21986. */
  21987. protected _alphaCutOff: number;
  21988. /**
  21989. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21990. */
  21991. protected _forceAlphaTest: boolean;
  21992. /**
  21993. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21994. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21995. */
  21996. protected _useAlphaFresnel: boolean;
  21997. /**
  21998. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21999. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22000. */
  22001. protected _useLinearAlphaFresnel: boolean;
  22002. /**
  22003. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22004. * from cos thetav and roughness:
  22005. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22006. */
  22007. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22008. /**
  22009. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22010. */
  22011. protected _forceIrradianceInFragment: boolean;
  22012. private _realTimeFiltering;
  22013. /**
  22014. * Enables realtime filtering on the texture.
  22015. */
  22016. get realTimeFiltering(): boolean;
  22017. set realTimeFiltering(b: boolean);
  22018. private _realTimeFilteringQuality;
  22019. /**
  22020. * Quality switch for realtime filtering
  22021. */
  22022. get realTimeFilteringQuality(): number;
  22023. set realTimeFilteringQuality(n: number);
  22024. /**
  22025. * Can this material render to several textures at once
  22026. */
  22027. get canRenderToMRT(): boolean;
  22028. /**
  22029. * Force normal to face away from face.
  22030. */
  22031. protected _forceNormalForward: boolean;
  22032. /**
  22033. * Enables specular anti aliasing in the PBR shader.
  22034. * It will both interacts on the Geometry for analytical and IBL lighting.
  22035. * It also prefilter the roughness map based on the bump values.
  22036. */
  22037. protected _enableSpecularAntiAliasing: boolean;
  22038. /**
  22039. * Default configuration related to image processing available in the PBR Material.
  22040. */
  22041. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22042. /**
  22043. * Keep track of the image processing observer to allow dispose and replace.
  22044. */
  22045. private _imageProcessingObserver;
  22046. /**
  22047. * Attaches a new image processing configuration to the PBR Material.
  22048. * @param configuration
  22049. */
  22050. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22051. /**
  22052. * Stores the available render targets.
  22053. */
  22054. private _renderTargets;
  22055. /**
  22056. * Sets the global ambient color for the material used in lighting calculations.
  22057. */
  22058. private _globalAmbientColor;
  22059. /**
  22060. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22061. */
  22062. private _useLogarithmicDepth;
  22063. /**
  22064. * If set to true, no lighting calculations will be applied.
  22065. */
  22066. private _unlit;
  22067. private _debugMode;
  22068. /**
  22069. * @hidden
  22070. * This is reserved for the inspector.
  22071. * Defines the material debug mode.
  22072. * It helps seeing only some components of the material while troubleshooting.
  22073. */
  22074. debugMode: number;
  22075. /**
  22076. * @hidden
  22077. * This is reserved for the inspector.
  22078. * Specify from where on screen the debug mode should start.
  22079. * The value goes from -1 (full screen) to 1 (not visible)
  22080. * It helps with side by side comparison against the final render
  22081. * This defaults to -1
  22082. */
  22083. private debugLimit;
  22084. /**
  22085. * @hidden
  22086. * This is reserved for the inspector.
  22087. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22088. * You can use the factor to better multiply the final value.
  22089. */
  22090. private debugFactor;
  22091. /**
  22092. * Defines the clear coat layer parameters for the material.
  22093. */
  22094. readonly clearCoat: PBRClearCoatConfiguration;
  22095. /**
  22096. * Defines the anisotropic parameters for the material.
  22097. */
  22098. readonly anisotropy: PBRAnisotropicConfiguration;
  22099. /**
  22100. * Defines the BRDF parameters for the material.
  22101. */
  22102. readonly brdf: PBRBRDFConfiguration;
  22103. /**
  22104. * Defines the Sheen parameters for the material.
  22105. */
  22106. readonly sheen: PBRSheenConfiguration;
  22107. /**
  22108. * Defines the SubSurface parameters for the material.
  22109. */
  22110. readonly subSurface: PBRSubSurfaceConfiguration;
  22111. /**
  22112. * Defines additionnal PrePass parameters for the material.
  22113. */
  22114. readonly prePassConfiguration: PrePassConfiguration;
  22115. /**
  22116. * Defines the detail map parameters for the material.
  22117. */
  22118. readonly detailMap: DetailMapConfiguration;
  22119. protected _rebuildInParallel: boolean;
  22120. /**
  22121. * Instantiates a new PBRMaterial instance.
  22122. *
  22123. * @param name The material name
  22124. * @param scene The scene the material will be use in.
  22125. */
  22126. constructor(name: string, scene: Scene);
  22127. /**
  22128. * Gets a boolean indicating that current material needs to register RTT
  22129. */
  22130. get hasRenderTargetTextures(): boolean;
  22131. /**
  22132. * Gets the name of the material class.
  22133. */
  22134. getClassName(): string;
  22135. /**
  22136. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22137. */
  22138. get useLogarithmicDepth(): boolean;
  22139. /**
  22140. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22141. */
  22142. set useLogarithmicDepth(value: boolean);
  22143. /**
  22144. * Returns true if alpha blending should be disabled.
  22145. */
  22146. protected get _disableAlphaBlending(): boolean;
  22147. /**
  22148. * Specifies whether or not this material should be rendered in alpha blend mode.
  22149. */
  22150. needAlphaBlending(): boolean;
  22151. /**
  22152. * Specifies whether or not this material should be rendered in alpha test mode.
  22153. */
  22154. needAlphaTesting(): boolean;
  22155. /**
  22156. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22157. */
  22158. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22159. /**
  22160. * Specifies whether or not there is a usable alpha channel for transparency.
  22161. */
  22162. protected _hasAlphaChannel(): boolean;
  22163. /**
  22164. * Gets the texture used for the alpha test.
  22165. */
  22166. getAlphaTestTexture(): Nullable<BaseTexture>;
  22167. /**
  22168. * Specifies that the submesh is ready to be used.
  22169. * @param mesh - BJS mesh.
  22170. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22171. * @param useInstances - Specifies that instances should be used.
  22172. * @returns - boolean indicating that the submesh is ready or not.
  22173. */
  22174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22175. /**
  22176. * Specifies if the material uses metallic roughness workflow.
  22177. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22178. */
  22179. isMetallicWorkflow(): boolean;
  22180. private _prepareEffect;
  22181. private _prepareDefines;
  22182. /**
  22183. * Force shader compilation
  22184. */
  22185. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22186. /**
  22187. * Initializes the uniform buffer layout for the shader.
  22188. */
  22189. buildUniformLayout(): void;
  22190. /**
  22191. * Unbinds the material from the mesh
  22192. */
  22193. unbind(): void;
  22194. /**
  22195. * Binds the submesh data.
  22196. * @param world - The world matrix.
  22197. * @param mesh - The BJS mesh.
  22198. * @param subMesh - A submesh of the BJS mesh.
  22199. */
  22200. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22201. /**
  22202. * Returns the animatable textures.
  22203. * @returns - Array of animatable textures.
  22204. */
  22205. getAnimatables(): IAnimatable[];
  22206. /**
  22207. * Returns the texture used for reflections.
  22208. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22209. */
  22210. private _getReflectionTexture;
  22211. /**
  22212. * Returns an array of the actively used textures.
  22213. * @returns - Array of BaseTextures
  22214. */
  22215. getActiveTextures(): BaseTexture[];
  22216. /**
  22217. * Checks to see if a texture is used in the material.
  22218. * @param texture - Base texture to use.
  22219. * @returns - Boolean specifying if a texture is used in the material.
  22220. */
  22221. hasTexture(texture: BaseTexture): boolean;
  22222. /**
  22223. * Sets the required values to the prepass renderer.
  22224. * @param prePassRenderer defines the prepass renderer to setup
  22225. */
  22226. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22227. /**
  22228. * Disposes the resources of the material.
  22229. * @param forceDisposeEffect - Forces the disposal of effects.
  22230. * @param forceDisposeTextures - Forces the disposal of all textures.
  22231. */
  22232. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22233. }
  22234. }
  22235. declare module BABYLON {
  22236. /**
  22237. * The Physically based material of BJS.
  22238. *
  22239. * This offers the main features of a standard PBR material.
  22240. * For more information, please refer to the documentation :
  22241. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22242. */
  22243. export class PBRMaterial extends PBRBaseMaterial {
  22244. /**
  22245. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22246. */
  22247. static readonly PBRMATERIAL_OPAQUE: number;
  22248. /**
  22249. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22250. */
  22251. static readonly PBRMATERIAL_ALPHATEST: number;
  22252. /**
  22253. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22254. */
  22255. static readonly PBRMATERIAL_ALPHABLEND: number;
  22256. /**
  22257. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22258. * They are also discarded below the alpha cutoff threshold to improve performances.
  22259. */
  22260. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22261. /**
  22262. * Defines the default value of how much AO map is occluding the analytical lights
  22263. * (point spot...).
  22264. */
  22265. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22266. /**
  22267. * Intensity of the direct lights e.g. the four lights available in your scene.
  22268. * This impacts both the direct diffuse and specular highlights.
  22269. */
  22270. directIntensity: number;
  22271. /**
  22272. * Intensity of the emissive part of the material.
  22273. * This helps controlling the emissive effect without modifying the emissive color.
  22274. */
  22275. emissiveIntensity: number;
  22276. /**
  22277. * Intensity of the environment e.g. how much the environment will light the object
  22278. * either through harmonics for rough material or through the refelction for shiny ones.
  22279. */
  22280. environmentIntensity: number;
  22281. /**
  22282. * This is a special control allowing the reduction of the specular highlights coming from the
  22283. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22284. */
  22285. specularIntensity: number;
  22286. /**
  22287. * Debug Control allowing disabling the bump map on this material.
  22288. */
  22289. disableBumpMap: boolean;
  22290. /**
  22291. * AKA Diffuse Texture in standard nomenclature.
  22292. */
  22293. albedoTexture: BaseTexture;
  22294. /**
  22295. * AKA Occlusion Texture in other nomenclature.
  22296. */
  22297. ambientTexture: BaseTexture;
  22298. /**
  22299. * AKA Occlusion Texture Intensity in other nomenclature.
  22300. */
  22301. ambientTextureStrength: number;
  22302. /**
  22303. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22304. * 1 means it completely occludes it
  22305. * 0 mean it has no impact
  22306. */
  22307. ambientTextureImpactOnAnalyticalLights: number;
  22308. /**
  22309. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22310. */
  22311. opacityTexture: BaseTexture;
  22312. /**
  22313. * Stores the reflection values in a texture.
  22314. */
  22315. reflectionTexture: Nullable<BaseTexture>;
  22316. /**
  22317. * Stores the emissive values in a texture.
  22318. */
  22319. emissiveTexture: BaseTexture;
  22320. /**
  22321. * AKA Specular texture in other nomenclature.
  22322. */
  22323. reflectivityTexture: BaseTexture;
  22324. /**
  22325. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22326. */
  22327. metallicTexture: BaseTexture;
  22328. /**
  22329. * Specifies the metallic scalar of the metallic/roughness workflow.
  22330. * Can also be used to scale the metalness values of the metallic texture.
  22331. */
  22332. metallic: Nullable<number>;
  22333. /**
  22334. * Specifies the roughness scalar of the metallic/roughness workflow.
  22335. * Can also be used to scale the roughness values of the metallic texture.
  22336. */
  22337. roughness: Nullable<number>;
  22338. /**
  22339. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22340. * By default the indexOfrefraction is used to compute F0;
  22341. *
  22342. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22343. *
  22344. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22345. * F90 = metallicReflectanceColor;
  22346. */
  22347. metallicF0Factor: number;
  22348. /**
  22349. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22350. * By default the F90 is always 1;
  22351. *
  22352. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22353. *
  22354. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22355. * F90 = metallicReflectanceColor;
  22356. */
  22357. metallicReflectanceColor: Color3;
  22358. /**
  22359. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22360. * This is multiply against the scalar values defined in the material.
  22361. */
  22362. metallicReflectanceTexture: Nullable<BaseTexture>;
  22363. /**
  22364. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22365. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22366. */
  22367. microSurfaceTexture: BaseTexture;
  22368. /**
  22369. * Stores surface normal data used to displace a mesh in a texture.
  22370. */
  22371. bumpTexture: BaseTexture;
  22372. /**
  22373. * Stores the pre-calculated light information of a mesh in a texture.
  22374. */
  22375. lightmapTexture: BaseTexture;
  22376. /**
  22377. * Stores the refracted light information in a texture.
  22378. */
  22379. get refractionTexture(): Nullable<BaseTexture>;
  22380. set refractionTexture(value: Nullable<BaseTexture>);
  22381. /**
  22382. * The color of a material in ambient lighting.
  22383. */
  22384. ambientColor: Color3;
  22385. /**
  22386. * AKA Diffuse Color in other nomenclature.
  22387. */
  22388. albedoColor: Color3;
  22389. /**
  22390. * AKA Specular Color in other nomenclature.
  22391. */
  22392. reflectivityColor: Color3;
  22393. /**
  22394. * The color reflected from the material.
  22395. */
  22396. reflectionColor: Color3;
  22397. /**
  22398. * The color emitted from the material.
  22399. */
  22400. emissiveColor: Color3;
  22401. /**
  22402. * AKA Glossiness in other nomenclature.
  22403. */
  22404. microSurface: number;
  22405. /**
  22406. * Index of refraction of the material base layer.
  22407. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22408. *
  22409. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22410. *
  22411. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22412. */
  22413. get indexOfRefraction(): number;
  22414. set indexOfRefraction(value: number);
  22415. /**
  22416. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22417. */
  22418. get invertRefractionY(): boolean;
  22419. set invertRefractionY(value: boolean);
  22420. /**
  22421. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22422. * Materials half opaque for instance using refraction could benefit from this control.
  22423. */
  22424. get linkRefractionWithTransparency(): boolean;
  22425. set linkRefractionWithTransparency(value: boolean);
  22426. /**
  22427. * If true, the light map contains occlusion information instead of lighting info.
  22428. */
  22429. useLightmapAsShadowmap: boolean;
  22430. /**
  22431. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22432. */
  22433. useAlphaFromAlbedoTexture: boolean;
  22434. /**
  22435. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22436. */
  22437. forceAlphaTest: boolean;
  22438. /**
  22439. * Defines the alpha limits in alpha test mode.
  22440. */
  22441. alphaCutOff: number;
  22442. /**
  22443. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22444. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22445. */
  22446. useSpecularOverAlpha: boolean;
  22447. /**
  22448. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22449. */
  22450. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22451. /**
  22452. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22453. */
  22454. useRoughnessFromMetallicTextureAlpha: boolean;
  22455. /**
  22456. * Specifies if the metallic texture contains the roughness information in its green channel.
  22457. */
  22458. useRoughnessFromMetallicTextureGreen: boolean;
  22459. /**
  22460. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22461. */
  22462. useMetallnessFromMetallicTextureBlue: boolean;
  22463. /**
  22464. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22465. */
  22466. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22467. /**
  22468. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22469. */
  22470. useAmbientInGrayScale: boolean;
  22471. /**
  22472. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22473. * The material will try to infer what glossiness each pixel should be.
  22474. */
  22475. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22476. /**
  22477. * BJS is using an harcoded light falloff based on a manually sets up range.
  22478. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22479. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22480. */
  22481. get usePhysicalLightFalloff(): boolean;
  22482. /**
  22483. * BJS is using an harcoded light falloff based on a manually sets up range.
  22484. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22485. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22486. */
  22487. set usePhysicalLightFalloff(value: boolean);
  22488. /**
  22489. * In order to support the falloff compatibility with gltf, a special mode has been added
  22490. * to reproduce the gltf light falloff.
  22491. */
  22492. get useGLTFLightFalloff(): boolean;
  22493. /**
  22494. * In order to support the falloff compatibility with gltf, a special mode has been added
  22495. * to reproduce the gltf light falloff.
  22496. */
  22497. set useGLTFLightFalloff(value: boolean);
  22498. /**
  22499. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22500. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22501. */
  22502. useRadianceOverAlpha: boolean;
  22503. /**
  22504. * Allows using an object space normal map (instead of tangent space).
  22505. */
  22506. useObjectSpaceNormalMap: boolean;
  22507. /**
  22508. * Allows using the bump map in parallax mode.
  22509. */
  22510. useParallax: boolean;
  22511. /**
  22512. * Allows using the bump map in parallax occlusion mode.
  22513. */
  22514. useParallaxOcclusion: boolean;
  22515. /**
  22516. * Controls the scale bias of the parallax mode.
  22517. */
  22518. parallaxScaleBias: number;
  22519. /**
  22520. * If sets to true, disables all the lights affecting the material.
  22521. */
  22522. disableLighting: boolean;
  22523. /**
  22524. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22525. */
  22526. forceIrradianceInFragment: boolean;
  22527. /**
  22528. * Number of Simultaneous lights allowed on the material.
  22529. */
  22530. maxSimultaneousLights: number;
  22531. /**
  22532. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22533. */
  22534. invertNormalMapX: boolean;
  22535. /**
  22536. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22537. */
  22538. invertNormalMapY: boolean;
  22539. /**
  22540. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22541. */
  22542. twoSidedLighting: boolean;
  22543. /**
  22544. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22545. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22546. */
  22547. useAlphaFresnel: boolean;
  22548. /**
  22549. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22550. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22551. */
  22552. useLinearAlphaFresnel: boolean;
  22553. /**
  22554. * Let user defines the brdf lookup texture used for IBL.
  22555. * A default 8bit version is embedded but you could point at :
  22556. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22557. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22558. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22559. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22560. */
  22561. environmentBRDFTexture: Nullable<BaseTexture>;
  22562. /**
  22563. * Force normal to face away from face.
  22564. */
  22565. forceNormalForward: boolean;
  22566. /**
  22567. * Enables specular anti aliasing in the PBR shader.
  22568. * It will both interacts on the Geometry for analytical and IBL lighting.
  22569. * It also prefilter the roughness map based on the bump values.
  22570. */
  22571. enableSpecularAntiAliasing: boolean;
  22572. /**
  22573. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22574. * makes the reflect vector face the model (under horizon).
  22575. */
  22576. useHorizonOcclusion: boolean;
  22577. /**
  22578. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22579. * too much the area relying on ambient texture to define their ambient occlusion.
  22580. */
  22581. useRadianceOcclusion: boolean;
  22582. /**
  22583. * If set to true, no lighting calculations will be applied.
  22584. */
  22585. unlit: boolean;
  22586. /**
  22587. * Gets the image processing configuration used either in this material.
  22588. */
  22589. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22590. /**
  22591. * Sets the Default image processing configuration used either in the this material.
  22592. *
  22593. * If sets to null, the scene one is in use.
  22594. */
  22595. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22596. /**
  22597. * Gets wether the color curves effect is enabled.
  22598. */
  22599. get cameraColorCurvesEnabled(): boolean;
  22600. /**
  22601. * Sets wether the color curves effect is enabled.
  22602. */
  22603. set cameraColorCurvesEnabled(value: boolean);
  22604. /**
  22605. * Gets wether the color grading effect is enabled.
  22606. */
  22607. get cameraColorGradingEnabled(): boolean;
  22608. /**
  22609. * Gets wether the color grading effect is enabled.
  22610. */
  22611. set cameraColorGradingEnabled(value: boolean);
  22612. /**
  22613. * Gets wether tonemapping is enabled or not.
  22614. */
  22615. get cameraToneMappingEnabled(): boolean;
  22616. /**
  22617. * Sets wether tonemapping is enabled or not
  22618. */
  22619. set cameraToneMappingEnabled(value: boolean);
  22620. /**
  22621. * The camera exposure used on this material.
  22622. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22623. * This corresponds to a photographic exposure.
  22624. */
  22625. get cameraExposure(): number;
  22626. /**
  22627. * The camera exposure used on this material.
  22628. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22629. * This corresponds to a photographic exposure.
  22630. */
  22631. set cameraExposure(value: number);
  22632. /**
  22633. * Gets The camera contrast used on this material.
  22634. */
  22635. get cameraContrast(): number;
  22636. /**
  22637. * Sets The camera contrast used on this material.
  22638. */
  22639. set cameraContrast(value: number);
  22640. /**
  22641. * Gets the Color Grading 2D Lookup Texture.
  22642. */
  22643. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22644. /**
  22645. * Sets the Color Grading 2D Lookup Texture.
  22646. */
  22647. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22648. /**
  22649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22651. * 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;
  22652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22653. */
  22654. get cameraColorCurves(): Nullable<ColorCurves>;
  22655. /**
  22656. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22657. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22658. * 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;
  22659. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22660. */
  22661. set cameraColorCurves(value: Nullable<ColorCurves>);
  22662. /**
  22663. * Instantiates a new PBRMaterial instance.
  22664. *
  22665. * @param name The material name
  22666. * @param scene The scene the material will be use in.
  22667. */
  22668. constructor(name: string, scene: Scene);
  22669. /**
  22670. * Returns the name of this material class.
  22671. */
  22672. getClassName(): string;
  22673. /**
  22674. * Makes a duplicate of the current material.
  22675. * @param name - name to use for the new material.
  22676. */
  22677. clone(name: string): PBRMaterial;
  22678. /**
  22679. * Serializes this PBR Material.
  22680. * @returns - An object with the serialized material.
  22681. */
  22682. serialize(): any;
  22683. /**
  22684. * Parses a PBR Material from a serialized object.
  22685. * @param source - Serialized object.
  22686. * @param scene - BJS scene instance.
  22687. * @param rootUrl - url for the scene object
  22688. * @returns - PBRMaterial
  22689. */
  22690. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22691. }
  22692. }
  22693. declare module BABYLON {
  22694. /** @hidden */
  22695. export var mrtFragmentDeclaration: {
  22696. name: string;
  22697. shader: string;
  22698. };
  22699. }
  22700. declare module BABYLON {
  22701. /** @hidden */
  22702. export var geometryPixelShader: {
  22703. name: string;
  22704. shader: string;
  22705. };
  22706. }
  22707. declare module BABYLON {
  22708. /** @hidden */
  22709. export var instancesDeclaration: {
  22710. name: string;
  22711. shader: string;
  22712. };
  22713. }
  22714. declare module BABYLON {
  22715. /** @hidden */
  22716. export var geometryVertexShader: {
  22717. name: string;
  22718. shader: string;
  22719. };
  22720. }
  22721. declare module BABYLON {
  22722. /** @hidden */
  22723. interface ISavedTransformationMatrix {
  22724. world: Matrix;
  22725. viewProjection: Matrix;
  22726. }
  22727. /**
  22728. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22729. */
  22730. export class GeometryBufferRenderer {
  22731. /**
  22732. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22733. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22734. */
  22735. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22736. /**
  22737. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22738. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22739. */
  22740. static readonly POSITION_TEXTURE_TYPE: number;
  22741. /**
  22742. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22743. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22744. */
  22745. static readonly VELOCITY_TEXTURE_TYPE: number;
  22746. /**
  22747. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22748. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22749. */
  22750. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22751. /**
  22752. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22753. * in order to compute objects velocities when enableVelocity is set to "true"
  22754. * @hidden
  22755. */
  22756. _previousTransformationMatrices: {
  22757. [index: number]: ISavedTransformationMatrix;
  22758. };
  22759. /**
  22760. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22761. * in order to compute objects velocities when enableVelocity is set to "true"
  22762. * @hidden
  22763. */
  22764. _previousBonesTransformationMatrices: {
  22765. [index: number]: Float32Array;
  22766. };
  22767. /**
  22768. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22769. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22770. */
  22771. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22772. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22773. renderTransparentMeshes: boolean;
  22774. private _scene;
  22775. private _resizeObserver;
  22776. private _multiRenderTarget;
  22777. private _ratio;
  22778. private _enablePosition;
  22779. private _enableVelocity;
  22780. private _enableReflectivity;
  22781. private _positionIndex;
  22782. private _velocityIndex;
  22783. private _reflectivityIndex;
  22784. private _depthNormalIndex;
  22785. private _linkedWithPrePass;
  22786. private _prePassRenderer;
  22787. private _attachments;
  22788. protected _effect: Effect;
  22789. protected _cachedDefines: string;
  22790. /**
  22791. * @hidden
  22792. * Sets up internal structures to share outputs with PrePassRenderer
  22793. * This method should only be called by the PrePassRenderer itself
  22794. */
  22795. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22796. /**
  22797. * @hidden
  22798. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22799. * This method should only be called by the PrePassRenderer itself
  22800. */
  22801. _unlinkPrePassRenderer(): void;
  22802. /**
  22803. * @hidden
  22804. * Resets the geometry buffer layout
  22805. */
  22806. _resetLayout(): void;
  22807. /**
  22808. * @hidden
  22809. * Replaces a texture in the geometry buffer renderer
  22810. * Useful when linking textures of the prepass renderer
  22811. */
  22812. _forceTextureType(geometryBufferType: number, index: number): void;
  22813. /**
  22814. * @hidden
  22815. * Sets texture attachments
  22816. * Useful when linking textures of the prepass renderer
  22817. */
  22818. _setAttachments(attachments: number[]): void;
  22819. /**
  22820. * @hidden
  22821. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22822. * Useful when linking textures of the prepass renderer
  22823. */
  22824. _linkInternalTexture(internalTexture: InternalTexture): void;
  22825. /**
  22826. * Gets the render list (meshes to be rendered) used in the G buffer.
  22827. */
  22828. get renderList(): Nullable<AbstractMesh[]>;
  22829. /**
  22830. * Set the render list (meshes to be rendered) used in the G buffer.
  22831. */
  22832. set renderList(meshes: Nullable<AbstractMesh[]>);
  22833. /**
  22834. * Gets wether or not G buffer are supported by the running hardware.
  22835. * This requires draw buffer supports
  22836. */
  22837. get isSupported(): boolean;
  22838. /**
  22839. * Returns the index of the given texture type in the G-Buffer textures array
  22840. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22841. * @returns the index of the given texture type in the G-Buffer textures array
  22842. */
  22843. getTextureIndex(textureType: number): number;
  22844. /**
  22845. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22846. */
  22847. get enablePosition(): boolean;
  22848. /**
  22849. * Sets whether or not objects positions are enabled for the G buffer.
  22850. */
  22851. set enablePosition(enable: boolean);
  22852. /**
  22853. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22854. */
  22855. get enableVelocity(): boolean;
  22856. /**
  22857. * Sets wether or not objects velocities are enabled for the G buffer.
  22858. */
  22859. set enableVelocity(enable: boolean);
  22860. /**
  22861. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22862. */
  22863. get enableReflectivity(): boolean;
  22864. /**
  22865. * Sets wether or not objects roughness are enabled for the G buffer.
  22866. */
  22867. set enableReflectivity(enable: boolean);
  22868. /**
  22869. * Gets the scene associated with the buffer.
  22870. */
  22871. get scene(): Scene;
  22872. /**
  22873. * Gets the ratio used by the buffer during its creation.
  22874. * How big is the buffer related to the main canvas.
  22875. */
  22876. get ratio(): number;
  22877. /** @hidden */
  22878. static _SceneComponentInitialization: (scene: Scene) => void;
  22879. /**
  22880. * Creates a new G Buffer for the scene
  22881. * @param scene The scene the buffer belongs to
  22882. * @param ratio How big is the buffer related to the main canvas.
  22883. */
  22884. constructor(scene: Scene, ratio?: number);
  22885. /**
  22886. * Checks wether everything is ready to render a submesh to the G buffer.
  22887. * @param subMesh the submesh to check readiness for
  22888. * @param useInstances is the mesh drawn using instance or not
  22889. * @returns true if ready otherwise false
  22890. */
  22891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22892. /**
  22893. * Gets the current underlying G Buffer.
  22894. * @returns the buffer
  22895. */
  22896. getGBuffer(): MultiRenderTarget;
  22897. /**
  22898. * Gets the number of samples used to render the buffer (anti aliasing).
  22899. */
  22900. get samples(): number;
  22901. /**
  22902. * Sets the number of samples used to render the buffer (anti aliasing).
  22903. */
  22904. set samples(value: number);
  22905. /**
  22906. * Disposes the renderer and frees up associated resources.
  22907. */
  22908. dispose(): void;
  22909. private _assignRenderTargetIndices;
  22910. protected _createRenderTargets(): void;
  22911. private _copyBonesTransformationMatrices;
  22912. }
  22913. }
  22914. declare module BABYLON {
  22915. /**
  22916. * Renders a pre pass of the scene
  22917. * This means every mesh in the scene will be rendered to a render target texture
  22918. * And then this texture will be composited to the rendering canvas with post processes
  22919. * It is necessary for effects like subsurface scattering or deferred shading
  22920. */
  22921. export class PrePassRenderer {
  22922. /** @hidden */
  22923. static _SceneComponentInitialization: (scene: Scene) => void;
  22924. private _textureFormats;
  22925. /**
  22926. * To save performance, we can excluded skinned meshes from the prepass
  22927. */
  22928. excludedSkinnedMesh: AbstractMesh[];
  22929. /**
  22930. * Force material to be excluded from the prepass
  22931. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22932. * and you don't want a material to show in the effect.
  22933. */
  22934. excludedMaterials: Material[];
  22935. private _textureIndices;
  22936. private _scene;
  22937. private _engine;
  22938. private _isDirty;
  22939. /**
  22940. * Number of textures in the multi render target texture where the scene is directly rendered
  22941. */
  22942. mrtCount: number;
  22943. /**
  22944. * The render target where the scene is directly rendered
  22945. */
  22946. prePassRT: MultiRenderTarget;
  22947. private _multiRenderAttachments;
  22948. private _defaultAttachments;
  22949. private _postProcesses;
  22950. private readonly _clearColor;
  22951. /**
  22952. * Image processing post process for composition
  22953. */
  22954. imageProcessingPostProcess: ImageProcessingPostProcess;
  22955. /**
  22956. * Configuration for prepass effects
  22957. */
  22958. private _effectConfigurations;
  22959. private _mrtFormats;
  22960. private _mrtLayout;
  22961. private _enabled;
  22962. /**
  22963. * Indicates if the prepass is enabled
  22964. */
  22965. get enabled(): boolean;
  22966. /**
  22967. * How many samples are used for MSAA of the scene render target
  22968. */
  22969. get samples(): number;
  22970. set samples(n: number);
  22971. private _geometryBuffer;
  22972. private _useGeometryBufferFallback;
  22973. /**
  22974. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22975. */
  22976. get useGeometryBufferFallback(): boolean;
  22977. set useGeometryBufferFallback(value: boolean);
  22978. /**
  22979. * Set to true to disable gamma transform in PrePass.
  22980. * Can be useful in case you already proceed to gamma transform on a material level
  22981. * and your post processes don't need to be in linear color space.
  22982. */
  22983. disableGammaTransform: boolean;
  22984. /**
  22985. * Instanciates a prepass renderer
  22986. * @param scene The scene
  22987. */
  22988. constructor(scene: Scene);
  22989. private _initializeAttachments;
  22990. private _createCompositionEffect;
  22991. /**
  22992. * Indicates if rendering a prepass is supported
  22993. */
  22994. get isSupported(): boolean;
  22995. /**
  22996. * Sets the proper output textures to draw in the engine.
  22997. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22998. * @param subMesh Submesh on which the effect is applied
  22999. */
  23000. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23001. /**
  23002. * Restores attachments for single texture draw.
  23003. */
  23004. restoreAttachments(): void;
  23005. /**
  23006. * @hidden
  23007. */
  23008. _beforeCameraDraw(): void;
  23009. /**
  23010. * @hidden
  23011. */
  23012. _afterCameraDraw(): void;
  23013. private _checkRTSize;
  23014. private _bindFrameBuffer;
  23015. /**
  23016. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23017. */
  23018. clear(): void;
  23019. private _setState;
  23020. private _updateGeometryBufferLayout;
  23021. /**
  23022. * Adds an effect configuration to the prepass.
  23023. * If an effect has already been added, it won't add it twice and will return the configuration
  23024. * already present.
  23025. * @param cfg the effect configuration
  23026. * @return the effect configuration now used by the prepass
  23027. */
  23028. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23029. /**
  23030. * Returns the index of a texture in the multi render target texture array.
  23031. * @param type Texture type
  23032. * @return The index
  23033. */
  23034. getIndex(type: number): number;
  23035. private _enable;
  23036. private _disable;
  23037. private _resetLayout;
  23038. private _resetPostProcessChain;
  23039. private _bindPostProcessChain;
  23040. /**
  23041. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23042. */
  23043. markAsDirty(): void;
  23044. /**
  23045. * Enables a texture on the MultiRenderTarget for prepass
  23046. */
  23047. private _enableTextures;
  23048. private _update;
  23049. private _markAllMaterialsAsPrePassDirty;
  23050. /**
  23051. * Disposes the prepass renderer.
  23052. */
  23053. dispose(): void;
  23054. }
  23055. }
  23056. declare module BABYLON {
  23057. /**
  23058. * Size options for a post process
  23059. */
  23060. export type PostProcessOptions = {
  23061. width: number;
  23062. height: number;
  23063. };
  23064. /**
  23065. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23066. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23067. */
  23068. export class PostProcess {
  23069. /**
  23070. * Gets or sets the unique id of the post process
  23071. */
  23072. uniqueId: number;
  23073. /** Name of the PostProcess. */
  23074. name: string;
  23075. /**
  23076. * Width of the texture to apply the post process on
  23077. */
  23078. width: number;
  23079. /**
  23080. * Height of the texture to apply the post process on
  23081. */
  23082. height: number;
  23083. /**
  23084. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23085. */
  23086. nodeMaterialSource: Nullable<NodeMaterial>;
  23087. /**
  23088. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23089. * @hidden
  23090. */
  23091. _outputTexture: Nullable<InternalTexture>;
  23092. /**
  23093. * Sampling mode used by the shader
  23094. * See https://doc.babylonjs.com/classes/3.1/texture
  23095. */
  23096. renderTargetSamplingMode: number;
  23097. /**
  23098. * Clear color to use when screen clearing
  23099. */
  23100. clearColor: Color4;
  23101. /**
  23102. * If the buffer needs to be cleared before applying the post process. (default: true)
  23103. * Should be set to false if shader will overwrite all previous pixels.
  23104. */
  23105. autoClear: boolean;
  23106. /**
  23107. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23108. */
  23109. alphaMode: number;
  23110. /**
  23111. * Sets the setAlphaBlendConstants of the babylon engine
  23112. */
  23113. alphaConstants: Color4;
  23114. /**
  23115. * Animations to be used for the post processing
  23116. */
  23117. animations: Animation[];
  23118. /**
  23119. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23120. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23121. */
  23122. enablePixelPerfectMode: boolean;
  23123. /**
  23124. * Force the postprocess to be applied without taking in account viewport
  23125. */
  23126. forceFullscreenViewport: boolean;
  23127. /**
  23128. * List of inspectable custom properties (used by the Inspector)
  23129. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23130. */
  23131. inspectableCustomProperties: IInspectable[];
  23132. /**
  23133. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23134. *
  23135. * | Value | Type | Description |
  23136. * | ----- | ----------------------------------- | ----------- |
  23137. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23138. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23139. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23140. *
  23141. */
  23142. scaleMode: number;
  23143. /**
  23144. * Force textures to be a power of two (default: false)
  23145. */
  23146. alwaysForcePOT: boolean;
  23147. private _samples;
  23148. /**
  23149. * Number of sample textures (default: 1)
  23150. */
  23151. get samples(): number;
  23152. set samples(n: number);
  23153. /**
  23154. * Modify the scale of the post process to be the same as the viewport (default: false)
  23155. */
  23156. adaptScaleToCurrentViewport: boolean;
  23157. private _camera;
  23158. protected _scene: Scene;
  23159. private _engine;
  23160. private _options;
  23161. private _reusable;
  23162. private _textureType;
  23163. private _textureFormat;
  23164. /**
  23165. * Smart array of input and output textures for the post process.
  23166. * @hidden
  23167. */
  23168. _textures: SmartArray<InternalTexture>;
  23169. /**
  23170. * The index in _textures that corresponds to the output texture.
  23171. * @hidden
  23172. */
  23173. _currentRenderTextureInd: number;
  23174. private _effect;
  23175. private _samplers;
  23176. private _fragmentUrl;
  23177. private _vertexUrl;
  23178. private _parameters;
  23179. private _scaleRatio;
  23180. protected _indexParameters: any;
  23181. private _shareOutputWithPostProcess;
  23182. private _texelSize;
  23183. private _forcedOutputTexture;
  23184. /**
  23185. * Prepass configuration in case this post process needs a texture from prepass
  23186. * @hidden
  23187. */
  23188. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23189. /**
  23190. * Returns the fragment url or shader name used in the post process.
  23191. * @returns the fragment url or name in the shader store.
  23192. */
  23193. getEffectName(): string;
  23194. /**
  23195. * An event triggered when the postprocess is activated.
  23196. */
  23197. onActivateObservable: Observable<Camera>;
  23198. private _onActivateObserver;
  23199. /**
  23200. * A function that is added to the onActivateObservable
  23201. */
  23202. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23203. /**
  23204. * An event triggered when the postprocess changes its size.
  23205. */
  23206. onSizeChangedObservable: Observable<PostProcess>;
  23207. private _onSizeChangedObserver;
  23208. /**
  23209. * A function that is added to the onSizeChangedObservable
  23210. */
  23211. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23212. /**
  23213. * An event triggered when the postprocess applies its effect.
  23214. */
  23215. onApplyObservable: Observable<Effect>;
  23216. private _onApplyObserver;
  23217. /**
  23218. * A function that is added to the onApplyObservable
  23219. */
  23220. set onApply(callback: (effect: Effect) => void);
  23221. /**
  23222. * An event triggered before rendering the postprocess
  23223. */
  23224. onBeforeRenderObservable: Observable<Effect>;
  23225. private _onBeforeRenderObserver;
  23226. /**
  23227. * A function that is added to the onBeforeRenderObservable
  23228. */
  23229. set onBeforeRender(callback: (effect: Effect) => void);
  23230. /**
  23231. * An event triggered after rendering the postprocess
  23232. */
  23233. onAfterRenderObservable: Observable<Effect>;
  23234. private _onAfterRenderObserver;
  23235. /**
  23236. * A function that is added to the onAfterRenderObservable
  23237. */
  23238. set onAfterRender(callback: (efect: Effect) => void);
  23239. /**
  23240. * 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
  23241. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23242. */
  23243. get inputTexture(): InternalTexture;
  23244. set inputTexture(value: InternalTexture);
  23245. /**
  23246. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23247. * the only way to unset it is to use this function to restore its internal state
  23248. */
  23249. restoreDefaultInputTexture(): void;
  23250. /**
  23251. * Gets the camera which post process is applied to.
  23252. * @returns The camera the post process is applied to.
  23253. */
  23254. getCamera(): Camera;
  23255. /**
  23256. * Gets the texel size of the postprocess.
  23257. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23258. */
  23259. get texelSize(): Vector2;
  23260. /**
  23261. * Creates a new instance PostProcess
  23262. * @param name The name of the PostProcess.
  23263. * @param fragmentUrl The url of the fragment shader to be used.
  23264. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23265. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23266. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23267. * @param camera The camera to apply the render pass to.
  23268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23269. * @param engine The engine which the post process will be applied. (default: current engine)
  23270. * @param reusable If the post process can be reused on the same frame. (default: false)
  23271. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23272. * @param textureType Type of textures used when performing the post process. (default: 0)
  23273. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23274. * @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
  23275. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23276. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23277. */
  23278. 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);
  23279. /**
  23280. * Gets a string identifying the name of the class
  23281. * @returns "PostProcess" string
  23282. */
  23283. getClassName(): string;
  23284. /**
  23285. * Gets the engine which this post process belongs to.
  23286. * @returns The engine the post process was enabled with.
  23287. */
  23288. getEngine(): Engine;
  23289. /**
  23290. * The effect that is created when initializing the post process.
  23291. * @returns The created effect corresponding the the postprocess.
  23292. */
  23293. getEffect(): Effect;
  23294. /**
  23295. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23296. * @param postProcess The post process to share the output with.
  23297. * @returns This post process.
  23298. */
  23299. shareOutputWith(postProcess: PostProcess): PostProcess;
  23300. /**
  23301. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23302. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23303. */
  23304. useOwnOutput(): void;
  23305. /**
  23306. * Updates the effect with the current post process compile time values and recompiles the shader.
  23307. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23308. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23309. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23310. * @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
  23311. * @param onCompiled Called when the shader has been compiled.
  23312. * @param onError Called if there is an error when compiling a shader.
  23313. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23314. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23315. */
  23316. 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;
  23317. /**
  23318. * The post process is reusable if it can be used multiple times within one frame.
  23319. * @returns If the post process is reusable
  23320. */
  23321. isReusable(): boolean;
  23322. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23323. markTextureDirty(): void;
  23324. /**
  23325. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23326. * 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.
  23327. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23328. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23329. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23330. * @returns The target texture that was bound to be written to.
  23331. */
  23332. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23333. /**
  23334. * If the post process is supported.
  23335. */
  23336. get isSupported(): boolean;
  23337. /**
  23338. * The aspect ratio of the output texture.
  23339. */
  23340. get aspectRatio(): number;
  23341. /**
  23342. * Get a value indicating if the post-process is ready to be used
  23343. * @returns true if the post-process is ready (shader is compiled)
  23344. */
  23345. isReady(): boolean;
  23346. /**
  23347. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23348. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23349. */
  23350. apply(): Nullable<Effect>;
  23351. private _disposeTextures;
  23352. /**
  23353. * Sets the required values to the prepass renderer.
  23354. * @param prePassRenderer defines the prepass renderer to setup.
  23355. * @returns true if the pre pass is needed.
  23356. */
  23357. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23358. /**
  23359. * Disposes the post process.
  23360. * @param camera The camera to dispose the post process on.
  23361. */
  23362. dispose(camera?: Camera): void;
  23363. /**
  23364. * Serializes the particle system to a JSON object
  23365. * @returns the JSON object
  23366. */
  23367. serialize(): any;
  23368. /**
  23369. * Creates a material from parsed material data
  23370. * @param parsedPostProcess defines parsed post process data
  23371. * @param scene defines the hosting scene
  23372. * @param rootUrl defines the root URL to use to load textures
  23373. * @returns a new post process
  23374. */
  23375. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23376. }
  23377. }
  23378. declare module BABYLON {
  23379. /** @hidden */
  23380. export var kernelBlurVaryingDeclaration: {
  23381. name: string;
  23382. shader: string;
  23383. };
  23384. }
  23385. declare module BABYLON {
  23386. /** @hidden */
  23387. export var packingFunctions: {
  23388. name: string;
  23389. shader: string;
  23390. };
  23391. }
  23392. declare module BABYLON {
  23393. /** @hidden */
  23394. export var kernelBlurFragment: {
  23395. name: string;
  23396. shader: string;
  23397. };
  23398. }
  23399. declare module BABYLON {
  23400. /** @hidden */
  23401. export var kernelBlurFragment2: {
  23402. name: string;
  23403. shader: string;
  23404. };
  23405. }
  23406. declare module BABYLON {
  23407. /** @hidden */
  23408. export var kernelBlurPixelShader: {
  23409. name: string;
  23410. shader: string;
  23411. };
  23412. }
  23413. declare module BABYLON {
  23414. /** @hidden */
  23415. export var kernelBlurVertex: {
  23416. name: string;
  23417. shader: string;
  23418. };
  23419. }
  23420. declare module BABYLON {
  23421. /** @hidden */
  23422. export var kernelBlurVertexShader: {
  23423. name: string;
  23424. shader: string;
  23425. };
  23426. }
  23427. declare module BABYLON {
  23428. /**
  23429. * The Blur Post Process which blurs an image based on a kernel and direction.
  23430. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23431. */
  23432. export class BlurPostProcess extends PostProcess {
  23433. private blockCompilation;
  23434. protected _kernel: number;
  23435. protected _idealKernel: number;
  23436. protected _packedFloat: boolean;
  23437. private _staticDefines;
  23438. /** The direction in which to blur the image. */
  23439. direction: Vector2;
  23440. /**
  23441. * Sets the length in pixels of the blur sample region
  23442. */
  23443. set kernel(v: number);
  23444. /**
  23445. * Gets the length in pixels of the blur sample region
  23446. */
  23447. get kernel(): number;
  23448. /**
  23449. * Sets wether or not the blur needs to unpack/repack floats
  23450. */
  23451. set packedFloat(v: boolean);
  23452. /**
  23453. * Gets wether or not the blur is unpacking/repacking floats
  23454. */
  23455. get packedFloat(): boolean;
  23456. /**
  23457. * Gets a string identifying the name of the class
  23458. * @returns "BlurPostProcess" string
  23459. */
  23460. getClassName(): string;
  23461. /**
  23462. * Creates a new instance BlurPostProcess
  23463. * @param name The name of the effect.
  23464. * @param direction The direction in which to blur the image.
  23465. * @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.
  23466. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23467. * @param camera The camera to apply the render pass to.
  23468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23469. * @param engine The engine which the post process will be applied. (default: current engine)
  23470. * @param reusable If the post process can be reused on the same frame. (default: false)
  23471. * @param textureType Type of textures used when performing the post process. (default: 0)
  23472. * @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)
  23473. */
  23474. 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);
  23475. /**
  23476. * Updates the effect with the current post process compile time values and recompiles the shader.
  23477. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23478. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23479. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23480. * @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
  23481. * @param onCompiled Called when the shader has been compiled.
  23482. * @param onError Called if there is an error when compiling a shader.
  23483. */
  23484. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23485. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23486. /**
  23487. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23488. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23489. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23490. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23491. * The gaps between physical kernels are compensated for in the weighting of the samples
  23492. * @param idealKernel Ideal blur kernel.
  23493. * @return Nearest best kernel.
  23494. */
  23495. protected _nearestBestKernel(idealKernel: number): number;
  23496. /**
  23497. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23498. * @param x The point on the Gaussian distribution to sample.
  23499. * @return the value of the Gaussian function at x.
  23500. */
  23501. protected _gaussianWeight(x: number): number;
  23502. /**
  23503. * Generates a string that can be used as a floating point number in GLSL.
  23504. * @param x Value to print.
  23505. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23506. * @return GLSL float string.
  23507. */
  23508. protected _glslFloat(x: number, decimalFigures?: number): string;
  23509. /** @hidden */
  23510. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23511. }
  23512. }
  23513. declare module BABYLON {
  23514. /**
  23515. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23516. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23517. * You can then easily use it as a reflectionTexture on a flat surface.
  23518. * In case the surface is not a plane, please consider relying on reflection probes.
  23519. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23520. */
  23521. export class MirrorTexture extends RenderTargetTexture {
  23522. private scene;
  23523. /**
  23524. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23525. * 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.
  23526. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23527. */
  23528. mirrorPlane: Plane;
  23529. /**
  23530. * Define the blur ratio used to blur the reflection if needed.
  23531. */
  23532. set blurRatio(value: number);
  23533. get blurRatio(): number;
  23534. /**
  23535. * Define the adaptive blur kernel used to blur the reflection if needed.
  23536. * This will autocompute the closest best match for the `blurKernel`
  23537. */
  23538. set adaptiveBlurKernel(value: number);
  23539. /**
  23540. * Define the blur kernel used to blur the reflection if needed.
  23541. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23542. */
  23543. set blurKernel(value: number);
  23544. /**
  23545. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23546. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23547. */
  23548. set blurKernelX(value: number);
  23549. get blurKernelX(): number;
  23550. /**
  23551. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23552. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23553. */
  23554. set blurKernelY(value: number);
  23555. get blurKernelY(): number;
  23556. private _autoComputeBlurKernel;
  23557. protected _onRatioRescale(): void;
  23558. private _updateGammaSpace;
  23559. private _imageProcessingConfigChangeObserver;
  23560. private _transformMatrix;
  23561. private _mirrorMatrix;
  23562. private _savedViewMatrix;
  23563. private _blurX;
  23564. private _blurY;
  23565. private _adaptiveBlurKernel;
  23566. private _blurKernelX;
  23567. private _blurKernelY;
  23568. private _blurRatio;
  23569. /**
  23570. * Instantiates a Mirror Texture.
  23571. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23572. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23573. * You can then easily use it as a reflectionTexture on a flat surface.
  23574. * In case the surface is not a plane, please consider relying on reflection probes.
  23575. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23576. * @param name
  23577. * @param size
  23578. * @param scene
  23579. * @param generateMipMaps
  23580. * @param type
  23581. * @param samplingMode
  23582. * @param generateDepthBuffer
  23583. */
  23584. constructor(name: string, size: number | {
  23585. width: number;
  23586. height: number;
  23587. } | {
  23588. ratio: number;
  23589. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23590. private _preparePostProcesses;
  23591. /**
  23592. * Clone the mirror texture.
  23593. * @returns the cloned texture
  23594. */
  23595. clone(): MirrorTexture;
  23596. /**
  23597. * Serialize the texture to a JSON representation you could use in Parse later on
  23598. * @returns the serialized JSON representation
  23599. */
  23600. serialize(): any;
  23601. /**
  23602. * Dispose the texture and release its associated resources.
  23603. */
  23604. dispose(): void;
  23605. }
  23606. }
  23607. declare module BABYLON {
  23608. /**
  23609. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23610. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23611. */
  23612. export class Texture extends BaseTexture {
  23613. /**
  23614. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23615. */
  23616. static SerializeBuffers: boolean;
  23617. /**
  23618. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23619. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23620. */
  23621. static ForceSerializeBuffers: boolean;
  23622. /** @hidden */
  23623. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23624. /** @hidden */
  23625. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23626. /** @hidden */
  23627. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23628. /** nearest is mag = nearest and min = nearest and mip = linear */
  23629. static readonly NEAREST_SAMPLINGMODE: number;
  23630. /** nearest is mag = nearest and min = nearest and mip = linear */
  23631. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23632. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23633. static readonly BILINEAR_SAMPLINGMODE: number;
  23634. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23635. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23636. /** Trilinear is mag = linear and min = linear and mip = linear */
  23637. static readonly TRILINEAR_SAMPLINGMODE: number;
  23638. /** Trilinear is mag = linear and min = linear and mip = linear */
  23639. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23640. /** mag = nearest and min = nearest and mip = nearest */
  23641. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23642. /** mag = nearest and min = linear and mip = nearest */
  23643. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23644. /** mag = nearest and min = linear and mip = linear */
  23645. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23646. /** mag = nearest and min = linear and mip = none */
  23647. static readonly NEAREST_LINEAR: number;
  23648. /** mag = nearest and min = nearest and mip = none */
  23649. static readonly NEAREST_NEAREST: number;
  23650. /** mag = linear and min = nearest and mip = nearest */
  23651. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23652. /** mag = linear and min = nearest and mip = linear */
  23653. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23654. /** mag = linear and min = linear and mip = none */
  23655. static readonly LINEAR_LINEAR: number;
  23656. /** mag = linear and min = nearest and mip = none */
  23657. static readonly LINEAR_NEAREST: number;
  23658. /** Explicit coordinates mode */
  23659. static readonly EXPLICIT_MODE: number;
  23660. /** Spherical coordinates mode */
  23661. static readonly SPHERICAL_MODE: number;
  23662. /** Planar coordinates mode */
  23663. static readonly PLANAR_MODE: number;
  23664. /** Cubic coordinates mode */
  23665. static readonly CUBIC_MODE: number;
  23666. /** Projection coordinates mode */
  23667. static readonly PROJECTION_MODE: number;
  23668. /** Inverse Cubic coordinates mode */
  23669. static readonly SKYBOX_MODE: number;
  23670. /** Inverse Cubic coordinates mode */
  23671. static readonly INVCUBIC_MODE: number;
  23672. /** Equirectangular coordinates mode */
  23673. static readonly EQUIRECTANGULAR_MODE: number;
  23674. /** Equirectangular Fixed coordinates mode */
  23675. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23676. /** Equirectangular Fixed Mirrored coordinates mode */
  23677. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23678. /** Texture is not repeating outside of 0..1 UVs */
  23679. static readonly CLAMP_ADDRESSMODE: number;
  23680. /** Texture is repeating outside of 0..1 UVs */
  23681. static readonly WRAP_ADDRESSMODE: number;
  23682. /** Texture is repeating and mirrored */
  23683. static readonly MIRROR_ADDRESSMODE: number;
  23684. /**
  23685. * 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
  23686. */
  23687. static UseSerializedUrlIfAny: boolean;
  23688. /**
  23689. * Define the url of the texture.
  23690. */
  23691. url: Nullable<string>;
  23692. /**
  23693. * Define an offset on the texture to offset the u coordinates of the UVs
  23694. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23695. */
  23696. uOffset: number;
  23697. /**
  23698. * Define an offset on the texture to offset the v coordinates of the UVs
  23699. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23700. */
  23701. vOffset: number;
  23702. /**
  23703. * Define an offset on the texture to scale the u coordinates of the UVs
  23704. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23705. */
  23706. uScale: number;
  23707. /**
  23708. * Define an offset on the texture to scale the v coordinates of the UVs
  23709. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23710. */
  23711. vScale: number;
  23712. /**
  23713. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23714. * @see https://doc.babylonjs.com/how_to/more_materials
  23715. */
  23716. uAng: number;
  23717. /**
  23718. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23719. * @see https://doc.babylonjs.com/how_to/more_materials
  23720. */
  23721. vAng: number;
  23722. /**
  23723. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23724. * @see https://doc.babylonjs.com/how_to/more_materials
  23725. */
  23726. wAng: number;
  23727. /**
  23728. * Defines the center of rotation (U)
  23729. */
  23730. uRotationCenter: number;
  23731. /**
  23732. * Defines the center of rotation (V)
  23733. */
  23734. vRotationCenter: number;
  23735. /**
  23736. * Defines the center of rotation (W)
  23737. */
  23738. wRotationCenter: number;
  23739. /**
  23740. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23741. */
  23742. homogeneousRotationInUVTransform: boolean;
  23743. /**
  23744. * Are mip maps generated for this texture or not.
  23745. */
  23746. get noMipmap(): boolean;
  23747. /**
  23748. * List of inspectable custom properties (used by the Inspector)
  23749. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23750. */
  23751. inspectableCustomProperties: Nullable<IInspectable[]>;
  23752. private _noMipmap;
  23753. /** @hidden */
  23754. _invertY: boolean;
  23755. private _rowGenerationMatrix;
  23756. private _cachedTextureMatrix;
  23757. private _projectionModeMatrix;
  23758. private _t0;
  23759. private _t1;
  23760. private _t2;
  23761. private _cachedUOffset;
  23762. private _cachedVOffset;
  23763. private _cachedUScale;
  23764. private _cachedVScale;
  23765. private _cachedUAng;
  23766. private _cachedVAng;
  23767. private _cachedWAng;
  23768. private _cachedProjectionMatrixId;
  23769. private _cachedURotationCenter;
  23770. private _cachedVRotationCenter;
  23771. private _cachedWRotationCenter;
  23772. private _cachedHomogeneousRotationInUVTransform;
  23773. private _cachedCoordinatesMode;
  23774. /** @hidden */
  23775. protected _initialSamplingMode: number;
  23776. /** @hidden */
  23777. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23778. private _deleteBuffer;
  23779. protected _format: Nullable<number>;
  23780. private _delayedOnLoad;
  23781. private _delayedOnError;
  23782. private _mimeType?;
  23783. private _loaderOptions?;
  23784. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23785. get mimeType(): string | undefined;
  23786. /**
  23787. * Observable triggered once the texture has been loaded.
  23788. */
  23789. onLoadObservable: Observable<Texture>;
  23790. protected _isBlocking: boolean;
  23791. /**
  23792. * Is the texture preventing material to render while loading.
  23793. * If false, a default texture will be used instead of the loading one during the preparation step.
  23794. */
  23795. set isBlocking(value: boolean);
  23796. get isBlocking(): boolean;
  23797. /**
  23798. * Get the current sampling mode associated with the texture.
  23799. */
  23800. get samplingMode(): number;
  23801. /**
  23802. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23803. */
  23804. get invertY(): boolean;
  23805. /**
  23806. * Instantiates a new texture.
  23807. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23808. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23809. * @param url defines the url of the picture to load as a texture
  23810. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23811. * @param noMipmap defines if the texture will require mip maps or not
  23812. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23813. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23814. * @param onLoad defines a callback triggered when the texture has been loaded
  23815. * @param onError defines a callback triggered when an error occurred during the loading session
  23816. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23817. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23818. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23819. * @param mimeType defines an optional mime type information
  23820. * @param loaderOptions options to be passed to the loader
  23821. */
  23822. 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);
  23823. /**
  23824. * Update the url (and optional buffer) of this texture if url was null during construction.
  23825. * @param url the url of the texture
  23826. * @param buffer the buffer of the texture (defaults to null)
  23827. * @param onLoad callback called when the texture is loaded (defaults to null)
  23828. */
  23829. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23830. /**
  23831. * Finish the loading sequence of a texture flagged as delayed load.
  23832. * @hidden
  23833. */
  23834. delayLoad(): void;
  23835. private _prepareRowForTextureGeneration;
  23836. /**
  23837. * Checks if the texture has the same transform matrix than another texture
  23838. * @param texture texture to check against
  23839. * @returns true if the transforms are the same, else false
  23840. */
  23841. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23842. /**
  23843. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23844. * @returns the transform matrix of the texture.
  23845. */
  23846. getTextureMatrix(uBase?: number): Matrix;
  23847. /**
  23848. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23849. * @returns The reflection texture transform
  23850. */
  23851. getReflectionTextureMatrix(): Matrix;
  23852. /**
  23853. * Clones the texture.
  23854. * @returns the cloned texture
  23855. */
  23856. clone(): Texture;
  23857. /**
  23858. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23859. * @returns The JSON representation of the texture
  23860. */
  23861. serialize(): any;
  23862. /**
  23863. * Get the current class name of the texture useful for serialization or dynamic coding.
  23864. * @returns "Texture"
  23865. */
  23866. getClassName(): string;
  23867. /**
  23868. * Dispose the texture and release its associated resources.
  23869. */
  23870. dispose(): void;
  23871. /**
  23872. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23873. * @param parsedTexture Define the JSON representation of the texture
  23874. * @param scene Define the scene the parsed texture should be instantiated in
  23875. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23876. * @returns The parsed texture if successful
  23877. */
  23878. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23879. /**
  23880. * Creates a texture from its base 64 representation.
  23881. * @param data Define the base64 payload without the data: prefix
  23882. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23883. * @param scene Define the scene the texture should belong to
  23884. * @param noMipmap Forces the texture to not create mip map information if true
  23885. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23886. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23887. * @param onLoad define a callback triggered when the texture has been loaded
  23888. * @param onError define a callback triggered when an error occurred during the loading session
  23889. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23890. * @returns the created texture
  23891. */
  23892. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23893. /**
  23894. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23895. * @param data Define the base64 payload without the data: prefix
  23896. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23897. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23898. * @param scene Define the scene the texture should belong to
  23899. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23900. * @param noMipmap Forces the texture to not create mip map information if true
  23901. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23902. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23903. * @param onLoad define a callback triggered when the texture has been loaded
  23904. * @param onError define a callback triggered when an error occurred during the loading session
  23905. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23906. * @returns the created texture
  23907. */
  23908. 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;
  23909. }
  23910. }
  23911. declare module BABYLON {
  23912. /**
  23913. * ThinSprite Class used to represent a thin sprite
  23914. * This is the base class for sprites but can also directly be used with ThinEngine
  23915. * @see https://doc.babylonjs.com/babylon101/sprites
  23916. */
  23917. export class ThinSprite {
  23918. /** Gets or sets the cell index in the sprite sheet */
  23919. cellIndex: number;
  23920. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23921. cellRef: string;
  23922. /** Gets or sets the current world position */
  23923. position: IVector3Like;
  23924. /** Gets or sets the main color */
  23925. color: IColor4Like;
  23926. /** Gets or sets the width */
  23927. width: number;
  23928. /** Gets or sets the height */
  23929. height: number;
  23930. /** Gets or sets rotation angle */
  23931. angle: number;
  23932. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23933. invertU: boolean;
  23934. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23935. invertV: boolean;
  23936. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23937. isVisible: boolean;
  23938. /**
  23939. * Returns a boolean indicating if the animation is started
  23940. */
  23941. get animationStarted(): boolean;
  23942. /** Gets the initial key for the animation (setting it will restart the animation) */
  23943. get fromIndex(): number;
  23944. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23945. get toIndex(): number;
  23946. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23947. get loopAnimation(): boolean;
  23948. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23949. get delay(): number;
  23950. /** @hidden */
  23951. _xOffset: number;
  23952. /** @hidden */
  23953. _yOffset: number;
  23954. /** @hidden */
  23955. _xSize: number;
  23956. /** @hidden */
  23957. _ySize: number;
  23958. private _animationStarted;
  23959. protected _loopAnimation: boolean;
  23960. protected _fromIndex: number;
  23961. protected _toIndex: number;
  23962. protected _delay: number;
  23963. private _direction;
  23964. private _time;
  23965. private _onBaseAnimationEnd;
  23966. /**
  23967. * Creates a new Thin Sprite
  23968. */
  23969. constructor();
  23970. /**
  23971. * Starts an animation
  23972. * @param from defines the initial key
  23973. * @param to defines the end key
  23974. * @param loop defines if the animation must loop
  23975. * @param delay defines the start delay (in ms)
  23976. * @param onAnimationEnd defines a callback for when the animation ends
  23977. */
  23978. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23979. /** Stops current animation (if any) */
  23980. stopAnimation(): void;
  23981. /** @hidden */
  23982. _animate(deltaTime: number): void;
  23983. }
  23984. }
  23985. declare module BABYLON {
  23986. /** @hidden */
  23987. export var imageProcessingCompatibility: {
  23988. name: string;
  23989. shader: string;
  23990. };
  23991. }
  23992. declare module BABYLON {
  23993. /** @hidden */
  23994. export var spritesPixelShader: {
  23995. name: string;
  23996. shader: string;
  23997. };
  23998. }
  23999. declare module BABYLON {
  24000. /** @hidden */
  24001. export var spritesVertexShader: {
  24002. name: string;
  24003. shader: string;
  24004. };
  24005. }
  24006. declare module BABYLON {
  24007. /**
  24008. * Class used to render sprites.
  24009. *
  24010. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24011. */
  24012. export class SpriteRenderer {
  24013. /**
  24014. * Defines the texture of the spritesheet
  24015. */
  24016. texture: Nullable<ThinTexture>;
  24017. /**
  24018. * Defines the default width of a cell in the spritesheet
  24019. */
  24020. cellWidth: number;
  24021. /**
  24022. * Defines the default height of a cell in the spritesheet
  24023. */
  24024. cellHeight: number;
  24025. /**
  24026. * Blend mode use to render the particle, it can be any of
  24027. * the static Constants.ALPHA_x properties provided in this class.
  24028. * Default value is Constants.ALPHA_COMBINE
  24029. */
  24030. blendMode: number;
  24031. /**
  24032. * Gets or sets a boolean indicating if alpha mode is automatically
  24033. * reset.
  24034. */
  24035. autoResetAlpha: boolean;
  24036. /**
  24037. * Disables writing to the depth buffer when rendering the sprites.
  24038. * It can be handy to disable depth writing when using textures without alpha channel
  24039. * and setting some specific blend modes.
  24040. */
  24041. disableDepthWrite: boolean;
  24042. /**
  24043. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24044. */
  24045. fogEnabled: boolean;
  24046. /**
  24047. * Gets the capacity of the manager
  24048. */
  24049. get capacity(): number;
  24050. private readonly _engine;
  24051. private readonly _useVAO;
  24052. private readonly _useInstancing;
  24053. private readonly _scene;
  24054. private readonly _capacity;
  24055. private readonly _epsilon;
  24056. private _vertexBufferSize;
  24057. private _vertexData;
  24058. private _buffer;
  24059. private _vertexBuffers;
  24060. private _spriteBuffer;
  24061. private _indexBuffer;
  24062. private _effectBase;
  24063. private _effectFog;
  24064. private _vertexArrayObject;
  24065. /**
  24066. * Creates a new sprite Renderer
  24067. * @param engine defines the engine the renderer works with
  24068. * @param capacity defines the maximum allowed number of sprites
  24069. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24070. * @param scene defines the hosting scene
  24071. */
  24072. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24073. /**
  24074. * Render all child sprites
  24075. * @param sprites defines the list of sprites to render
  24076. * @param deltaTime defines the time since last frame
  24077. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24078. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24079. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24080. */
  24081. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24082. private _appendSpriteVertex;
  24083. /**
  24084. * Release associated resources
  24085. */
  24086. dispose(): void;
  24087. }
  24088. }
  24089. declare module BABYLON {
  24090. /**
  24091. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24092. */
  24093. export interface ISpriteManager extends IDisposable {
  24094. /**
  24095. * Gets manager's name
  24096. */
  24097. name: string;
  24098. /**
  24099. * Restricts the camera to viewing objects with the same layerMask.
  24100. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24101. */
  24102. layerMask: number;
  24103. /**
  24104. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24105. */
  24106. isPickable: boolean;
  24107. /**
  24108. * Gets the hosting scene
  24109. */
  24110. scene: Scene;
  24111. /**
  24112. * Specifies the rendering group id for this mesh (0 by default)
  24113. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24114. */
  24115. renderingGroupId: number;
  24116. /**
  24117. * Defines the list of sprites managed by the manager.
  24118. */
  24119. sprites: Array<Sprite>;
  24120. /**
  24121. * Gets or sets the spritesheet texture
  24122. */
  24123. texture: Texture;
  24124. /** Defines the default width of a cell in the spritesheet */
  24125. cellWidth: number;
  24126. /** Defines the default height of a cell in the spritesheet */
  24127. cellHeight: number;
  24128. /**
  24129. * Tests the intersection of a sprite with a specific ray.
  24130. * @param ray The ray we are sending to test the collision
  24131. * @param camera The camera space we are sending rays in
  24132. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24133. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24134. * @returns picking info or null.
  24135. */
  24136. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24137. /**
  24138. * Intersects the sprites with a ray
  24139. * @param ray defines the ray to intersect with
  24140. * @param camera defines the current active camera
  24141. * @param predicate defines a predicate used to select candidate sprites
  24142. * @returns null if no hit or a PickingInfo array
  24143. */
  24144. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24145. /**
  24146. * Renders the list of sprites on screen.
  24147. */
  24148. render(): void;
  24149. }
  24150. /**
  24151. * Class used to manage multiple sprites on the same spritesheet
  24152. * @see https://doc.babylonjs.com/babylon101/sprites
  24153. */
  24154. export class SpriteManager implements ISpriteManager {
  24155. /** defines the manager's name */
  24156. name: string;
  24157. /** Define the Url to load snippets */
  24158. static SnippetUrl: string;
  24159. /** Snippet ID if the manager was created from the snippet server */
  24160. snippetId: string;
  24161. /** Gets the list of sprites */
  24162. sprites: Sprite[];
  24163. /** Gets or sets the rendering group id (0 by default) */
  24164. renderingGroupId: number;
  24165. /** Gets or sets camera layer mask */
  24166. layerMask: number;
  24167. /** Gets or sets a boolean indicating if the sprites are pickable */
  24168. isPickable: boolean;
  24169. /**
  24170. * An event triggered when the manager is disposed.
  24171. */
  24172. onDisposeObservable: Observable<SpriteManager>;
  24173. /**
  24174. * Callback called when the manager is disposed
  24175. */
  24176. set onDispose(callback: () => void);
  24177. /**
  24178. * Gets or sets the unique id of the sprite
  24179. */
  24180. uniqueId: number;
  24181. /**
  24182. * Gets the array of sprites
  24183. */
  24184. get children(): Sprite[];
  24185. /**
  24186. * Gets the hosting scene
  24187. */
  24188. get scene(): Scene;
  24189. /**
  24190. * Gets the capacity of the manager
  24191. */
  24192. get capacity(): number;
  24193. /**
  24194. * Gets or sets the spritesheet texture
  24195. */
  24196. get texture(): Texture;
  24197. set texture(value: Texture);
  24198. /** Defines the default width of a cell in the spritesheet */
  24199. get cellWidth(): number;
  24200. set cellWidth(value: number);
  24201. /** Defines the default height of a cell in the spritesheet */
  24202. get cellHeight(): number;
  24203. set cellHeight(value: number);
  24204. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24205. get fogEnabled(): boolean;
  24206. set fogEnabled(value: boolean);
  24207. /**
  24208. * Blend mode use to render the particle, it can be any of
  24209. * the static Constants.ALPHA_x properties provided in this class.
  24210. * Default value is Constants.ALPHA_COMBINE
  24211. */
  24212. get blendMode(): number;
  24213. set blendMode(blendMode: number);
  24214. /** Disables writing to the depth buffer when rendering the sprites.
  24215. * It can be handy to disable depth writing when using textures without alpha channel
  24216. * and setting some specific blend modes.
  24217. */
  24218. disableDepthWrite: boolean;
  24219. private _spriteRenderer;
  24220. /** Associative array from JSON sprite data file */
  24221. private _cellData;
  24222. /** Array of sprite names from JSON sprite data file */
  24223. private _spriteMap;
  24224. /** True when packed cell data from JSON file is ready*/
  24225. private _packedAndReady;
  24226. private _textureContent;
  24227. private _onDisposeObserver;
  24228. private _fromPacked;
  24229. private _scene;
  24230. /**
  24231. * Creates a new sprite manager
  24232. * @param name defines the manager's name
  24233. * @param imgUrl defines the sprite sheet url
  24234. * @param capacity defines the maximum allowed number of sprites
  24235. * @param cellSize defines the size of a sprite cell
  24236. * @param scene defines the hosting scene
  24237. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24238. * @param samplingMode defines the smapling mode to use with spritesheet
  24239. * @param fromPacked set to false; do not alter
  24240. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24241. */
  24242. constructor(
  24243. /** defines the manager's name */
  24244. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24245. /**
  24246. * Returns the string "SpriteManager"
  24247. * @returns "SpriteManager"
  24248. */
  24249. getClassName(): string;
  24250. private _makePacked;
  24251. private _checkTextureAlpha;
  24252. /**
  24253. * Intersects the sprites with a ray
  24254. * @param ray defines the ray to intersect with
  24255. * @param camera defines the current active camera
  24256. * @param predicate defines a predicate used to select candidate sprites
  24257. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24258. * @returns null if no hit or a PickingInfo
  24259. */
  24260. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24261. /**
  24262. * Intersects the sprites with a ray
  24263. * @param ray defines the ray to intersect with
  24264. * @param camera defines the current active camera
  24265. * @param predicate defines a predicate used to select candidate sprites
  24266. * @returns null if no hit or a PickingInfo array
  24267. */
  24268. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24269. /**
  24270. * Render all child sprites
  24271. */
  24272. render(): void;
  24273. private _customUpdate;
  24274. /**
  24275. * Release associated resources
  24276. */
  24277. dispose(): void;
  24278. /**
  24279. * Serializes the sprite manager to a JSON object
  24280. * @param serializeTexture defines if the texture must be serialized as well
  24281. * @returns the JSON object
  24282. */
  24283. serialize(serializeTexture?: boolean): any;
  24284. /**
  24285. * Parses a JSON object to create a new sprite manager.
  24286. * @param parsedManager The JSON object to parse
  24287. * @param scene The scene to create the sprite managerin
  24288. * @param rootUrl The root url to use to load external dependencies like texture
  24289. * @returns the new sprite manager
  24290. */
  24291. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24292. /**
  24293. * Creates a sprite manager from a snippet saved in a remote file
  24294. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24295. * @param url defines the url to load from
  24296. * @param scene defines the hosting scene
  24297. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24298. * @returns a promise that will resolve to the new sprite manager
  24299. */
  24300. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24301. /**
  24302. * Creates a sprite manager from a snippet saved by the sprite editor
  24303. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24304. * @param scene defines the hosting scene
  24305. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24306. * @returns a promise that will resolve to the new sprite manager
  24307. */
  24308. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24309. }
  24310. }
  24311. declare module BABYLON {
  24312. /**
  24313. * Class used to represent a sprite
  24314. * @see https://doc.babylonjs.com/babylon101/sprites
  24315. */
  24316. export class Sprite extends ThinSprite implements IAnimatable {
  24317. /** defines the name */
  24318. name: string;
  24319. /** Gets or sets the current world position */
  24320. position: Vector3;
  24321. /** Gets or sets the main color */
  24322. color: Color4;
  24323. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24324. disposeWhenFinishedAnimating: boolean;
  24325. /** Gets the list of attached animations */
  24326. animations: Nullable<Array<Animation>>;
  24327. /** Gets or sets a boolean indicating if the sprite can be picked */
  24328. isPickable: boolean;
  24329. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24330. useAlphaForPicking: boolean;
  24331. /**
  24332. * Gets or sets the associated action manager
  24333. */
  24334. actionManager: Nullable<ActionManager>;
  24335. /**
  24336. * An event triggered when the control has been disposed
  24337. */
  24338. onDisposeObservable: Observable<Sprite>;
  24339. private _manager;
  24340. private _onAnimationEnd;
  24341. /**
  24342. * Gets or sets the sprite size
  24343. */
  24344. get size(): number;
  24345. set size(value: number);
  24346. /**
  24347. * Gets or sets the unique id of the sprite
  24348. */
  24349. uniqueId: number;
  24350. /**
  24351. * Gets the manager of this sprite
  24352. */
  24353. get manager(): ISpriteManager;
  24354. /**
  24355. * Creates a new Sprite
  24356. * @param name defines the name
  24357. * @param manager defines the manager
  24358. */
  24359. constructor(
  24360. /** defines the name */
  24361. name: string, manager: ISpriteManager);
  24362. /**
  24363. * Returns the string "Sprite"
  24364. * @returns "Sprite"
  24365. */
  24366. getClassName(): string;
  24367. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24368. get fromIndex(): number;
  24369. set fromIndex(value: number);
  24370. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24371. get toIndex(): number;
  24372. set toIndex(value: number);
  24373. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24374. get loopAnimation(): boolean;
  24375. set loopAnimation(value: boolean);
  24376. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24377. get delay(): number;
  24378. set delay(value: number);
  24379. /**
  24380. * Starts an animation
  24381. * @param from defines the initial key
  24382. * @param to defines the end key
  24383. * @param loop defines if the animation must loop
  24384. * @param delay defines the start delay (in ms)
  24385. * @param onAnimationEnd defines a callback to call when animation ends
  24386. */
  24387. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24388. private _endAnimation;
  24389. /** Release associated resources */
  24390. dispose(): void;
  24391. /**
  24392. * Serializes the sprite to a JSON object
  24393. * @returns the JSON object
  24394. */
  24395. serialize(): any;
  24396. /**
  24397. * Parses a JSON object to create a new sprite
  24398. * @param parsedSprite The JSON object to parse
  24399. * @param manager defines the hosting manager
  24400. * @returns the new sprite
  24401. */
  24402. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24403. }
  24404. }
  24405. declare module BABYLON {
  24406. /**
  24407. * Information about the result of picking within a scene
  24408. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24409. */
  24410. export class PickingInfo {
  24411. /** @hidden */
  24412. _pickingUnavailable: boolean;
  24413. /**
  24414. * If the pick collided with an object
  24415. */
  24416. hit: boolean;
  24417. /**
  24418. * Distance away where the pick collided
  24419. */
  24420. distance: number;
  24421. /**
  24422. * The location of pick collision
  24423. */
  24424. pickedPoint: Nullable<Vector3>;
  24425. /**
  24426. * The mesh corresponding the the pick collision
  24427. */
  24428. pickedMesh: Nullable<AbstractMesh>;
  24429. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24430. bu: number;
  24431. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24432. bv: number;
  24433. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24434. faceId: number;
  24435. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24436. subMeshFaceId: number;
  24437. /** Id of the the submesh that was picked */
  24438. subMeshId: number;
  24439. /** If a sprite was picked, this will be the sprite the pick collided with */
  24440. pickedSprite: Nullable<Sprite>;
  24441. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24442. thinInstanceIndex: number;
  24443. /**
  24444. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24445. */
  24446. originMesh: Nullable<AbstractMesh>;
  24447. /**
  24448. * The ray that was used to perform the picking.
  24449. */
  24450. ray: Nullable<Ray>;
  24451. /**
  24452. * Gets the normal correspodning to the face the pick collided with
  24453. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24454. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24455. * @returns The normal correspodning to the face the pick collided with
  24456. */
  24457. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24458. /**
  24459. * Gets the texture coordinates of where the pick occured
  24460. * @returns the vector containing the coordnates of the texture
  24461. */
  24462. getTextureCoordinates(): Nullable<Vector2>;
  24463. }
  24464. }
  24465. declare module BABYLON {
  24466. /**
  24467. * Gather the list of pointer event types as constants.
  24468. */
  24469. export class PointerEventTypes {
  24470. /**
  24471. * 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.
  24472. */
  24473. static readonly POINTERDOWN: number;
  24474. /**
  24475. * The pointerup event is fired when a pointer is no longer active.
  24476. */
  24477. static readonly POINTERUP: number;
  24478. /**
  24479. * The pointermove event is fired when a pointer changes coordinates.
  24480. */
  24481. static readonly POINTERMOVE: number;
  24482. /**
  24483. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24484. */
  24485. static readonly POINTERWHEEL: number;
  24486. /**
  24487. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24488. */
  24489. static readonly POINTERPICK: number;
  24490. /**
  24491. * The pointertap event is fired when a the object has been touched and released without drag.
  24492. */
  24493. static readonly POINTERTAP: number;
  24494. /**
  24495. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24496. */
  24497. static readonly POINTERDOUBLETAP: number;
  24498. }
  24499. /**
  24500. * Base class of pointer info types.
  24501. */
  24502. export class PointerInfoBase {
  24503. /**
  24504. * Defines the type of event (PointerEventTypes)
  24505. */
  24506. type: number;
  24507. /**
  24508. * Defines the related dom event
  24509. */
  24510. event: PointerEvent | MouseWheelEvent;
  24511. /**
  24512. * Instantiates the base class of pointers info.
  24513. * @param type Defines the type of event (PointerEventTypes)
  24514. * @param event Defines the related dom event
  24515. */
  24516. constructor(
  24517. /**
  24518. * Defines the type of event (PointerEventTypes)
  24519. */
  24520. type: number,
  24521. /**
  24522. * Defines the related dom event
  24523. */
  24524. event: PointerEvent | MouseWheelEvent);
  24525. }
  24526. /**
  24527. * This class is used to store pointer related info for the onPrePointerObservable event.
  24528. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24529. */
  24530. export class PointerInfoPre extends PointerInfoBase {
  24531. /**
  24532. * Ray from a pointer if availible (eg. 6dof controller)
  24533. */
  24534. ray: Nullable<Ray>;
  24535. /**
  24536. * Defines the local position of the pointer on the canvas.
  24537. */
  24538. localPosition: Vector2;
  24539. /**
  24540. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24541. */
  24542. skipOnPointerObservable: boolean;
  24543. /**
  24544. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24545. * @param type Defines the type of event (PointerEventTypes)
  24546. * @param event Defines the related dom event
  24547. * @param localX Defines the local x coordinates of the pointer when the event occured
  24548. * @param localY Defines the local y coordinates of the pointer when the event occured
  24549. */
  24550. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24551. }
  24552. /**
  24553. * This type contains all the data related to a pointer event in Babylon.js.
  24554. * 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.
  24555. */
  24556. export class PointerInfo extends PointerInfoBase {
  24557. /**
  24558. * Defines the picking info associated to the info (if any)\
  24559. */
  24560. pickInfo: Nullable<PickingInfo>;
  24561. /**
  24562. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24563. * @param type Defines the type of event (PointerEventTypes)
  24564. * @param event Defines the related dom event
  24565. * @param pickInfo Defines the picking info associated to the info (if any)\
  24566. */
  24567. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24568. /**
  24569. * Defines the picking info associated to the info (if any)\
  24570. */
  24571. pickInfo: Nullable<PickingInfo>);
  24572. }
  24573. /**
  24574. * Data relating to a touch event on the screen.
  24575. */
  24576. export interface PointerTouch {
  24577. /**
  24578. * X coordinate of touch.
  24579. */
  24580. x: number;
  24581. /**
  24582. * Y coordinate of touch.
  24583. */
  24584. y: number;
  24585. /**
  24586. * Id of touch. Unique for each finger.
  24587. */
  24588. pointerId: number;
  24589. /**
  24590. * Event type passed from DOM.
  24591. */
  24592. type: any;
  24593. }
  24594. }
  24595. declare module BABYLON {
  24596. /**
  24597. * Manage the mouse inputs to control the movement of a free camera.
  24598. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24599. */
  24600. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24601. /**
  24602. * Define if touch is enabled in the mouse input
  24603. */
  24604. touchEnabled: boolean;
  24605. /**
  24606. * Defines the camera the input is attached to.
  24607. */
  24608. camera: FreeCamera;
  24609. /**
  24610. * Defines the buttons associated with the input to handle camera move.
  24611. */
  24612. buttons: number[];
  24613. /**
  24614. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24615. */
  24616. angularSensibility: number;
  24617. private _pointerInput;
  24618. private _onMouseMove;
  24619. private _observer;
  24620. private previousPosition;
  24621. /**
  24622. * Observable for when a pointer move event occurs containing the move offset
  24623. */
  24624. onPointerMovedObservable: Observable<{
  24625. offsetX: number;
  24626. offsetY: number;
  24627. }>;
  24628. /**
  24629. * @hidden
  24630. * If the camera should be rotated automatically based on pointer movement
  24631. */
  24632. _allowCameraRotation: boolean;
  24633. /**
  24634. * Manage the mouse inputs to control the movement of a free camera.
  24635. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24636. * @param touchEnabled Defines if touch is enabled or not
  24637. */
  24638. constructor(
  24639. /**
  24640. * Define if touch is enabled in the mouse input
  24641. */
  24642. touchEnabled?: boolean);
  24643. /**
  24644. * Attach the input controls to a specific dom element to get the input from.
  24645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24646. */
  24647. attachControl(noPreventDefault?: boolean): void;
  24648. /**
  24649. * Called on JS contextmenu event.
  24650. * Override this method to provide functionality.
  24651. */
  24652. protected onContextMenu(evt: PointerEvent): void;
  24653. /**
  24654. * Detach the current controls from the specified dom element.
  24655. */
  24656. detachControl(): void;
  24657. /**
  24658. * Gets the class name of the current intput.
  24659. * @returns the class name
  24660. */
  24661. getClassName(): string;
  24662. /**
  24663. * Get the friendly name associated with the input class.
  24664. * @returns the input friendly name
  24665. */
  24666. getSimpleName(): string;
  24667. }
  24668. }
  24669. declare module BABYLON {
  24670. /**
  24671. * Base class for mouse wheel input..
  24672. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24673. * for example usage.
  24674. */
  24675. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24676. /**
  24677. * Defines the camera the input is attached to.
  24678. */
  24679. abstract camera: Camera;
  24680. /**
  24681. * How fast is the camera moves in relation to X axis mouseWheel events.
  24682. * Use negative value to reverse direction.
  24683. */
  24684. wheelPrecisionX: number;
  24685. /**
  24686. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24687. * Use negative value to reverse direction.
  24688. */
  24689. wheelPrecisionY: number;
  24690. /**
  24691. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24692. * Use negative value to reverse direction.
  24693. */
  24694. wheelPrecisionZ: number;
  24695. /**
  24696. * Observable for when a mouse wheel move event occurs.
  24697. */
  24698. onChangedObservable: Observable<{
  24699. wheelDeltaX: number;
  24700. wheelDeltaY: number;
  24701. wheelDeltaZ: number;
  24702. }>;
  24703. private _wheel;
  24704. private _observer;
  24705. /**
  24706. * Attach the input controls to a specific dom element to get the input from.
  24707. * @param noPreventDefault Defines whether event caught by the controls
  24708. * should call preventdefault().
  24709. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24710. */
  24711. attachControl(noPreventDefault?: boolean): void;
  24712. /**
  24713. * Detach the current controls from the specified dom element.
  24714. */
  24715. detachControl(): void;
  24716. /**
  24717. * Called for each rendered frame.
  24718. */
  24719. checkInputs(): void;
  24720. /**
  24721. * Gets the class name of the current intput.
  24722. * @returns the class name
  24723. */
  24724. getClassName(): string;
  24725. /**
  24726. * Get the friendly name associated with the input class.
  24727. * @returns the input friendly name
  24728. */
  24729. getSimpleName(): string;
  24730. /**
  24731. * Incremental value of multiple mouse wheel movements of the X axis.
  24732. * Should be zero-ed when read.
  24733. */
  24734. protected _wheelDeltaX: number;
  24735. /**
  24736. * Incremental value of multiple mouse wheel movements of the Y axis.
  24737. * Should be zero-ed when read.
  24738. */
  24739. protected _wheelDeltaY: number;
  24740. /**
  24741. * Incremental value of multiple mouse wheel movements of the Z axis.
  24742. * Should be zero-ed when read.
  24743. */
  24744. protected _wheelDeltaZ: number;
  24745. /**
  24746. * Firefox uses a different scheme to report scroll distances to other
  24747. * browsers. Rather than use complicated methods to calculate the exact
  24748. * multiple we need to apply, let's just cheat and use a constant.
  24749. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24750. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24751. */
  24752. private readonly _ffMultiplier;
  24753. /**
  24754. * Different event attributes for wheel data fall into a few set ranges.
  24755. * Some relevant but dated date here:
  24756. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24757. */
  24758. private readonly _normalize;
  24759. }
  24760. }
  24761. declare module BABYLON {
  24762. /**
  24763. * Manage the mouse wheel inputs to control a free camera.
  24764. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24765. */
  24766. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24767. /**
  24768. * Defines the camera the input is attached to.
  24769. */
  24770. camera: FreeCamera;
  24771. /**
  24772. * Gets the class name of the current input.
  24773. * @returns the class name
  24774. */
  24775. getClassName(): string;
  24776. /**
  24777. * Set which movement axis (relative to camera's orientation) the mouse
  24778. * wheel's X axis controls.
  24779. * @param axis The axis to be moved. Set null to clear.
  24780. */
  24781. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24782. /**
  24783. * Get the configured movement axis (relative to camera's orientation) the
  24784. * mouse wheel's X axis controls.
  24785. * @returns The configured axis or null if none.
  24786. */
  24787. get wheelXMoveRelative(): Nullable<Coordinate>;
  24788. /**
  24789. * Set which movement axis (relative to camera's orientation) the mouse
  24790. * wheel's Y axis controls.
  24791. * @param axis The axis to be moved. Set null to clear.
  24792. */
  24793. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24794. /**
  24795. * Get the configured movement axis (relative to camera's orientation) the
  24796. * mouse wheel's Y axis controls.
  24797. * @returns The configured axis or null if none.
  24798. */
  24799. get wheelYMoveRelative(): Nullable<Coordinate>;
  24800. /**
  24801. * Set which movement axis (relative to camera's orientation) the mouse
  24802. * wheel's Z axis controls.
  24803. * @param axis The axis to be moved. Set null to clear.
  24804. */
  24805. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24806. /**
  24807. * Get the configured movement axis (relative to camera's orientation) the
  24808. * mouse wheel's Z axis controls.
  24809. * @returns The configured axis or null if none.
  24810. */
  24811. get wheelZMoveRelative(): Nullable<Coordinate>;
  24812. /**
  24813. * Set which rotation axis (relative to camera's orientation) the mouse
  24814. * wheel's X axis controls.
  24815. * @param axis The axis to be moved. Set null to clear.
  24816. */
  24817. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24818. /**
  24819. * Get the configured rotation axis (relative to camera's orientation) the
  24820. * mouse wheel's X axis controls.
  24821. * @returns The configured axis or null if none.
  24822. */
  24823. get wheelXRotateRelative(): Nullable<Coordinate>;
  24824. /**
  24825. * Set which rotation axis (relative to camera's orientation) the mouse
  24826. * wheel's Y axis controls.
  24827. * @param axis The axis to be moved. Set null to clear.
  24828. */
  24829. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24830. /**
  24831. * Get the configured rotation axis (relative to camera's orientation) the
  24832. * mouse wheel's Y axis controls.
  24833. * @returns The configured axis or null if none.
  24834. */
  24835. get wheelYRotateRelative(): Nullable<Coordinate>;
  24836. /**
  24837. * Set which rotation axis (relative to camera's orientation) the mouse
  24838. * wheel's Z axis controls.
  24839. * @param axis The axis to be moved. Set null to clear.
  24840. */
  24841. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24842. /**
  24843. * Get the configured rotation axis (relative to camera's orientation) the
  24844. * mouse wheel's Z axis controls.
  24845. * @returns The configured axis or null if none.
  24846. */
  24847. get wheelZRotateRelative(): Nullable<Coordinate>;
  24848. /**
  24849. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24850. * controls.
  24851. * @param axis The axis to be moved. Set null to clear.
  24852. */
  24853. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24854. /**
  24855. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24856. * X axis controls.
  24857. * @returns The configured axis or null if none.
  24858. */
  24859. get wheelXMoveScene(): Nullable<Coordinate>;
  24860. /**
  24861. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24862. * controls.
  24863. * @param axis The axis to be moved. Set null to clear.
  24864. */
  24865. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24866. /**
  24867. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24868. * Y axis controls.
  24869. * @returns The configured axis or null if none.
  24870. */
  24871. get wheelYMoveScene(): Nullable<Coordinate>;
  24872. /**
  24873. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24874. * controls.
  24875. * @param axis The axis to be moved. Set null to clear.
  24876. */
  24877. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24878. /**
  24879. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24880. * Z axis controls.
  24881. * @returns The configured axis or null if none.
  24882. */
  24883. get wheelZMoveScene(): Nullable<Coordinate>;
  24884. /**
  24885. * Called for each rendered frame.
  24886. */
  24887. checkInputs(): void;
  24888. private _moveRelative;
  24889. private _rotateRelative;
  24890. private _moveScene;
  24891. /**
  24892. * These are set to the desired default behaviour.
  24893. */
  24894. private _wheelXAction;
  24895. private _wheelXActionCoordinate;
  24896. private _wheelYAction;
  24897. private _wheelYActionCoordinate;
  24898. private _wheelZAction;
  24899. private _wheelZActionCoordinate;
  24900. /**
  24901. * Update the camera according to any configured properties for the 3
  24902. * mouse-wheel axis.
  24903. */
  24904. private _updateCamera;
  24905. /**
  24906. * Update one property of the camera.
  24907. */
  24908. private _updateCameraProperty;
  24909. }
  24910. }
  24911. declare module BABYLON {
  24912. /**
  24913. * Manage the touch inputs to control the movement of a free camera.
  24914. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24915. */
  24916. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24917. /**
  24918. * Define if mouse events can be treated as touch events
  24919. */
  24920. allowMouse: boolean;
  24921. /**
  24922. * Defines the camera the input is attached to.
  24923. */
  24924. camera: FreeCamera;
  24925. /**
  24926. * Defines the touch sensibility for rotation.
  24927. * The higher the faster.
  24928. */
  24929. touchAngularSensibility: number;
  24930. /**
  24931. * Defines the touch sensibility for move.
  24932. * The higher the faster.
  24933. */
  24934. touchMoveSensibility: number;
  24935. private _offsetX;
  24936. private _offsetY;
  24937. private _pointerPressed;
  24938. private _pointerInput?;
  24939. private _observer;
  24940. private _onLostFocus;
  24941. /**
  24942. * Manage the touch inputs to control the movement of a free camera.
  24943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24944. * @param allowMouse Defines if mouse events can be treated as touch events
  24945. */
  24946. constructor(
  24947. /**
  24948. * Define if mouse events can be treated as touch events
  24949. */
  24950. allowMouse?: boolean);
  24951. /**
  24952. * Attach the input controls to a specific dom element to get the input from.
  24953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24954. */
  24955. attachControl(noPreventDefault?: boolean): void;
  24956. /**
  24957. * Detach the current controls from the specified dom element.
  24958. */
  24959. detachControl(): void;
  24960. /**
  24961. * Update the current camera state depending on the inputs that have been used this frame.
  24962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24963. */
  24964. checkInputs(): void;
  24965. /**
  24966. * Gets the class name of the current intput.
  24967. * @returns the class name
  24968. */
  24969. getClassName(): string;
  24970. /**
  24971. * Get the friendly name associated with the input class.
  24972. * @returns the input friendly name
  24973. */
  24974. getSimpleName(): string;
  24975. }
  24976. }
  24977. declare module BABYLON {
  24978. /**
  24979. * Default Inputs manager for the FreeCamera.
  24980. * It groups all the default supported inputs for ease of use.
  24981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24982. */
  24983. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24984. /**
  24985. * @hidden
  24986. */
  24987. _mouseInput: Nullable<FreeCameraMouseInput>;
  24988. /**
  24989. * @hidden
  24990. */
  24991. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24992. /**
  24993. * Instantiates a new FreeCameraInputsManager.
  24994. * @param camera Defines the camera the inputs belong to
  24995. */
  24996. constructor(camera: FreeCamera);
  24997. /**
  24998. * Add keyboard input support to the input manager.
  24999. * @returns the current input manager
  25000. */
  25001. addKeyboard(): FreeCameraInputsManager;
  25002. /**
  25003. * Add mouse input support to the input manager.
  25004. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25005. * @returns the current input manager
  25006. */
  25007. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25008. /**
  25009. * Removes the mouse input support from the manager
  25010. * @returns the current input manager
  25011. */
  25012. removeMouse(): FreeCameraInputsManager;
  25013. /**
  25014. * Add mouse wheel input support to the input manager.
  25015. * @returns the current input manager
  25016. */
  25017. addMouseWheel(): FreeCameraInputsManager;
  25018. /**
  25019. * Removes the mouse wheel input support from the manager
  25020. * @returns the current input manager
  25021. */
  25022. removeMouseWheel(): FreeCameraInputsManager;
  25023. /**
  25024. * Add touch input support to the input manager.
  25025. * @returns the current input manager
  25026. */
  25027. addTouch(): FreeCameraInputsManager;
  25028. /**
  25029. * Remove all attached input methods from a camera
  25030. */
  25031. clear(): void;
  25032. }
  25033. }
  25034. declare module BABYLON {
  25035. /**
  25036. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25037. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25038. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25039. */
  25040. export class FreeCamera extends TargetCamera {
  25041. /**
  25042. * Define the collision ellipsoid of the camera.
  25043. * This is helpful to simulate a camera body like the player body around the camera
  25044. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25045. */
  25046. ellipsoid: Vector3;
  25047. /**
  25048. * Define an offset for the position of the ellipsoid around the camera.
  25049. * This can be helpful to determine the center of the body near the gravity center of the body
  25050. * instead of its head.
  25051. */
  25052. ellipsoidOffset: Vector3;
  25053. /**
  25054. * Enable or disable collisions of the camera with the rest of the scene objects.
  25055. */
  25056. checkCollisions: boolean;
  25057. /**
  25058. * Enable or disable gravity on the camera.
  25059. */
  25060. applyGravity: boolean;
  25061. /**
  25062. * Define the input manager associated to the camera.
  25063. */
  25064. inputs: FreeCameraInputsManager;
  25065. /**
  25066. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25067. * Higher values reduce sensitivity.
  25068. */
  25069. get angularSensibility(): number;
  25070. /**
  25071. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25072. * Higher values reduce sensitivity.
  25073. */
  25074. set angularSensibility(value: number);
  25075. /**
  25076. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25077. */
  25078. get keysUp(): number[];
  25079. set keysUp(value: number[]);
  25080. /**
  25081. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25082. */
  25083. get keysUpward(): number[];
  25084. set keysUpward(value: number[]);
  25085. /**
  25086. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25087. */
  25088. get keysDown(): number[];
  25089. set keysDown(value: number[]);
  25090. /**
  25091. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25092. */
  25093. get keysDownward(): number[];
  25094. set keysDownward(value: number[]);
  25095. /**
  25096. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25097. */
  25098. get keysLeft(): number[];
  25099. set keysLeft(value: number[]);
  25100. /**
  25101. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25102. */
  25103. get keysRight(): number[];
  25104. set keysRight(value: number[]);
  25105. /**
  25106. * Event raised when the camera collide with a mesh in the scene.
  25107. */
  25108. onCollide: (collidedMesh: AbstractMesh) => void;
  25109. private _collider;
  25110. private _needMoveForGravity;
  25111. private _oldPosition;
  25112. private _diffPosition;
  25113. private _newPosition;
  25114. /** @hidden */
  25115. _localDirection: Vector3;
  25116. /** @hidden */
  25117. _transformedDirection: Vector3;
  25118. /**
  25119. * Instantiates a Free Camera.
  25120. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25121. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25122. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25123. * @param name Define the name of the camera in the scene
  25124. * @param position Define the start position of the camera in the scene
  25125. * @param scene Define the scene the camera belongs to
  25126. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25127. */
  25128. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25129. /**
  25130. * Attach the input controls to a specific dom element to get the input from.
  25131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25132. */
  25133. attachControl(noPreventDefault?: boolean): void;
  25134. /**
  25135. * Attach the input controls to a specific dom element to get the input from.
  25136. * @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
  25137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25138. * BACK COMPAT SIGNATURE ONLY.
  25139. */
  25140. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25141. /**
  25142. * Detach the current controls from the specified dom element.
  25143. */
  25144. detachControl(): void;
  25145. /**
  25146. * Detach the current controls from the specified dom element.
  25147. * @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
  25148. */
  25149. detachControl(ignored: any): void;
  25150. private _collisionMask;
  25151. /**
  25152. * Define a collision mask to limit the list of object the camera can collide with
  25153. */
  25154. get collisionMask(): number;
  25155. set collisionMask(mask: number);
  25156. /** @hidden */
  25157. _collideWithWorld(displacement: Vector3): void;
  25158. private _onCollisionPositionChange;
  25159. /** @hidden */
  25160. _checkInputs(): void;
  25161. /** @hidden */
  25162. _decideIfNeedsToMove(): boolean;
  25163. /** @hidden */
  25164. _updatePosition(): void;
  25165. /**
  25166. * Destroy the camera and release the current resources hold by it.
  25167. */
  25168. dispose(): void;
  25169. /**
  25170. * Gets the current object class name.
  25171. * @return the class name
  25172. */
  25173. getClassName(): string;
  25174. }
  25175. }
  25176. declare module BABYLON {
  25177. /**
  25178. * Represents a gamepad control stick position
  25179. */
  25180. export class StickValues {
  25181. /**
  25182. * The x component of the control stick
  25183. */
  25184. x: number;
  25185. /**
  25186. * The y component of the control stick
  25187. */
  25188. y: number;
  25189. /**
  25190. * Initializes the gamepad x and y control stick values
  25191. * @param x The x component of the gamepad control stick value
  25192. * @param y The y component of the gamepad control stick value
  25193. */
  25194. constructor(
  25195. /**
  25196. * The x component of the control stick
  25197. */
  25198. x: number,
  25199. /**
  25200. * The y component of the control stick
  25201. */
  25202. y: number);
  25203. }
  25204. /**
  25205. * An interface which manages callbacks for gamepad button changes
  25206. */
  25207. export interface GamepadButtonChanges {
  25208. /**
  25209. * Called when a gamepad has been changed
  25210. */
  25211. changed: boolean;
  25212. /**
  25213. * Called when a gamepad press event has been triggered
  25214. */
  25215. pressChanged: boolean;
  25216. /**
  25217. * Called when a touch event has been triggered
  25218. */
  25219. touchChanged: boolean;
  25220. /**
  25221. * Called when a value has changed
  25222. */
  25223. valueChanged: boolean;
  25224. }
  25225. /**
  25226. * Represents a gamepad
  25227. */
  25228. export class Gamepad {
  25229. /**
  25230. * The id of the gamepad
  25231. */
  25232. id: string;
  25233. /**
  25234. * The index of the gamepad
  25235. */
  25236. index: number;
  25237. /**
  25238. * The browser gamepad
  25239. */
  25240. browserGamepad: any;
  25241. /**
  25242. * Specifies what type of gamepad this represents
  25243. */
  25244. type: number;
  25245. private _leftStick;
  25246. private _rightStick;
  25247. /** @hidden */
  25248. _isConnected: boolean;
  25249. private _leftStickAxisX;
  25250. private _leftStickAxisY;
  25251. private _rightStickAxisX;
  25252. private _rightStickAxisY;
  25253. /**
  25254. * Triggered when the left control stick has been changed
  25255. */
  25256. private _onleftstickchanged;
  25257. /**
  25258. * Triggered when the right control stick has been changed
  25259. */
  25260. private _onrightstickchanged;
  25261. /**
  25262. * Represents a gamepad controller
  25263. */
  25264. static GAMEPAD: number;
  25265. /**
  25266. * Represents a generic controller
  25267. */
  25268. static GENERIC: number;
  25269. /**
  25270. * Represents an XBox controller
  25271. */
  25272. static XBOX: number;
  25273. /**
  25274. * Represents a pose-enabled controller
  25275. */
  25276. static POSE_ENABLED: number;
  25277. /**
  25278. * Represents an Dual Shock controller
  25279. */
  25280. static DUALSHOCK: number;
  25281. /**
  25282. * Specifies whether the left control stick should be Y-inverted
  25283. */
  25284. protected _invertLeftStickY: boolean;
  25285. /**
  25286. * Specifies if the gamepad has been connected
  25287. */
  25288. get isConnected(): boolean;
  25289. /**
  25290. * Initializes the gamepad
  25291. * @param id The id of the gamepad
  25292. * @param index The index of the gamepad
  25293. * @param browserGamepad The browser gamepad
  25294. * @param leftStickX The x component of the left joystick
  25295. * @param leftStickY The y component of the left joystick
  25296. * @param rightStickX The x component of the right joystick
  25297. * @param rightStickY The y component of the right joystick
  25298. */
  25299. constructor(
  25300. /**
  25301. * The id of the gamepad
  25302. */
  25303. id: string,
  25304. /**
  25305. * The index of the gamepad
  25306. */
  25307. index: number,
  25308. /**
  25309. * The browser gamepad
  25310. */
  25311. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25312. /**
  25313. * Callback triggered when the left joystick has changed
  25314. * @param callback
  25315. */
  25316. onleftstickchanged(callback: (values: StickValues) => void): void;
  25317. /**
  25318. * Callback triggered when the right joystick has changed
  25319. * @param callback
  25320. */
  25321. onrightstickchanged(callback: (values: StickValues) => void): void;
  25322. /**
  25323. * Gets the left joystick
  25324. */
  25325. get leftStick(): StickValues;
  25326. /**
  25327. * Sets the left joystick values
  25328. */
  25329. set leftStick(newValues: StickValues);
  25330. /**
  25331. * Gets the right joystick
  25332. */
  25333. get rightStick(): StickValues;
  25334. /**
  25335. * Sets the right joystick value
  25336. */
  25337. set rightStick(newValues: StickValues);
  25338. /**
  25339. * Updates the gamepad joystick positions
  25340. */
  25341. update(): void;
  25342. /**
  25343. * Disposes the gamepad
  25344. */
  25345. dispose(): void;
  25346. }
  25347. /**
  25348. * Represents a generic gamepad
  25349. */
  25350. export class GenericPad extends Gamepad {
  25351. private _buttons;
  25352. private _onbuttondown;
  25353. private _onbuttonup;
  25354. /**
  25355. * Observable triggered when a button has been pressed
  25356. */
  25357. onButtonDownObservable: Observable<number>;
  25358. /**
  25359. * Observable triggered when a button has been released
  25360. */
  25361. onButtonUpObservable: Observable<number>;
  25362. /**
  25363. * Callback triggered when a button has been pressed
  25364. * @param callback Called when a button has been pressed
  25365. */
  25366. onbuttondown(callback: (buttonPressed: number) => void): void;
  25367. /**
  25368. * Callback triggered when a button has been released
  25369. * @param callback Called when a button has been released
  25370. */
  25371. onbuttonup(callback: (buttonReleased: number) => void): void;
  25372. /**
  25373. * Initializes the generic gamepad
  25374. * @param id The id of the generic gamepad
  25375. * @param index The index of the generic gamepad
  25376. * @param browserGamepad The browser gamepad
  25377. */
  25378. constructor(id: string, index: number, browserGamepad: any);
  25379. private _setButtonValue;
  25380. /**
  25381. * Updates the generic gamepad
  25382. */
  25383. update(): void;
  25384. /**
  25385. * Disposes the generic gamepad
  25386. */
  25387. dispose(): void;
  25388. }
  25389. }
  25390. declare module BABYLON {
  25391. /**
  25392. * Defines a runtime animation
  25393. */
  25394. export class RuntimeAnimation {
  25395. private _events;
  25396. /**
  25397. * The current frame of the runtime animation
  25398. */
  25399. private _currentFrame;
  25400. /**
  25401. * The animation used by the runtime animation
  25402. */
  25403. private _animation;
  25404. /**
  25405. * The target of the runtime animation
  25406. */
  25407. private _target;
  25408. /**
  25409. * The initiating animatable
  25410. */
  25411. private _host;
  25412. /**
  25413. * The original value of the runtime animation
  25414. */
  25415. private _originalValue;
  25416. /**
  25417. * The original blend value of the runtime animation
  25418. */
  25419. private _originalBlendValue;
  25420. /**
  25421. * The offsets cache of the runtime animation
  25422. */
  25423. private _offsetsCache;
  25424. /**
  25425. * The high limits cache of the runtime animation
  25426. */
  25427. private _highLimitsCache;
  25428. /**
  25429. * Specifies if the runtime animation has been stopped
  25430. */
  25431. private _stopped;
  25432. /**
  25433. * The blending factor of the runtime animation
  25434. */
  25435. private _blendingFactor;
  25436. /**
  25437. * The BabylonJS scene
  25438. */
  25439. private _scene;
  25440. /**
  25441. * The current value of the runtime animation
  25442. */
  25443. private _currentValue;
  25444. /** @hidden */
  25445. _animationState: _IAnimationState;
  25446. /**
  25447. * The active target of the runtime animation
  25448. */
  25449. private _activeTargets;
  25450. private _currentActiveTarget;
  25451. private _directTarget;
  25452. /**
  25453. * The target path of the runtime animation
  25454. */
  25455. private _targetPath;
  25456. /**
  25457. * The weight of the runtime animation
  25458. */
  25459. private _weight;
  25460. /**
  25461. * The ratio offset of the runtime animation
  25462. */
  25463. private _ratioOffset;
  25464. /**
  25465. * The previous delay of the runtime animation
  25466. */
  25467. private _previousDelay;
  25468. /**
  25469. * The previous ratio of the runtime animation
  25470. */
  25471. private _previousRatio;
  25472. private _enableBlending;
  25473. private _keys;
  25474. private _minFrame;
  25475. private _maxFrame;
  25476. private _minValue;
  25477. private _maxValue;
  25478. private _targetIsArray;
  25479. /**
  25480. * Gets the current frame of the runtime animation
  25481. */
  25482. get currentFrame(): number;
  25483. /**
  25484. * Gets the weight of the runtime animation
  25485. */
  25486. get weight(): number;
  25487. /**
  25488. * Gets the current value of the runtime animation
  25489. */
  25490. get currentValue(): any;
  25491. /**
  25492. * Gets the target path of the runtime animation
  25493. */
  25494. get targetPath(): string;
  25495. /**
  25496. * Gets the actual target of the runtime animation
  25497. */
  25498. get target(): any;
  25499. /**
  25500. * Gets the additive state of the runtime animation
  25501. */
  25502. get isAdditive(): boolean;
  25503. /** @hidden */
  25504. _onLoop: () => void;
  25505. /**
  25506. * Create a new RuntimeAnimation object
  25507. * @param target defines the target of the animation
  25508. * @param animation defines the source animation object
  25509. * @param scene defines the hosting scene
  25510. * @param host defines the initiating Animatable
  25511. */
  25512. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25513. private _preparePath;
  25514. /**
  25515. * Gets the animation from the runtime animation
  25516. */
  25517. get animation(): Animation;
  25518. /**
  25519. * Resets the runtime animation to the beginning
  25520. * @param restoreOriginal defines whether to restore the target property to the original value
  25521. */
  25522. reset(restoreOriginal?: boolean): void;
  25523. /**
  25524. * Specifies if the runtime animation is stopped
  25525. * @returns Boolean specifying if the runtime animation is stopped
  25526. */
  25527. isStopped(): boolean;
  25528. /**
  25529. * Disposes of the runtime animation
  25530. */
  25531. dispose(): void;
  25532. /**
  25533. * Apply the interpolated value to the target
  25534. * @param currentValue defines the value computed by the animation
  25535. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25536. */
  25537. setValue(currentValue: any, weight: number): void;
  25538. private _getOriginalValues;
  25539. private _setValue;
  25540. /**
  25541. * Gets the loop pmode of the runtime animation
  25542. * @returns Loop Mode
  25543. */
  25544. private _getCorrectLoopMode;
  25545. /**
  25546. * Move the current animation to a given frame
  25547. * @param frame defines the frame to move to
  25548. */
  25549. goToFrame(frame: number): void;
  25550. /**
  25551. * @hidden Internal use only
  25552. */
  25553. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25554. /**
  25555. * Execute the current animation
  25556. * @param delay defines the delay to add to the current frame
  25557. * @param from defines the lower bound of the animation range
  25558. * @param to defines the upper bound of the animation range
  25559. * @param loop defines if the current animation must loop
  25560. * @param speedRatio defines the current speed ratio
  25561. * @param weight defines the weight of the animation (default is -1 so no weight)
  25562. * @param onLoop optional callback called when animation loops
  25563. * @returns a boolean indicating if the animation is running
  25564. */
  25565. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25566. }
  25567. }
  25568. declare module BABYLON {
  25569. /**
  25570. * Class used to store an actual running animation
  25571. */
  25572. export class Animatable {
  25573. /** defines the target object */
  25574. target: any;
  25575. /** defines the starting frame number (default is 0) */
  25576. fromFrame: number;
  25577. /** defines the ending frame number (default is 100) */
  25578. toFrame: number;
  25579. /** defines if the animation must loop (default is false) */
  25580. loopAnimation: boolean;
  25581. /** defines a callback to call when animation ends if it is not looping */
  25582. onAnimationEnd?: (() => void) | null | undefined;
  25583. /** defines a callback to call when animation loops */
  25584. onAnimationLoop?: (() => void) | null | undefined;
  25585. /** defines whether the animation should be evaluated additively */
  25586. isAdditive: boolean;
  25587. private _localDelayOffset;
  25588. private _pausedDelay;
  25589. private _runtimeAnimations;
  25590. private _paused;
  25591. private _scene;
  25592. private _speedRatio;
  25593. private _weight;
  25594. private _syncRoot;
  25595. /**
  25596. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25597. * This will only apply for non looping animation (default is true)
  25598. */
  25599. disposeOnEnd: boolean;
  25600. /**
  25601. * Gets a boolean indicating if the animation has started
  25602. */
  25603. animationStarted: boolean;
  25604. /**
  25605. * Observer raised when the animation ends
  25606. */
  25607. onAnimationEndObservable: Observable<Animatable>;
  25608. /**
  25609. * Observer raised when the animation loops
  25610. */
  25611. onAnimationLoopObservable: Observable<Animatable>;
  25612. /**
  25613. * Gets the root Animatable used to synchronize and normalize animations
  25614. */
  25615. get syncRoot(): Nullable<Animatable>;
  25616. /**
  25617. * Gets the current frame of the first RuntimeAnimation
  25618. * Used to synchronize Animatables
  25619. */
  25620. get masterFrame(): number;
  25621. /**
  25622. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25623. */
  25624. get weight(): number;
  25625. set weight(value: number);
  25626. /**
  25627. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25628. */
  25629. get speedRatio(): number;
  25630. set speedRatio(value: number);
  25631. /**
  25632. * Creates a new Animatable
  25633. * @param scene defines the hosting scene
  25634. * @param target defines the target object
  25635. * @param fromFrame defines the starting frame number (default is 0)
  25636. * @param toFrame defines the ending frame number (default is 100)
  25637. * @param loopAnimation defines if the animation must loop (default is false)
  25638. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25639. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25640. * @param animations defines a group of animation to add to the new Animatable
  25641. * @param onAnimationLoop defines a callback to call when animation loops
  25642. * @param isAdditive defines whether the animation should be evaluated additively
  25643. */
  25644. constructor(scene: Scene,
  25645. /** defines the target object */
  25646. target: any,
  25647. /** defines the starting frame number (default is 0) */
  25648. fromFrame?: number,
  25649. /** defines the ending frame number (default is 100) */
  25650. toFrame?: number,
  25651. /** defines if the animation must loop (default is false) */
  25652. loopAnimation?: boolean, speedRatio?: number,
  25653. /** defines a callback to call when animation ends if it is not looping */
  25654. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25655. /** defines a callback to call when animation loops */
  25656. onAnimationLoop?: (() => void) | null | undefined,
  25657. /** defines whether the animation should be evaluated additively */
  25658. isAdditive?: boolean);
  25659. /**
  25660. * Synchronize and normalize current Animatable with a source Animatable
  25661. * This is useful when using animation weights and when animations are not of the same length
  25662. * @param root defines the root Animatable to synchronize with
  25663. * @returns the current Animatable
  25664. */
  25665. syncWith(root: Animatable): Animatable;
  25666. /**
  25667. * Gets the list of runtime animations
  25668. * @returns an array of RuntimeAnimation
  25669. */
  25670. getAnimations(): RuntimeAnimation[];
  25671. /**
  25672. * Adds more animations to the current animatable
  25673. * @param target defines the target of the animations
  25674. * @param animations defines the new animations to add
  25675. */
  25676. appendAnimations(target: any, animations: Animation[]): void;
  25677. /**
  25678. * Gets the source animation for a specific property
  25679. * @param property defines the propertyu to look for
  25680. * @returns null or the source animation for the given property
  25681. */
  25682. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25683. /**
  25684. * Gets the runtime animation for a specific property
  25685. * @param property defines the propertyu to look for
  25686. * @returns null or the runtime animation for the given property
  25687. */
  25688. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25689. /**
  25690. * Resets the animatable to its original state
  25691. */
  25692. reset(): void;
  25693. /**
  25694. * Allows the animatable to blend with current running animations
  25695. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25696. * @param blendingSpeed defines the blending speed to use
  25697. */
  25698. enableBlending(blendingSpeed: number): void;
  25699. /**
  25700. * Disable animation blending
  25701. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25702. */
  25703. disableBlending(): void;
  25704. /**
  25705. * Jump directly to a given frame
  25706. * @param frame defines the frame to jump to
  25707. */
  25708. goToFrame(frame: number): void;
  25709. /**
  25710. * Pause the animation
  25711. */
  25712. pause(): void;
  25713. /**
  25714. * Restart the animation
  25715. */
  25716. restart(): void;
  25717. private _raiseOnAnimationEnd;
  25718. /**
  25719. * Stop and delete the current animation
  25720. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25721. * @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)
  25722. */
  25723. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25724. /**
  25725. * Wait asynchronously for the animation to end
  25726. * @returns a promise which will be fullfilled when the animation ends
  25727. */
  25728. waitAsync(): Promise<Animatable>;
  25729. /** @hidden */
  25730. _animate(delay: number): boolean;
  25731. }
  25732. interface Scene {
  25733. /** @hidden */
  25734. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25735. /** @hidden */
  25736. _processLateAnimationBindingsForMatrices(holder: {
  25737. totalWeight: number;
  25738. totalAdditiveWeight: number;
  25739. animations: RuntimeAnimation[];
  25740. additiveAnimations: RuntimeAnimation[];
  25741. originalValue: Matrix;
  25742. }): any;
  25743. /** @hidden */
  25744. _processLateAnimationBindingsForQuaternions(holder: {
  25745. totalWeight: number;
  25746. totalAdditiveWeight: number;
  25747. animations: RuntimeAnimation[];
  25748. additiveAnimations: RuntimeAnimation[];
  25749. originalValue: Quaternion;
  25750. }, refQuaternion: Quaternion): Quaternion;
  25751. /** @hidden */
  25752. _processLateAnimationBindings(): void;
  25753. /**
  25754. * Will start the animation sequence of a given target
  25755. * @param target defines the target
  25756. * @param from defines from which frame should animation start
  25757. * @param to defines until which frame should animation run.
  25758. * @param weight defines the weight to apply to the animation (1.0 by default)
  25759. * @param loop defines if the animation loops
  25760. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25761. * @param onAnimationEnd defines the function to be executed when the animation ends
  25762. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25763. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25764. * @param onAnimationLoop defines the callback to call when an animation loops
  25765. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25766. * @returns the animatable object created for this animation
  25767. */
  25768. 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;
  25769. /**
  25770. * Will start the animation sequence of a given target
  25771. * @param target defines the target
  25772. * @param from defines from which frame should animation start
  25773. * @param to defines until which frame should animation run.
  25774. * @param loop defines if the animation loops
  25775. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25776. * @param onAnimationEnd defines the function to be executed when the animation ends
  25777. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25778. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25779. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25780. * @param onAnimationLoop defines the callback to call when an animation loops
  25781. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25782. * @returns the animatable object created for this animation
  25783. */
  25784. 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;
  25785. /**
  25786. * Will start the animation sequence of a given target and its hierarchy
  25787. * @param target defines the target
  25788. * @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.
  25789. * @param from defines from which frame should animation start
  25790. * @param to defines until which frame should animation run.
  25791. * @param loop defines if the animation loops
  25792. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25793. * @param onAnimationEnd defines the function to be executed when the animation ends
  25794. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25795. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25796. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25797. * @param onAnimationLoop defines the callback to call when an animation loops
  25798. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25799. * @returns the list of created animatables
  25800. */
  25801. 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[];
  25802. /**
  25803. * Begin a new animation on a given node
  25804. * @param target defines the target where the animation will take place
  25805. * @param animations defines the list of animations to start
  25806. * @param from defines the initial value
  25807. * @param to defines the final value
  25808. * @param loop defines if you want animation to loop (off by default)
  25809. * @param speedRatio defines the speed ratio to apply to all animations
  25810. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25811. * @param onAnimationLoop defines the callback to call when an animation loops
  25812. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25813. * @returns the list of created animatables
  25814. */
  25815. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25816. /**
  25817. * Begin a new animation on a given node and its hierarchy
  25818. * @param target defines the root node where the animation will take place
  25819. * @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.
  25820. * @param animations defines the list of animations to start
  25821. * @param from defines the initial value
  25822. * @param to defines the final value
  25823. * @param loop defines if you want animation to loop (off by default)
  25824. * @param speedRatio defines the speed ratio to apply to all animations
  25825. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25826. * @param onAnimationLoop defines the callback to call when an animation loops
  25827. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25828. * @returns the list of animatables created for all nodes
  25829. */
  25830. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25831. /**
  25832. * Gets the animatable associated with a specific target
  25833. * @param target defines the target of the animatable
  25834. * @returns the required animatable if found
  25835. */
  25836. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25837. /**
  25838. * Gets all animatables associated with a given target
  25839. * @param target defines the target to look animatables for
  25840. * @returns an array of Animatables
  25841. */
  25842. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25843. /**
  25844. * Stops and removes all animations that have been applied to the scene
  25845. */
  25846. stopAllAnimations(): void;
  25847. /**
  25848. * Gets the current delta time used by animation engine
  25849. */
  25850. deltaTime: number;
  25851. }
  25852. interface Bone {
  25853. /**
  25854. * Copy an animation range from another bone
  25855. * @param source defines the source bone
  25856. * @param rangeName defines the range name to copy
  25857. * @param frameOffset defines the frame offset
  25858. * @param rescaleAsRequired defines if rescaling must be applied if required
  25859. * @param skelDimensionsRatio defines the scaling ratio
  25860. * @returns true if operation was successful
  25861. */
  25862. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25863. }
  25864. }
  25865. declare module BABYLON {
  25866. /**
  25867. * Class used to override all child animations of a given target
  25868. */
  25869. export class AnimationPropertiesOverride {
  25870. /**
  25871. * Gets or sets a value indicating if animation blending must be used
  25872. */
  25873. enableBlending: boolean;
  25874. /**
  25875. * Gets or sets the blending speed to use when enableBlending is true
  25876. */
  25877. blendingSpeed: number;
  25878. /**
  25879. * Gets or sets the default loop mode to use
  25880. */
  25881. loopMode: number;
  25882. }
  25883. }
  25884. declare module BABYLON {
  25885. /**
  25886. * Class used to handle skinning animations
  25887. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25888. */
  25889. export class Skeleton implements IAnimatable {
  25890. /** defines the skeleton name */
  25891. name: string;
  25892. /** defines the skeleton Id */
  25893. id: string;
  25894. /**
  25895. * Defines the list of child bones
  25896. */
  25897. bones: Bone[];
  25898. /**
  25899. * Defines an estimate of the dimension of the skeleton at rest
  25900. */
  25901. dimensionsAtRest: Vector3;
  25902. /**
  25903. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25904. */
  25905. needInitialSkinMatrix: boolean;
  25906. /**
  25907. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25908. */
  25909. overrideMesh: Nullable<AbstractMesh>;
  25910. /**
  25911. * Gets the list of animations attached to this skeleton
  25912. */
  25913. animations: Array<Animation>;
  25914. private _scene;
  25915. private _isDirty;
  25916. private _transformMatrices;
  25917. private _transformMatrixTexture;
  25918. private _meshesWithPoseMatrix;
  25919. private _animatables;
  25920. private _identity;
  25921. private _synchronizedWithMesh;
  25922. private _ranges;
  25923. private _lastAbsoluteTransformsUpdateId;
  25924. private _canUseTextureForBones;
  25925. private _uniqueId;
  25926. /** @hidden */
  25927. _numBonesWithLinkedTransformNode: number;
  25928. /** @hidden */
  25929. _hasWaitingData: Nullable<boolean>;
  25930. /** @hidden */
  25931. _waitingOverrideMeshId: Nullable<string>;
  25932. /**
  25933. * Specifies if the skeleton should be serialized
  25934. */
  25935. doNotSerialize: boolean;
  25936. private _useTextureToStoreBoneMatrices;
  25937. /**
  25938. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25939. * Please note that this option is not available if the hardware does not support it
  25940. */
  25941. get useTextureToStoreBoneMatrices(): boolean;
  25942. set useTextureToStoreBoneMatrices(value: boolean);
  25943. private _animationPropertiesOverride;
  25944. /**
  25945. * Gets or sets the animation properties override
  25946. */
  25947. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25948. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25949. /**
  25950. * List of inspectable custom properties (used by the Inspector)
  25951. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25952. */
  25953. inspectableCustomProperties: IInspectable[];
  25954. /**
  25955. * An observable triggered before computing the skeleton's matrices
  25956. */
  25957. onBeforeComputeObservable: Observable<Skeleton>;
  25958. /**
  25959. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25960. */
  25961. get isUsingTextureForMatrices(): boolean;
  25962. /**
  25963. * Gets the unique ID of this skeleton
  25964. */
  25965. get uniqueId(): number;
  25966. /**
  25967. * Creates a new skeleton
  25968. * @param name defines the skeleton name
  25969. * @param id defines the skeleton Id
  25970. * @param scene defines the hosting scene
  25971. */
  25972. constructor(
  25973. /** defines the skeleton name */
  25974. name: string,
  25975. /** defines the skeleton Id */
  25976. id: string, scene: Scene);
  25977. /**
  25978. * Gets the current object class name.
  25979. * @return the class name
  25980. */
  25981. getClassName(): string;
  25982. /**
  25983. * Returns an array containing the root bones
  25984. * @returns an array containing the root bones
  25985. */
  25986. getChildren(): Array<Bone>;
  25987. /**
  25988. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25989. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25990. * @returns a Float32Array containing matrices data
  25991. */
  25992. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25993. /**
  25994. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25995. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25996. * @returns a raw texture containing the data
  25997. */
  25998. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25999. /**
  26000. * Gets the current hosting scene
  26001. * @returns a scene object
  26002. */
  26003. getScene(): Scene;
  26004. /**
  26005. * Gets a string representing the current skeleton data
  26006. * @param fullDetails defines a boolean indicating if we want a verbose version
  26007. * @returns a string representing the current skeleton data
  26008. */
  26009. toString(fullDetails?: boolean): string;
  26010. /**
  26011. * Get bone's index searching by name
  26012. * @param name defines bone's name to search for
  26013. * @return the indice of the bone. Returns -1 if not found
  26014. */
  26015. getBoneIndexByName(name: string): number;
  26016. /**
  26017. * Creater a new animation range
  26018. * @param name defines the name of the range
  26019. * @param from defines the start key
  26020. * @param to defines the end key
  26021. */
  26022. createAnimationRange(name: string, from: number, to: number): void;
  26023. /**
  26024. * Delete a specific animation range
  26025. * @param name defines the name of the range
  26026. * @param deleteFrames defines if frames must be removed as well
  26027. */
  26028. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26029. /**
  26030. * Gets a specific animation range
  26031. * @param name defines the name of the range to look for
  26032. * @returns the requested animation range or null if not found
  26033. */
  26034. getAnimationRange(name: string): Nullable<AnimationRange>;
  26035. /**
  26036. * Gets the list of all animation ranges defined on this skeleton
  26037. * @returns an array
  26038. */
  26039. getAnimationRanges(): Nullable<AnimationRange>[];
  26040. /**
  26041. * Copy animation range from a source skeleton.
  26042. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26043. * @param source defines the source skeleton
  26044. * @param name defines the name of the range to copy
  26045. * @param rescaleAsRequired defines if rescaling must be applied if required
  26046. * @returns true if operation was successful
  26047. */
  26048. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26049. /**
  26050. * Forces the skeleton to go to rest pose
  26051. */
  26052. returnToRest(): void;
  26053. private _getHighestAnimationFrame;
  26054. /**
  26055. * Begin a specific animation range
  26056. * @param name defines the name of the range to start
  26057. * @param loop defines if looping must be turned on (false by default)
  26058. * @param speedRatio defines the speed ratio to apply (1 by default)
  26059. * @param onAnimationEnd defines a callback which will be called when animation will end
  26060. * @returns a new animatable
  26061. */
  26062. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26063. /**
  26064. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26065. * @param skeleton defines the Skeleton containing the animation range to convert
  26066. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26067. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26068. * @returns the original skeleton
  26069. */
  26070. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26071. /** @hidden */
  26072. _markAsDirty(): void;
  26073. /** @hidden */
  26074. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26075. /** @hidden */
  26076. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26077. private _computeTransformMatrices;
  26078. /**
  26079. * Build all resources required to render a skeleton
  26080. */
  26081. prepare(): void;
  26082. /**
  26083. * Gets the list of animatables currently running for this skeleton
  26084. * @returns an array of animatables
  26085. */
  26086. getAnimatables(): IAnimatable[];
  26087. /**
  26088. * Clone the current skeleton
  26089. * @param name defines the name of the new skeleton
  26090. * @param id defines the id of the new skeleton
  26091. * @returns the new skeleton
  26092. */
  26093. clone(name: string, id?: string): Skeleton;
  26094. /**
  26095. * Enable animation blending for this skeleton
  26096. * @param blendingSpeed defines the blending speed to apply
  26097. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26098. */
  26099. enableBlending(blendingSpeed?: number): void;
  26100. /**
  26101. * Releases all resources associated with the current skeleton
  26102. */
  26103. dispose(): void;
  26104. /**
  26105. * Serialize the skeleton in a JSON object
  26106. * @returns a JSON object
  26107. */
  26108. serialize(): any;
  26109. /**
  26110. * Creates a new skeleton from serialized data
  26111. * @param parsedSkeleton defines the serialized data
  26112. * @param scene defines the hosting scene
  26113. * @returns a new skeleton
  26114. */
  26115. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26116. /**
  26117. * Compute all node absolute transforms
  26118. * @param forceUpdate defines if computation must be done even if cache is up to date
  26119. */
  26120. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26121. /**
  26122. * Gets the root pose matrix
  26123. * @returns a matrix
  26124. */
  26125. getPoseMatrix(): Nullable<Matrix>;
  26126. /**
  26127. * Sorts bones per internal index
  26128. */
  26129. sortBones(): void;
  26130. private _sortBones;
  26131. /**
  26132. * Set the current local matrix as the restPose for all bones in the skeleton.
  26133. */
  26134. setCurrentPoseAsRest(): void;
  26135. }
  26136. }
  26137. declare module BABYLON {
  26138. /**
  26139. * Class used to store bone information
  26140. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26141. */
  26142. export class Bone extends Node {
  26143. /**
  26144. * defines the bone name
  26145. */
  26146. name: string;
  26147. private static _tmpVecs;
  26148. private static _tmpQuat;
  26149. private static _tmpMats;
  26150. /**
  26151. * Gets the list of child bones
  26152. */
  26153. children: Bone[];
  26154. /** Gets the animations associated with this bone */
  26155. animations: Animation[];
  26156. /**
  26157. * Gets or sets bone length
  26158. */
  26159. length: number;
  26160. /**
  26161. * @hidden Internal only
  26162. * Set this value to map this bone to a different index in the transform matrices
  26163. * Set this value to -1 to exclude the bone from the transform matrices
  26164. */
  26165. _index: Nullable<number>;
  26166. private _skeleton;
  26167. private _localMatrix;
  26168. private _restPose;
  26169. private _bindPose;
  26170. private _baseMatrix;
  26171. private _absoluteTransform;
  26172. private _invertedAbsoluteTransform;
  26173. private _parent;
  26174. private _scalingDeterminant;
  26175. private _worldTransform;
  26176. private _localScaling;
  26177. private _localRotation;
  26178. private _localPosition;
  26179. private _needToDecompose;
  26180. private _needToCompose;
  26181. /** @hidden */
  26182. _linkedTransformNode: Nullable<TransformNode>;
  26183. /** @hidden */
  26184. _waitingTransformNodeId: Nullable<string>;
  26185. /** @hidden */
  26186. get _matrix(): Matrix;
  26187. /** @hidden */
  26188. set _matrix(value: Matrix);
  26189. /**
  26190. * Create a new bone
  26191. * @param name defines the bone name
  26192. * @param skeleton defines the parent skeleton
  26193. * @param parentBone defines the parent (can be null if the bone is the root)
  26194. * @param localMatrix defines the local matrix
  26195. * @param restPose defines the rest pose matrix
  26196. * @param baseMatrix defines the base matrix
  26197. * @param index defines index of the bone in the hiearchy
  26198. */
  26199. constructor(
  26200. /**
  26201. * defines the bone name
  26202. */
  26203. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26204. /**
  26205. * Gets the current object class name.
  26206. * @return the class name
  26207. */
  26208. getClassName(): string;
  26209. /**
  26210. * Gets the parent skeleton
  26211. * @returns a skeleton
  26212. */
  26213. getSkeleton(): Skeleton;
  26214. /**
  26215. * Gets parent bone
  26216. * @returns a bone or null if the bone is the root of the bone hierarchy
  26217. */
  26218. getParent(): Nullable<Bone>;
  26219. /**
  26220. * Returns an array containing the root bones
  26221. * @returns an array containing the root bones
  26222. */
  26223. getChildren(): Array<Bone>;
  26224. /**
  26225. * Gets the node index in matrix array generated for rendering
  26226. * @returns the node index
  26227. */
  26228. getIndex(): number;
  26229. /**
  26230. * Sets the parent bone
  26231. * @param parent defines the parent (can be null if the bone is the root)
  26232. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26233. */
  26234. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26235. /**
  26236. * Gets the local matrix
  26237. * @returns a matrix
  26238. */
  26239. getLocalMatrix(): Matrix;
  26240. /**
  26241. * Gets the base matrix (initial matrix which remains unchanged)
  26242. * @returns a matrix
  26243. */
  26244. getBaseMatrix(): Matrix;
  26245. /**
  26246. * Gets the rest pose matrix
  26247. * @returns a matrix
  26248. */
  26249. getRestPose(): Matrix;
  26250. /**
  26251. * Sets the rest pose matrix
  26252. * @param matrix the local-space rest pose to set for this bone
  26253. */
  26254. setRestPose(matrix: Matrix): void;
  26255. /**
  26256. * Gets the bind pose matrix
  26257. * @returns the bind pose matrix
  26258. */
  26259. getBindPose(): Matrix;
  26260. /**
  26261. * Sets the bind pose matrix
  26262. * @param matrix the local-space bind pose to set for this bone
  26263. */
  26264. setBindPose(matrix: Matrix): void;
  26265. /**
  26266. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26267. */
  26268. getWorldMatrix(): Matrix;
  26269. /**
  26270. * Sets the local matrix to rest pose matrix
  26271. */
  26272. returnToRest(): void;
  26273. /**
  26274. * Gets the inverse of the absolute transform matrix.
  26275. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26276. * @returns a matrix
  26277. */
  26278. getInvertedAbsoluteTransform(): Matrix;
  26279. /**
  26280. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26281. * @returns a matrix
  26282. */
  26283. getAbsoluteTransform(): Matrix;
  26284. /**
  26285. * Links with the given transform node.
  26286. * The local matrix of this bone is copied from the transform node every frame.
  26287. * @param transformNode defines the transform node to link to
  26288. */
  26289. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26290. /**
  26291. * Gets the node used to drive the bone's transformation
  26292. * @returns a transform node or null
  26293. */
  26294. getTransformNode(): Nullable<TransformNode>;
  26295. /** Gets or sets current position (in local space) */
  26296. get position(): Vector3;
  26297. set position(newPosition: Vector3);
  26298. /** Gets or sets current rotation (in local space) */
  26299. get rotation(): Vector3;
  26300. set rotation(newRotation: Vector3);
  26301. /** Gets or sets current rotation quaternion (in local space) */
  26302. get rotationQuaternion(): Quaternion;
  26303. set rotationQuaternion(newRotation: Quaternion);
  26304. /** Gets or sets current scaling (in local space) */
  26305. get scaling(): Vector3;
  26306. set scaling(newScaling: Vector3);
  26307. /**
  26308. * Gets the animation properties override
  26309. */
  26310. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26311. private _decompose;
  26312. private _compose;
  26313. /**
  26314. * Update the base and local matrices
  26315. * @param matrix defines the new base or local matrix
  26316. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26317. * @param updateLocalMatrix defines if the local matrix should be updated
  26318. */
  26319. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26320. /** @hidden */
  26321. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26322. /**
  26323. * Flag the bone as dirty (Forcing it to update everything)
  26324. */
  26325. markAsDirty(): void;
  26326. /** @hidden */
  26327. _markAsDirtyAndCompose(): void;
  26328. private _markAsDirtyAndDecompose;
  26329. /**
  26330. * Translate the bone in local or world space
  26331. * @param vec The amount to translate the bone
  26332. * @param space The space that the translation is in
  26333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26334. */
  26335. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26336. /**
  26337. * Set the postion of the bone in local or world space
  26338. * @param position The position to set the bone
  26339. * @param space The space that the position is in
  26340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26341. */
  26342. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26343. /**
  26344. * Set the absolute position of the bone (world space)
  26345. * @param position The position to set the bone
  26346. * @param mesh The mesh that this bone is attached to
  26347. */
  26348. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26349. /**
  26350. * Scale the bone on the x, y and z axes (in local space)
  26351. * @param x The amount to scale the bone on the x axis
  26352. * @param y The amount to scale the bone on the y axis
  26353. * @param z The amount to scale the bone on the z axis
  26354. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26355. */
  26356. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26357. /**
  26358. * Set the bone scaling in local space
  26359. * @param scale defines the scaling vector
  26360. */
  26361. setScale(scale: Vector3): void;
  26362. /**
  26363. * Gets the current scaling in local space
  26364. * @returns the current scaling vector
  26365. */
  26366. getScale(): Vector3;
  26367. /**
  26368. * Gets the current scaling in local space and stores it in a target vector
  26369. * @param result defines the target vector
  26370. */
  26371. getScaleToRef(result: Vector3): void;
  26372. /**
  26373. * Set the yaw, pitch, and roll of the bone in local or world space
  26374. * @param yaw The rotation of the bone on the y axis
  26375. * @param pitch The rotation of the bone on the x axis
  26376. * @param roll The rotation of the bone on the z axis
  26377. * @param space The space that the axes of rotation are in
  26378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26379. */
  26380. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26381. /**
  26382. * Add a rotation to the bone on an axis in local or world space
  26383. * @param axis The axis to rotate the bone on
  26384. * @param amount The amount to rotate the bone
  26385. * @param space The space that the axis is in
  26386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26387. */
  26388. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26389. /**
  26390. * Set the rotation of the bone to a particular axis angle in local or world space
  26391. * @param axis The axis to rotate the bone on
  26392. * @param angle The angle that the bone should be rotated to
  26393. * @param space The space that the axis is in
  26394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26395. */
  26396. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26397. /**
  26398. * Set the euler rotation of the bone in local or world space
  26399. * @param rotation The euler rotation that the bone should be set to
  26400. * @param space The space that the rotation is in
  26401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26402. */
  26403. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26404. /**
  26405. * Set the quaternion rotation of the bone in local or world space
  26406. * @param quat The quaternion rotation that the bone should be set to
  26407. * @param space The space that the rotation is in
  26408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26409. */
  26410. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26411. /**
  26412. * Set the rotation matrix of the bone in local or world space
  26413. * @param rotMat The rotation matrix that the bone should be set to
  26414. * @param space The space that the rotation is in
  26415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26416. */
  26417. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26418. private _rotateWithMatrix;
  26419. private _getNegativeRotationToRef;
  26420. /**
  26421. * Get the position of the bone in local or world space
  26422. * @param space The space that the returned position is in
  26423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26424. * @returns The position of the bone
  26425. */
  26426. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26427. /**
  26428. * Copy the position of the bone to a vector3 in local or world space
  26429. * @param space The space that the returned position is in
  26430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26431. * @param result The vector3 to copy the position to
  26432. */
  26433. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26434. /**
  26435. * Get the absolute position of the bone (world space)
  26436. * @param mesh The mesh that this bone is attached to
  26437. * @returns The absolute position of the bone
  26438. */
  26439. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26440. /**
  26441. * Copy the absolute position of the bone (world space) to the result param
  26442. * @param mesh The mesh that this bone is attached to
  26443. * @param result The vector3 to copy the absolute position to
  26444. */
  26445. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26446. /**
  26447. * Compute the absolute transforms of this bone and its children
  26448. */
  26449. computeAbsoluteTransforms(): void;
  26450. /**
  26451. * Get the world direction from an axis that is in the local space of the bone
  26452. * @param localAxis The local direction that is used to compute the world direction
  26453. * @param mesh The mesh that this bone is attached to
  26454. * @returns The world direction
  26455. */
  26456. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26457. /**
  26458. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26459. * @param localAxis The local direction that is used to compute the world direction
  26460. * @param mesh The mesh that this bone is attached to
  26461. * @param result The vector3 that the world direction will be copied to
  26462. */
  26463. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26464. /**
  26465. * Get the euler rotation of the bone in local or world space
  26466. * @param space The space that the rotation should be in
  26467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26468. * @returns The euler rotation
  26469. */
  26470. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26471. /**
  26472. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26473. * @param space The space that the rotation should be in
  26474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26475. * @param result The vector3 that the rotation should be copied to
  26476. */
  26477. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26478. /**
  26479. * Get the quaternion rotation of the bone in either local or world space
  26480. * @param space The space that the rotation should be in
  26481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26482. * @returns The quaternion rotation
  26483. */
  26484. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26485. /**
  26486. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26487. * @param space The space that the rotation should be in
  26488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26489. * @param result The quaternion that the rotation should be copied to
  26490. */
  26491. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26492. /**
  26493. * Get the rotation matrix of the bone in local or world space
  26494. * @param space The space that the rotation should be in
  26495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26496. * @returns The rotation matrix
  26497. */
  26498. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26499. /**
  26500. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26501. * @param space The space that the rotation should be in
  26502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26503. * @param result The quaternion that the rotation should be copied to
  26504. */
  26505. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26506. /**
  26507. * Get the world position of a point that is in the local space of the bone
  26508. * @param position The local position
  26509. * @param mesh The mesh that this bone is attached to
  26510. * @returns The world position
  26511. */
  26512. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26513. /**
  26514. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26515. * @param position The local position
  26516. * @param mesh The mesh that this bone is attached to
  26517. * @param result The vector3 that the world position should be copied to
  26518. */
  26519. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26520. /**
  26521. * Get the local position of a point that is in world space
  26522. * @param position The world position
  26523. * @param mesh The mesh that this bone is attached to
  26524. * @returns The local position
  26525. */
  26526. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26527. /**
  26528. * Get the local position of a point that is in world space and copy it to the result param
  26529. * @param position The world position
  26530. * @param mesh The mesh that this bone is attached to
  26531. * @param result The vector3 that the local position should be copied to
  26532. */
  26533. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26534. /**
  26535. * Set the current local matrix as the restPose for this bone.
  26536. */
  26537. setCurrentPoseAsRest(): void;
  26538. }
  26539. }
  26540. declare module BABYLON {
  26541. /**
  26542. * 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.
  26543. * @see https://doc.babylonjs.com/how_to/transformnode
  26544. */
  26545. export class TransformNode extends Node {
  26546. /**
  26547. * Object will not rotate to face the camera
  26548. */
  26549. static BILLBOARDMODE_NONE: number;
  26550. /**
  26551. * Object will rotate to face the camera but only on the x axis
  26552. */
  26553. static BILLBOARDMODE_X: number;
  26554. /**
  26555. * Object will rotate to face the camera but only on the y axis
  26556. */
  26557. static BILLBOARDMODE_Y: number;
  26558. /**
  26559. * Object will rotate to face the camera but only on the z axis
  26560. */
  26561. static BILLBOARDMODE_Z: number;
  26562. /**
  26563. * Object will rotate to face the camera
  26564. */
  26565. static BILLBOARDMODE_ALL: number;
  26566. /**
  26567. * Object will rotate to face the camera's position instead of orientation
  26568. */
  26569. static BILLBOARDMODE_USE_POSITION: number;
  26570. private static _TmpRotation;
  26571. private static _TmpScaling;
  26572. private static _TmpTranslation;
  26573. private _forward;
  26574. private _forwardInverted;
  26575. private _up;
  26576. private _right;
  26577. private _rightInverted;
  26578. private _position;
  26579. private _rotation;
  26580. private _rotationQuaternion;
  26581. protected _scaling: Vector3;
  26582. protected _isDirty: boolean;
  26583. private _transformToBoneReferal;
  26584. private _isAbsoluteSynced;
  26585. private _billboardMode;
  26586. /**
  26587. * Gets or sets the billboard mode. Default is 0.
  26588. *
  26589. * | Value | Type | Description |
  26590. * | --- | --- | --- |
  26591. * | 0 | BILLBOARDMODE_NONE | |
  26592. * | 1 | BILLBOARDMODE_X | |
  26593. * | 2 | BILLBOARDMODE_Y | |
  26594. * | 4 | BILLBOARDMODE_Z | |
  26595. * | 7 | BILLBOARDMODE_ALL | |
  26596. *
  26597. */
  26598. get billboardMode(): number;
  26599. set billboardMode(value: number);
  26600. private _preserveParentRotationForBillboard;
  26601. /**
  26602. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26603. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26604. */
  26605. get preserveParentRotationForBillboard(): boolean;
  26606. set preserveParentRotationForBillboard(value: boolean);
  26607. /**
  26608. * 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
  26609. */
  26610. scalingDeterminant: number;
  26611. private _infiniteDistance;
  26612. /**
  26613. * Gets or sets the distance of the object to max, often used by skybox
  26614. */
  26615. get infiniteDistance(): boolean;
  26616. set infiniteDistance(value: boolean);
  26617. /**
  26618. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26619. * By default the system will update normals to compensate
  26620. */
  26621. ignoreNonUniformScaling: boolean;
  26622. /**
  26623. * 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
  26624. */
  26625. reIntegrateRotationIntoRotationQuaternion: boolean;
  26626. /** @hidden */
  26627. _poseMatrix: Nullable<Matrix>;
  26628. /** @hidden */
  26629. _localMatrix: Matrix;
  26630. private _usePivotMatrix;
  26631. private _absolutePosition;
  26632. private _absoluteScaling;
  26633. private _absoluteRotationQuaternion;
  26634. private _pivotMatrix;
  26635. private _pivotMatrixInverse;
  26636. /** @hidden */
  26637. _postMultiplyPivotMatrix: boolean;
  26638. protected _isWorldMatrixFrozen: boolean;
  26639. /** @hidden */
  26640. _indexInSceneTransformNodesArray: number;
  26641. /**
  26642. * An event triggered after the world matrix is updated
  26643. */
  26644. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26645. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26646. /**
  26647. * Gets a string identifying the name of the class
  26648. * @returns "TransformNode" string
  26649. */
  26650. getClassName(): string;
  26651. /**
  26652. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26653. */
  26654. get position(): Vector3;
  26655. set position(newPosition: Vector3);
  26656. /**
  26657. * 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)).
  26658. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26659. */
  26660. get rotation(): Vector3;
  26661. set rotation(newRotation: Vector3);
  26662. /**
  26663. * 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)).
  26664. */
  26665. get scaling(): Vector3;
  26666. set scaling(newScaling: Vector3);
  26667. /**
  26668. * 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).
  26669. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26670. */
  26671. get rotationQuaternion(): Nullable<Quaternion>;
  26672. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26673. /**
  26674. * The forward direction of that transform in world space.
  26675. */
  26676. get forward(): Vector3;
  26677. /**
  26678. * The up direction of that transform in world space.
  26679. */
  26680. get up(): Vector3;
  26681. /**
  26682. * The right direction of that transform in world space.
  26683. */
  26684. get right(): Vector3;
  26685. /**
  26686. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26687. * @param matrix the matrix to copy the pose from
  26688. * @returns this TransformNode.
  26689. */
  26690. updatePoseMatrix(matrix: Matrix): TransformNode;
  26691. /**
  26692. * Returns the mesh Pose matrix.
  26693. * @returns the pose matrix
  26694. */
  26695. getPoseMatrix(): Matrix;
  26696. /** @hidden */
  26697. _isSynchronized(): boolean;
  26698. /** @hidden */
  26699. _initCache(): void;
  26700. /**
  26701. * Flag the transform node as dirty (Forcing it to update everything)
  26702. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26703. * @returns this transform node
  26704. */
  26705. markAsDirty(property: string): TransformNode;
  26706. /**
  26707. * Returns the current mesh absolute position.
  26708. * Returns a Vector3.
  26709. */
  26710. get absolutePosition(): Vector3;
  26711. /**
  26712. * Returns the current mesh absolute scaling.
  26713. * Returns a Vector3.
  26714. */
  26715. get absoluteScaling(): Vector3;
  26716. /**
  26717. * Returns the current mesh absolute rotation.
  26718. * Returns a Quaternion.
  26719. */
  26720. get absoluteRotationQuaternion(): Quaternion;
  26721. /**
  26722. * Sets a new matrix to apply before all other transformation
  26723. * @param matrix defines the transform matrix
  26724. * @returns the current TransformNode
  26725. */
  26726. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26727. /**
  26728. * Sets a new pivot matrix to the current node
  26729. * @param matrix defines the new pivot matrix to use
  26730. * @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
  26731. * @returns the current TransformNode
  26732. */
  26733. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26734. /**
  26735. * Returns the mesh pivot matrix.
  26736. * Default : Identity.
  26737. * @returns the matrix
  26738. */
  26739. getPivotMatrix(): Matrix;
  26740. /**
  26741. * Instantiate (when possible) or clone that node with its hierarchy
  26742. * @param newParent defines the new parent to use for the instance (or clone)
  26743. * @param options defines options to configure how copy is done
  26744. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26745. * @returns an instance (or a clone) of the current node with its hiearchy
  26746. */
  26747. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26748. doNotInstantiate: boolean;
  26749. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26750. /**
  26751. * Prevents the World matrix to be computed any longer
  26752. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26753. * @returns the TransformNode.
  26754. */
  26755. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26756. /**
  26757. * Allows back the World matrix computation.
  26758. * @returns the TransformNode.
  26759. */
  26760. unfreezeWorldMatrix(): this;
  26761. /**
  26762. * True if the World matrix has been frozen.
  26763. */
  26764. get isWorldMatrixFrozen(): boolean;
  26765. /**
  26766. * Retuns the mesh absolute position in the World.
  26767. * @returns a Vector3.
  26768. */
  26769. getAbsolutePosition(): Vector3;
  26770. /**
  26771. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26772. * @param absolutePosition the absolute position to set
  26773. * @returns the TransformNode.
  26774. */
  26775. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26776. /**
  26777. * Sets the mesh position in its local space.
  26778. * @param vector3 the position to set in localspace
  26779. * @returns the TransformNode.
  26780. */
  26781. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26782. /**
  26783. * Returns the mesh position in the local space from the current World matrix values.
  26784. * @returns a new Vector3.
  26785. */
  26786. getPositionExpressedInLocalSpace(): Vector3;
  26787. /**
  26788. * Translates the mesh along the passed Vector3 in its local space.
  26789. * @param vector3 the distance to translate in localspace
  26790. * @returns the TransformNode.
  26791. */
  26792. locallyTranslate(vector3: Vector3): TransformNode;
  26793. private static _lookAtVectorCache;
  26794. /**
  26795. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26796. * @param targetPoint the position (must be in same space as current mesh) to look at
  26797. * @param yawCor optional yaw (y-axis) correction in radians
  26798. * @param pitchCor optional pitch (x-axis) correction in radians
  26799. * @param rollCor optional roll (z-axis) correction in radians
  26800. * @param space the choosen space of the target
  26801. * @returns the TransformNode.
  26802. */
  26803. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26804. /**
  26805. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26806. * This Vector3 is expressed in the World space.
  26807. * @param localAxis axis to rotate
  26808. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26809. */
  26810. getDirection(localAxis: Vector3): Vector3;
  26811. /**
  26812. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26813. * localAxis is expressed in the mesh local space.
  26814. * result is computed in the Wordl space from the mesh World matrix.
  26815. * @param localAxis axis to rotate
  26816. * @param result the resulting transformnode
  26817. * @returns this TransformNode.
  26818. */
  26819. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26820. /**
  26821. * Sets this transform node rotation to the given local axis.
  26822. * @param localAxis the axis in local space
  26823. * @param yawCor optional yaw (y-axis) correction in radians
  26824. * @param pitchCor optional pitch (x-axis) correction in radians
  26825. * @param rollCor optional roll (z-axis) correction in radians
  26826. * @returns this TransformNode
  26827. */
  26828. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26829. /**
  26830. * Sets a new pivot point to the current node
  26831. * @param point defines the new pivot point to use
  26832. * @param space defines if the point is in world or local space (local by default)
  26833. * @returns the current TransformNode
  26834. */
  26835. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26836. /**
  26837. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26838. * @returns the pivot point
  26839. */
  26840. getPivotPoint(): Vector3;
  26841. /**
  26842. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26843. * @param result the vector3 to store the result
  26844. * @returns this TransformNode.
  26845. */
  26846. getPivotPointToRef(result: Vector3): TransformNode;
  26847. /**
  26848. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26849. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26850. */
  26851. getAbsolutePivotPoint(): Vector3;
  26852. /**
  26853. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26854. * @param result vector3 to store the result
  26855. * @returns this TransformNode.
  26856. */
  26857. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26858. /**
  26859. * Defines the passed node as the parent of the current node.
  26860. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26861. * @see https://doc.babylonjs.com/how_to/parenting
  26862. * @param node the node ot set as the parent
  26863. * @returns this TransformNode.
  26864. */
  26865. setParent(node: Nullable<Node>): TransformNode;
  26866. private _nonUniformScaling;
  26867. /**
  26868. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26869. */
  26870. get nonUniformScaling(): boolean;
  26871. /** @hidden */
  26872. _updateNonUniformScalingState(value: boolean): boolean;
  26873. /**
  26874. * Attach the current TransformNode to another TransformNode associated with a bone
  26875. * @param bone Bone affecting the TransformNode
  26876. * @param affectedTransformNode TransformNode associated with the bone
  26877. * @returns this object
  26878. */
  26879. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26880. /**
  26881. * Detach the transform node if its associated with a bone
  26882. * @returns this object
  26883. */
  26884. detachFromBone(): TransformNode;
  26885. private static _rotationAxisCache;
  26886. /**
  26887. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26888. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26889. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26890. * The passed axis is also normalized.
  26891. * @param axis the axis to rotate around
  26892. * @param amount the amount to rotate in radians
  26893. * @param space Space to rotate in (Default: local)
  26894. * @returns the TransformNode.
  26895. */
  26896. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26897. /**
  26898. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26899. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26900. * The passed axis is also normalized. .
  26901. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26902. * @param point the point to rotate around
  26903. * @param axis the axis to rotate around
  26904. * @param amount the amount to rotate in radians
  26905. * @returns the TransformNode
  26906. */
  26907. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26908. /**
  26909. * Translates the mesh along the axis vector for the passed distance in the given space.
  26910. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26911. * @param axis the axis to translate in
  26912. * @param distance the distance to translate
  26913. * @param space Space to rotate in (Default: local)
  26914. * @returns the TransformNode.
  26915. */
  26916. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26917. /**
  26918. * Adds a rotation step to the mesh current rotation.
  26919. * x, y, z are Euler angles expressed in radians.
  26920. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26921. * This means this rotation is made in the mesh local space only.
  26922. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26923. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26924. * ```javascript
  26925. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26926. * ```
  26927. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26928. * 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.
  26929. * @param x Rotation to add
  26930. * @param y Rotation to add
  26931. * @param z Rotation to add
  26932. * @returns the TransformNode.
  26933. */
  26934. addRotation(x: number, y: number, z: number): TransformNode;
  26935. /**
  26936. * @hidden
  26937. */
  26938. protected _getEffectiveParent(): Nullable<Node>;
  26939. /**
  26940. * Computes the world matrix of the node
  26941. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26942. * @returns the world matrix
  26943. */
  26944. computeWorldMatrix(force?: boolean): Matrix;
  26945. /**
  26946. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26947. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26948. */
  26949. resetLocalMatrix(independentOfChildren?: boolean): void;
  26950. protected _afterComputeWorldMatrix(): void;
  26951. /**
  26952. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26953. * @param func callback function to add
  26954. *
  26955. * @returns the TransformNode.
  26956. */
  26957. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26958. /**
  26959. * Removes a registered callback function.
  26960. * @param func callback function to remove
  26961. * @returns the TransformNode.
  26962. */
  26963. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26964. /**
  26965. * Gets the position of the current mesh in camera space
  26966. * @param camera defines the camera to use
  26967. * @returns a position
  26968. */
  26969. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26970. /**
  26971. * Returns the distance from the mesh to the active camera
  26972. * @param camera defines the camera to use
  26973. * @returns the distance
  26974. */
  26975. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26976. /**
  26977. * Clone the current transform node
  26978. * @param name Name of the new clone
  26979. * @param newParent New parent for the clone
  26980. * @param doNotCloneChildren Do not clone children hierarchy
  26981. * @returns the new transform node
  26982. */
  26983. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26984. /**
  26985. * Serializes the objects information.
  26986. * @param currentSerializationObject defines the object to serialize in
  26987. * @returns the serialized object
  26988. */
  26989. serialize(currentSerializationObject?: any): any;
  26990. /**
  26991. * Returns a new TransformNode object parsed from the source provided.
  26992. * @param parsedTransformNode is the source.
  26993. * @param scene the scne the object belongs to
  26994. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26995. * @returns a new TransformNode object parsed from the source provided.
  26996. */
  26997. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26998. /**
  26999. * Get all child-transformNodes of this node
  27000. * @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
  27001. * @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
  27002. * @returns an array of TransformNode
  27003. */
  27004. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27005. /**
  27006. * Releases resources associated with this transform node.
  27007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27009. */
  27010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27011. /**
  27012. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27013. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27014. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27015. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27016. * @returns the current mesh
  27017. */
  27018. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27019. private _syncAbsoluteScalingAndRotation;
  27020. }
  27021. }
  27022. declare module BABYLON {
  27023. /**
  27024. * Defines the types of pose enabled controllers that are supported
  27025. */
  27026. export enum PoseEnabledControllerType {
  27027. /**
  27028. * HTC Vive
  27029. */
  27030. VIVE = 0,
  27031. /**
  27032. * Oculus Rift
  27033. */
  27034. OCULUS = 1,
  27035. /**
  27036. * Windows mixed reality
  27037. */
  27038. WINDOWS = 2,
  27039. /**
  27040. * Samsung gear VR
  27041. */
  27042. GEAR_VR = 3,
  27043. /**
  27044. * Google Daydream
  27045. */
  27046. DAYDREAM = 4,
  27047. /**
  27048. * Generic
  27049. */
  27050. GENERIC = 5
  27051. }
  27052. /**
  27053. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27054. */
  27055. export interface MutableGamepadButton {
  27056. /**
  27057. * Value of the button/trigger
  27058. */
  27059. value: number;
  27060. /**
  27061. * If the button/trigger is currently touched
  27062. */
  27063. touched: boolean;
  27064. /**
  27065. * If the button/trigger is currently pressed
  27066. */
  27067. pressed: boolean;
  27068. }
  27069. /**
  27070. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27071. * @hidden
  27072. */
  27073. export interface ExtendedGamepadButton extends GamepadButton {
  27074. /**
  27075. * If the button/trigger is currently pressed
  27076. */
  27077. readonly pressed: boolean;
  27078. /**
  27079. * If the button/trigger is currently touched
  27080. */
  27081. readonly touched: boolean;
  27082. /**
  27083. * Value of the button/trigger
  27084. */
  27085. readonly value: number;
  27086. }
  27087. /** @hidden */
  27088. export interface _GamePadFactory {
  27089. /**
  27090. * Returns whether or not the current gamepad can be created for this type of controller.
  27091. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27092. * @returns true if it can be created, otherwise false
  27093. */
  27094. canCreate(gamepadInfo: any): boolean;
  27095. /**
  27096. * Creates a new instance of the Gamepad.
  27097. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27098. * @returns the new gamepad instance
  27099. */
  27100. create(gamepadInfo: any): Gamepad;
  27101. }
  27102. /**
  27103. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27104. */
  27105. export class PoseEnabledControllerHelper {
  27106. /** @hidden */
  27107. static _ControllerFactories: _GamePadFactory[];
  27108. /** @hidden */
  27109. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27110. /**
  27111. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27112. * @param vrGamepad the gamepad to initialized
  27113. * @returns a vr controller of the type the gamepad identified as
  27114. */
  27115. static InitiateController(vrGamepad: any): Gamepad;
  27116. }
  27117. /**
  27118. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27119. */
  27120. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27121. /**
  27122. * If the controller is used in a webXR session
  27123. */
  27124. isXR: boolean;
  27125. private _deviceRoomPosition;
  27126. private _deviceRoomRotationQuaternion;
  27127. /**
  27128. * The device position in babylon space
  27129. */
  27130. devicePosition: Vector3;
  27131. /**
  27132. * The device rotation in babylon space
  27133. */
  27134. deviceRotationQuaternion: Quaternion;
  27135. /**
  27136. * The scale factor of the device in babylon space
  27137. */
  27138. deviceScaleFactor: number;
  27139. /**
  27140. * (Likely devicePosition should be used instead) The device position in its room space
  27141. */
  27142. position: Vector3;
  27143. /**
  27144. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27145. */
  27146. rotationQuaternion: Quaternion;
  27147. /**
  27148. * The type of controller (Eg. Windows mixed reality)
  27149. */
  27150. controllerType: PoseEnabledControllerType;
  27151. protected _calculatedPosition: Vector3;
  27152. private _calculatedRotation;
  27153. /**
  27154. * The raw pose from the device
  27155. */
  27156. rawPose: DevicePose;
  27157. private _trackPosition;
  27158. private _maxRotationDistFromHeadset;
  27159. private _draggedRoomRotation;
  27160. /**
  27161. * @hidden
  27162. */
  27163. _disableTrackPosition(fixedPosition: Vector3): void;
  27164. /**
  27165. * Internal, the mesh attached to the controller
  27166. * @hidden
  27167. */
  27168. _mesh: Nullable<AbstractMesh>;
  27169. private _poseControlledCamera;
  27170. private _leftHandSystemQuaternion;
  27171. /**
  27172. * Internal, matrix used to convert room space to babylon space
  27173. * @hidden
  27174. */
  27175. _deviceToWorld: Matrix;
  27176. /**
  27177. * Node to be used when casting a ray from the controller
  27178. * @hidden
  27179. */
  27180. _pointingPoseNode: Nullable<TransformNode>;
  27181. /**
  27182. * Name of the child mesh that can be used to cast a ray from the controller
  27183. */
  27184. static readonly POINTING_POSE: string;
  27185. /**
  27186. * Creates a new PoseEnabledController from a gamepad
  27187. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27188. */
  27189. constructor(browserGamepad: any);
  27190. private _workingMatrix;
  27191. /**
  27192. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27193. */
  27194. update(): void;
  27195. /**
  27196. * Updates only the pose device and mesh without doing any button event checking
  27197. */
  27198. protected _updatePoseAndMesh(): void;
  27199. /**
  27200. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27201. * @param poseData raw pose fromthe device
  27202. */
  27203. updateFromDevice(poseData: DevicePose): void;
  27204. /**
  27205. * @hidden
  27206. */
  27207. _meshAttachedObservable: Observable<AbstractMesh>;
  27208. /**
  27209. * Attaches a mesh to the controller
  27210. * @param mesh the mesh to be attached
  27211. */
  27212. attachToMesh(mesh: AbstractMesh): void;
  27213. /**
  27214. * Attaches the controllers mesh to a camera
  27215. * @param camera the camera the mesh should be attached to
  27216. */
  27217. attachToPoseControlledCamera(camera: TargetCamera): void;
  27218. /**
  27219. * Disposes of the controller
  27220. */
  27221. dispose(): void;
  27222. /**
  27223. * The mesh that is attached to the controller
  27224. */
  27225. get mesh(): Nullable<AbstractMesh>;
  27226. /**
  27227. * Gets the ray of the controller in the direction the controller is pointing
  27228. * @param length the length the resulting ray should be
  27229. * @returns a ray in the direction the controller is pointing
  27230. */
  27231. getForwardRay(length?: number): Ray;
  27232. }
  27233. }
  27234. declare module BABYLON {
  27235. /**
  27236. * Defines the WebVRController object that represents controllers tracked in 3D space
  27237. */
  27238. export abstract class WebVRController extends PoseEnabledController {
  27239. /**
  27240. * Internal, the default controller model for the controller
  27241. */
  27242. protected _defaultModel: Nullable<AbstractMesh>;
  27243. /**
  27244. * Fired when the trigger state has changed
  27245. */
  27246. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27247. /**
  27248. * Fired when the main button state has changed
  27249. */
  27250. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27251. /**
  27252. * Fired when the secondary button state has changed
  27253. */
  27254. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27255. /**
  27256. * Fired when the pad state has changed
  27257. */
  27258. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27259. /**
  27260. * Fired when controllers stick values have changed
  27261. */
  27262. onPadValuesChangedObservable: Observable<StickValues>;
  27263. /**
  27264. * Array of button availible on the controller
  27265. */
  27266. protected _buttons: Array<MutableGamepadButton>;
  27267. private _onButtonStateChange;
  27268. /**
  27269. * Fired when a controller button's state has changed
  27270. * @param callback the callback containing the button that was modified
  27271. */
  27272. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27273. /**
  27274. * X and Y axis corresponding to the controllers joystick
  27275. */
  27276. pad: StickValues;
  27277. /**
  27278. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27279. */
  27280. hand: string;
  27281. /**
  27282. * The default controller model for the controller
  27283. */
  27284. get defaultModel(): Nullable<AbstractMesh>;
  27285. /**
  27286. * Creates a new WebVRController from a gamepad
  27287. * @param vrGamepad the gamepad that the WebVRController should be created from
  27288. */
  27289. constructor(vrGamepad: any);
  27290. /**
  27291. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27292. */
  27293. update(): void;
  27294. /**
  27295. * Function to be called when a button is modified
  27296. */
  27297. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27298. /**
  27299. * Loads a mesh and attaches it to the controller
  27300. * @param scene the scene the mesh should be added to
  27301. * @param meshLoaded callback for when the mesh has been loaded
  27302. */
  27303. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27304. private _setButtonValue;
  27305. private _changes;
  27306. private _checkChanges;
  27307. /**
  27308. * Disposes of th webVRCOntroller
  27309. */
  27310. dispose(): void;
  27311. }
  27312. }
  27313. declare module BABYLON {
  27314. /**
  27315. * The HemisphericLight simulates the ambient environment light,
  27316. * so the passed direction is the light reflection direction, not the incoming direction.
  27317. */
  27318. export class HemisphericLight extends Light {
  27319. /**
  27320. * The groundColor is the light in the opposite direction to the one specified during creation.
  27321. * 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.
  27322. */
  27323. groundColor: Color3;
  27324. /**
  27325. * The light reflection direction, not the incoming direction.
  27326. */
  27327. direction: Vector3;
  27328. /**
  27329. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27330. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27331. * The HemisphericLight can't cast shadows.
  27332. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27333. * @param name The friendly name of the light
  27334. * @param direction The direction of the light reflection
  27335. * @param scene The scene the light belongs to
  27336. */
  27337. constructor(name: string, direction: Vector3, scene: Scene);
  27338. protected _buildUniformLayout(): void;
  27339. /**
  27340. * Returns the string "HemisphericLight".
  27341. * @return The class name
  27342. */
  27343. getClassName(): string;
  27344. /**
  27345. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27346. * Returns the updated direction.
  27347. * @param target The target the direction should point to
  27348. * @return The computed direction
  27349. */
  27350. setDirectionToTarget(target: Vector3): Vector3;
  27351. /**
  27352. * Returns the shadow generator associated to the light.
  27353. * @returns Always null for hemispheric lights because it does not support shadows.
  27354. */
  27355. getShadowGenerator(): Nullable<IShadowGenerator>;
  27356. /**
  27357. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27358. * @param effect The effect to update
  27359. * @param lightIndex The index of the light in the effect to update
  27360. * @returns The hemispheric light
  27361. */
  27362. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27363. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27364. /**
  27365. * Computes the world matrix of the node
  27366. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27367. * @param useWasUpdatedFlag defines a reserved property
  27368. * @returns the world matrix
  27369. */
  27370. computeWorldMatrix(): Matrix;
  27371. /**
  27372. * Returns the integer 3.
  27373. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27374. */
  27375. getTypeID(): number;
  27376. /**
  27377. * Prepares the list of defines specific to the light type.
  27378. * @param defines the list of defines
  27379. * @param lightIndex defines the index of the light for the effect
  27380. */
  27381. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27382. }
  27383. }
  27384. declare module BABYLON {
  27385. /** @hidden */
  27386. export var vrMultiviewToSingleviewPixelShader: {
  27387. name: string;
  27388. shader: string;
  27389. };
  27390. }
  27391. declare module BABYLON {
  27392. /**
  27393. * Renders to multiple views with a single draw call
  27394. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27395. */
  27396. export class MultiviewRenderTarget extends RenderTargetTexture {
  27397. /**
  27398. * Creates a multiview render target
  27399. * @param scene scene used with the render target
  27400. * @param size the size of the render target (used for each view)
  27401. */
  27402. constructor(scene: Scene, size?: number | {
  27403. width: number;
  27404. height: number;
  27405. } | {
  27406. ratio: number;
  27407. });
  27408. /**
  27409. * @hidden
  27410. * @param faceIndex the face index, if its a cube texture
  27411. */
  27412. _bindFrameBuffer(faceIndex?: number): void;
  27413. /**
  27414. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27415. * @returns the view count
  27416. */
  27417. getViewCount(): number;
  27418. }
  27419. }
  27420. declare module BABYLON {
  27421. interface Engine {
  27422. /**
  27423. * Creates a new multiview render target
  27424. * @param width defines the width of the texture
  27425. * @param height defines the height of the texture
  27426. * @returns the created multiview texture
  27427. */
  27428. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27429. /**
  27430. * Binds a multiview framebuffer to be drawn to
  27431. * @param multiviewTexture texture to bind
  27432. */
  27433. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27434. }
  27435. interface Camera {
  27436. /**
  27437. * @hidden
  27438. * 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)
  27439. */
  27440. _useMultiviewToSingleView: boolean;
  27441. /**
  27442. * @hidden
  27443. * 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)
  27444. */
  27445. _multiviewTexture: Nullable<RenderTargetTexture>;
  27446. /**
  27447. * @hidden
  27448. * ensures the multiview texture of the camera exists and has the specified width/height
  27449. * @param width height to set on the multiview texture
  27450. * @param height width to set on the multiview texture
  27451. */
  27452. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27453. }
  27454. interface Scene {
  27455. /** @hidden */
  27456. _transformMatrixR: Matrix;
  27457. /** @hidden */
  27458. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27459. /** @hidden */
  27460. _createMultiviewUbo(): void;
  27461. /** @hidden */
  27462. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27463. /** @hidden */
  27464. _renderMultiviewToSingleView(camera: Camera): void;
  27465. }
  27466. }
  27467. declare module BABYLON {
  27468. /**
  27469. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27470. * This will not be used for webXR as it supports displaying texture arrays directly
  27471. */
  27472. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27473. /**
  27474. * Gets a string identifying the name of the class
  27475. * @returns "VRMultiviewToSingleviewPostProcess" string
  27476. */
  27477. getClassName(): string;
  27478. /**
  27479. * Initializes a VRMultiviewToSingleview
  27480. * @param name name of the post process
  27481. * @param camera camera to be applied to
  27482. * @param scaleFactor scaling factor to the size of the output texture
  27483. */
  27484. constructor(name: string, camera: Camera, scaleFactor: number);
  27485. }
  27486. }
  27487. declare module BABYLON {
  27488. /**
  27489. * Interface used to define additional presentation attributes
  27490. */
  27491. export interface IVRPresentationAttributes {
  27492. /**
  27493. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27494. */
  27495. highRefreshRate: boolean;
  27496. /**
  27497. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27498. */
  27499. foveationLevel: number;
  27500. }
  27501. interface Engine {
  27502. /** @hidden */
  27503. _vrDisplay: any;
  27504. /** @hidden */
  27505. _vrSupported: boolean;
  27506. /** @hidden */
  27507. _oldSize: Size;
  27508. /** @hidden */
  27509. _oldHardwareScaleFactor: number;
  27510. /** @hidden */
  27511. _vrExclusivePointerMode: boolean;
  27512. /** @hidden */
  27513. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27514. /** @hidden */
  27515. _onVRDisplayPointerRestricted: () => void;
  27516. /** @hidden */
  27517. _onVRDisplayPointerUnrestricted: () => void;
  27518. /** @hidden */
  27519. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27520. /** @hidden */
  27521. _onVrDisplayDisconnect: Nullable<() => void>;
  27522. /** @hidden */
  27523. _onVrDisplayPresentChange: Nullable<() => void>;
  27524. /**
  27525. * Observable signaled when VR display mode changes
  27526. */
  27527. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27528. /**
  27529. * Observable signaled when VR request present is complete
  27530. */
  27531. onVRRequestPresentComplete: Observable<boolean>;
  27532. /**
  27533. * Observable signaled when VR request present starts
  27534. */
  27535. onVRRequestPresentStart: Observable<Engine>;
  27536. /**
  27537. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27538. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27539. */
  27540. isInVRExclusivePointerMode: boolean;
  27541. /**
  27542. * Gets a boolean indicating if a webVR device was detected
  27543. * @returns true if a webVR device was detected
  27544. */
  27545. isVRDevicePresent(): boolean;
  27546. /**
  27547. * Gets the current webVR device
  27548. * @returns the current webVR device (or null)
  27549. */
  27550. getVRDevice(): any;
  27551. /**
  27552. * Initializes a webVR display and starts listening to display change events
  27553. * The onVRDisplayChangedObservable will be notified upon these changes
  27554. * @returns A promise containing a VRDisplay and if vr is supported
  27555. */
  27556. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27557. /** @hidden */
  27558. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27559. /**
  27560. * Gets or sets the presentation attributes used to configure VR rendering
  27561. */
  27562. vrPresentationAttributes?: IVRPresentationAttributes;
  27563. /**
  27564. * Call this function to switch to webVR mode
  27565. * Will do nothing if webVR is not supported or if there is no webVR device
  27566. * @param options the webvr options provided to the camera. mainly used for multiview
  27567. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27568. */
  27569. enableVR(options: WebVROptions): void;
  27570. /** @hidden */
  27571. _onVRFullScreenTriggered(): void;
  27572. }
  27573. }
  27574. declare module BABYLON {
  27575. /**
  27576. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27577. * IMPORTANT!! The data is right-hand data.
  27578. * @export
  27579. * @interface DevicePose
  27580. */
  27581. export interface DevicePose {
  27582. /**
  27583. * The position of the device, values in array are [x,y,z].
  27584. */
  27585. readonly position: Nullable<Float32Array>;
  27586. /**
  27587. * The linearVelocity of the device, values in array are [x,y,z].
  27588. */
  27589. readonly linearVelocity: Nullable<Float32Array>;
  27590. /**
  27591. * The linearAcceleration of the device, values in array are [x,y,z].
  27592. */
  27593. readonly linearAcceleration: Nullable<Float32Array>;
  27594. /**
  27595. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27596. */
  27597. readonly orientation: Nullable<Float32Array>;
  27598. /**
  27599. * The angularVelocity of the device, values in array are [x,y,z].
  27600. */
  27601. readonly angularVelocity: Nullable<Float32Array>;
  27602. /**
  27603. * The angularAcceleration of the device, values in array are [x,y,z].
  27604. */
  27605. readonly angularAcceleration: Nullable<Float32Array>;
  27606. }
  27607. /**
  27608. * Interface representing a pose controlled object in Babylon.
  27609. * A pose controlled object has both regular pose values as well as pose values
  27610. * from an external device such as a VR head mounted display
  27611. */
  27612. export interface PoseControlled {
  27613. /**
  27614. * The position of the object in babylon space.
  27615. */
  27616. position: Vector3;
  27617. /**
  27618. * The rotation quaternion of the object in babylon space.
  27619. */
  27620. rotationQuaternion: Quaternion;
  27621. /**
  27622. * The position of the device in babylon space.
  27623. */
  27624. devicePosition?: Vector3;
  27625. /**
  27626. * The rotation quaternion of the device in babylon space.
  27627. */
  27628. deviceRotationQuaternion: Quaternion;
  27629. /**
  27630. * The raw pose coming from the device.
  27631. */
  27632. rawPose: Nullable<DevicePose>;
  27633. /**
  27634. * The scale of the device to be used when translating from device space to babylon space.
  27635. */
  27636. deviceScaleFactor: number;
  27637. /**
  27638. * Updates the poseControlled values based on the input device pose.
  27639. * @param poseData the pose data to update the object with
  27640. */
  27641. updateFromDevice(poseData: DevicePose): void;
  27642. }
  27643. /**
  27644. * Set of options to customize the webVRCamera
  27645. */
  27646. export interface WebVROptions {
  27647. /**
  27648. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27649. */
  27650. trackPosition?: boolean;
  27651. /**
  27652. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27653. */
  27654. positionScale?: number;
  27655. /**
  27656. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27657. */
  27658. displayName?: string;
  27659. /**
  27660. * Should the native controller meshes be initialized. (default: true)
  27661. */
  27662. controllerMeshes?: boolean;
  27663. /**
  27664. * Creating a default HemiLight only on controllers. (default: true)
  27665. */
  27666. defaultLightingOnControllers?: boolean;
  27667. /**
  27668. * If you don't want to use the default VR button of the helper. (default: false)
  27669. */
  27670. useCustomVRButton?: boolean;
  27671. /**
  27672. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27673. */
  27674. customVRButton?: HTMLButtonElement;
  27675. /**
  27676. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27677. */
  27678. rayLength?: number;
  27679. /**
  27680. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27681. */
  27682. defaultHeight?: number;
  27683. /**
  27684. * If multiview should be used if availible (default: false)
  27685. */
  27686. useMultiview?: boolean;
  27687. }
  27688. /**
  27689. * This represents a WebVR camera.
  27690. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27691. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27692. */
  27693. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27694. private webVROptions;
  27695. /**
  27696. * @hidden
  27697. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27698. */
  27699. _vrDevice: any;
  27700. /**
  27701. * The rawPose of the vrDevice.
  27702. */
  27703. rawPose: Nullable<DevicePose>;
  27704. private _onVREnabled;
  27705. private _specsVersion;
  27706. private _attached;
  27707. private _frameData;
  27708. protected _descendants: Array<Node>;
  27709. private _deviceRoomPosition;
  27710. /** @hidden */
  27711. _deviceRoomRotationQuaternion: Quaternion;
  27712. private _standingMatrix;
  27713. /**
  27714. * Represents device position in babylon space.
  27715. */
  27716. devicePosition: Vector3;
  27717. /**
  27718. * Represents device rotation in babylon space.
  27719. */
  27720. deviceRotationQuaternion: Quaternion;
  27721. /**
  27722. * The scale of the device to be used when translating from device space to babylon space.
  27723. */
  27724. deviceScaleFactor: number;
  27725. private _deviceToWorld;
  27726. private _worldToDevice;
  27727. /**
  27728. * References to the webVR controllers for the vrDevice.
  27729. */
  27730. controllers: Array<WebVRController>;
  27731. /**
  27732. * Emits an event when a controller is attached.
  27733. */
  27734. onControllersAttachedObservable: Observable<WebVRController[]>;
  27735. /**
  27736. * Emits an event when a controller's mesh has been loaded;
  27737. */
  27738. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27739. /**
  27740. * Emits an event when the HMD's pose has been updated.
  27741. */
  27742. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27743. private _poseSet;
  27744. /**
  27745. * If the rig cameras be used as parent instead of this camera.
  27746. */
  27747. rigParenting: boolean;
  27748. private _lightOnControllers;
  27749. private _defaultHeight?;
  27750. /**
  27751. * Instantiates a WebVRFreeCamera.
  27752. * @param name The name of the WebVRFreeCamera
  27753. * @param position The starting anchor position for the camera
  27754. * @param scene The scene the camera belongs to
  27755. * @param webVROptions a set of customizable options for the webVRCamera
  27756. */
  27757. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27758. /**
  27759. * Gets the device distance from the ground in meters.
  27760. * @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.
  27761. */
  27762. deviceDistanceToRoomGround(): number;
  27763. /**
  27764. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27765. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27766. */
  27767. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27768. /**
  27769. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27770. * @returns A promise with a boolean set to if the standing matrix is supported.
  27771. */
  27772. useStandingMatrixAsync(): Promise<boolean>;
  27773. /**
  27774. * Disposes the camera
  27775. */
  27776. dispose(): void;
  27777. /**
  27778. * Gets a vrController by name.
  27779. * @param name The name of the controller to retreive
  27780. * @returns the controller matching the name specified or null if not found
  27781. */
  27782. getControllerByName(name: string): Nullable<WebVRController>;
  27783. private _leftController;
  27784. /**
  27785. * The controller corresponding to the users left hand.
  27786. */
  27787. get leftController(): Nullable<WebVRController>;
  27788. private _rightController;
  27789. /**
  27790. * The controller corresponding to the users right hand.
  27791. */
  27792. get rightController(): Nullable<WebVRController>;
  27793. /**
  27794. * Casts a ray forward from the vrCamera's gaze.
  27795. * @param length Length of the ray (default: 100)
  27796. * @returns the ray corresponding to the gaze
  27797. */
  27798. getForwardRay(length?: number): Ray;
  27799. /**
  27800. * @hidden
  27801. * Updates the camera based on device's frame data
  27802. */
  27803. _checkInputs(): void;
  27804. /**
  27805. * Updates the poseControlled values based on the input device pose.
  27806. * @param poseData Pose coming from the device
  27807. */
  27808. updateFromDevice(poseData: DevicePose): void;
  27809. private _detachIfAttached;
  27810. /**
  27811. * WebVR's attach control will start broadcasting frames to the device.
  27812. * Note that in certain browsers (chrome for example) this function must be called
  27813. * within a user-interaction callback. Example:
  27814. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27815. *
  27816. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27817. */
  27818. attachControl(noPreventDefault?: boolean): void;
  27819. /**
  27820. * Detach the current controls from the specified dom element.
  27821. */
  27822. detachControl(): void;
  27823. /**
  27824. * @returns the name of this class
  27825. */
  27826. getClassName(): string;
  27827. /**
  27828. * Calls resetPose on the vrDisplay
  27829. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27830. */
  27831. resetToCurrentRotation(): void;
  27832. /**
  27833. * @hidden
  27834. * Updates the rig cameras (left and right eye)
  27835. */
  27836. _updateRigCameras(): void;
  27837. private _workingVector;
  27838. private _oneVector;
  27839. private _workingMatrix;
  27840. private updateCacheCalled;
  27841. private _correctPositionIfNotTrackPosition;
  27842. /**
  27843. * @hidden
  27844. * Updates the cached values of the camera
  27845. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27846. */
  27847. _updateCache(ignoreParentClass?: boolean): void;
  27848. /**
  27849. * @hidden
  27850. * Get current device position in babylon world
  27851. */
  27852. _computeDevicePosition(): void;
  27853. /**
  27854. * Updates the current device position and rotation in the babylon world
  27855. */
  27856. update(): void;
  27857. /**
  27858. * @hidden
  27859. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27860. * @returns an identity matrix
  27861. */
  27862. _getViewMatrix(): Matrix;
  27863. private _tmpMatrix;
  27864. /**
  27865. * This function is called by the two RIG cameras.
  27866. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27867. * @hidden
  27868. */
  27869. _getWebVRViewMatrix(): Matrix;
  27870. /** @hidden */
  27871. _getWebVRProjectionMatrix(): Matrix;
  27872. private _onGamepadConnectedObserver;
  27873. private _onGamepadDisconnectedObserver;
  27874. private _updateCacheWhenTrackingDisabledObserver;
  27875. /**
  27876. * Initializes the controllers and their meshes
  27877. */
  27878. initControllers(): void;
  27879. }
  27880. }
  27881. declare module BABYLON {
  27882. /**
  27883. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27884. *
  27885. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27886. *
  27887. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27888. */
  27889. export class MaterialHelper {
  27890. /**
  27891. * Bind the current view position to an effect.
  27892. * @param effect The effect to be bound
  27893. * @param scene The scene the eyes position is used from
  27894. * @param variableName name of the shader variable that will hold the eye position
  27895. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27896. * @return the computed eye position
  27897. */
  27898. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27899. /**
  27900. * Helps preparing the defines values about the UVs in used in the effect.
  27901. * UVs are shared as much as we can accross channels in the shaders.
  27902. * @param texture The texture we are preparing the UVs for
  27903. * @param defines The defines to update
  27904. * @param key The channel key "diffuse", "specular"... used in the shader
  27905. */
  27906. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27907. /**
  27908. * Binds a texture matrix value to its corrsponding uniform
  27909. * @param texture The texture to bind the matrix for
  27910. * @param uniformBuffer The uniform buffer receivin the data
  27911. * @param key The channel key "diffuse", "specular"... used in the shader
  27912. */
  27913. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27914. /**
  27915. * Gets the current status of the fog (should it be enabled?)
  27916. * @param mesh defines the mesh to evaluate for fog support
  27917. * @param scene defines the hosting scene
  27918. * @returns true if fog must be enabled
  27919. */
  27920. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27921. /**
  27922. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27923. * @param mesh defines the current mesh
  27924. * @param scene defines the current scene
  27925. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27926. * @param pointsCloud defines if point cloud rendering has to be turned on
  27927. * @param fogEnabled defines if fog has to be turned on
  27928. * @param alphaTest defines if alpha testing has to be turned on
  27929. * @param defines defines the current list of defines
  27930. */
  27931. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27932. /**
  27933. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27934. * @param scene defines the current scene
  27935. * @param engine defines the current engine
  27936. * @param defines specifies the list of active defines
  27937. * @param useInstances defines if instances have to be turned on
  27938. * @param useClipPlane defines if clip plane have to be turned on
  27939. * @param useInstances defines if instances have to be turned on
  27940. * @param useThinInstances defines if thin instances have to be turned on
  27941. */
  27942. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27943. /**
  27944. * Prepares the defines for bones
  27945. * @param mesh The mesh containing the geometry data we will draw
  27946. * @param defines The defines to update
  27947. */
  27948. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27949. /**
  27950. * Prepares the defines for morph targets
  27951. * @param mesh The mesh containing the geometry data we will draw
  27952. * @param defines The defines to update
  27953. */
  27954. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27955. /**
  27956. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27957. * @param mesh The mesh containing the geometry data we will draw
  27958. * @param defines The defines to update
  27959. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27960. * @param useBones Precise whether bones should be used or not (override mesh info)
  27961. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27962. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27963. * @returns false if defines are considered not dirty and have not been checked
  27964. */
  27965. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27966. /**
  27967. * Prepares the defines related to multiview
  27968. * @param scene The scene we are intending to draw
  27969. * @param defines The defines to update
  27970. */
  27971. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27972. /**
  27973. * Prepares the defines related to the prepass
  27974. * @param scene The scene we are intending to draw
  27975. * @param defines The defines to update
  27976. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27977. */
  27978. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27979. /**
  27980. * Prepares the defines related to the light information passed in parameter
  27981. * @param scene The scene we are intending to draw
  27982. * @param mesh The mesh the effect is compiling for
  27983. * @param light The light the effect is compiling for
  27984. * @param lightIndex The index of the light
  27985. * @param defines The defines to update
  27986. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27987. * @param state Defines the current state regarding what is needed (normals, etc...)
  27988. */
  27989. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27990. needNormals: boolean;
  27991. needRebuild: boolean;
  27992. shadowEnabled: boolean;
  27993. specularEnabled: boolean;
  27994. lightmapMode: boolean;
  27995. }): void;
  27996. /**
  27997. * Prepares the defines related to the light information passed in parameter
  27998. * @param scene The scene we are intending to draw
  27999. * @param mesh The mesh the effect is compiling for
  28000. * @param defines The defines to update
  28001. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28002. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28003. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28004. * @returns true if normals will be required for the rest of the effect
  28005. */
  28006. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28007. /**
  28008. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28009. * @param lightIndex defines the light index
  28010. * @param uniformsList The uniform list
  28011. * @param samplersList The sampler list
  28012. * @param projectedLightTexture defines if projected texture must be used
  28013. * @param uniformBuffersList defines an optional list of uniform buffers
  28014. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28015. */
  28016. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28017. /**
  28018. * Prepares the uniforms and samplers list to be used in the effect
  28019. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28020. * @param samplersList The sampler list
  28021. * @param defines The defines helping in the list generation
  28022. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28023. */
  28024. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28025. /**
  28026. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28027. * @param defines The defines to update while falling back
  28028. * @param fallbacks The authorized effect fallbacks
  28029. * @param maxSimultaneousLights The maximum number of lights allowed
  28030. * @param rank the current rank of the Effect
  28031. * @returns The newly affected rank
  28032. */
  28033. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28034. private static _TmpMorphInfluencers;
  28035. /**
  28036. * Prepares the list of attributes required for morph targets according to the effect defines.
  28037. * @param attribs The current list of supported attribs
  28038. * @param mesh The mesh to prepare the morph targets attributes for
  28039. * @param influencers The number of influencers
  28040. */
  28041. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28042. /**
  28043. * Prepares the list of attributes required for morph targets according to the effect defines.
  28044. * @param attribs The current list of supported attribs
  28045. * @param mesh The mesh to prepare the morph targets attributes for
  28046. * @param defines The current Defines of the effect
  28047. */
  28048. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28049. /**
  28050. * Prepares the list of attributes required for bones according to the effect defines.
  28051. * @param attribs The current list of supported attribs
  28052. * @param mesh The mesh to prepare the bones attributes for
  28053. * @param defines The current Defines of the effect
  28054. * @param fallbacks The current efffect fallback strategy
  28055. */
  28056. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28057. /**
  28058. * Check and prepare the list of attributes required for instances according to the effect defines.
  28059. * @param attribs The current list of supported attribs
  28060. * @param defines The current MaterialDefines of the effect
  28061. */
  28062. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28063. /**
  28064. * Add the list of attributes required for instances to the attribs array.
  28065. * @param attribs The current list of supported attribs
  28066. */
  28067. static PushAttributesForInstances(attribs: string[]): void;
  28068. /**
  28069. * Binds the light information to the effect.
  28070. * @param light The light containing the generator
  28071. * @param effect The effect we are binding the data to
  28072. * @param lightIndex The light index in the effect used to render
  28073. */
  28074. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28075. /**
  28076. * Binds the lights information from the scene to the effect for the given mesh.
  28077. * @param light Light to bind
  28078. * @param lightIndex Light index
  28079. * @param scene The scene where the light belongs to
  28080. * @param effect The effect we are binding the data to
  28081. * @param useSpecular Defines if specular is supported
  28082. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28083. */
  28084. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28085. /**
  28086. * Binds the lights information from the scene to the effect for the given mesh.
  28087. * @param scene The scene the lights belongs to
  28088. * @param mesh The mesh we are binding the information to render
  28089. * @param effect The effect we are binding the data to
  28090. * @param defines The generated defines for the effect
  28091. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28092. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28093. */
  28094. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28095. private static _tempFogColor;
  28096. /**
  28097. * Binds the fog information from the scene to the effect for the given mesh.
  28098. * @param scene The scene the lights belongs to
  28099. * @param mesh The mesh we are binding the information to render
  28100. * @param effect The effect we are binding the data to
  28101. * @param linearSpace Defines if the fog effect is applied in linear space
  28102. */
  28103. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28104. /**
  28105. * Binds the bones information from the mesh to the effect.
  28106. * @param mesh The mesh we are binding the information to render
  28107. * @param effect The effect we are binding the data to
  28108. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28109. */
  28110. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28111. private static _CopyBonesTransformationMatrices;
  28112. /**
  28113. * Binds the morph targets information from the mesh to the effect.
  28114. * @param abstractMesh The mesh we are binding the information to render
  28115. * @param effect The effect we are binding the data to
  28116. */
  28117. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28118. /**
  28119. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28120. * @param defines The generated defines used in the effect
  28121. * @param effect The effect we are binding the data to
  28122. * @param scene The scene we are willing to render with logarithmic scale for
  28123. */
  28124. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28125. /**
  28126. * Binds the clip plane information from the scene to the effect.
  28127. * @param scene The scene the clip plane information are extracted from
  28128. * @param effect The effect we are binding the data to
  28129. */
  28130. static BindClipPlane(effect: Effect, scene: Scene): void;
  28131. }
  28132. }
  28133. declare module BABYLON {
  28134. /** @hidden */
  28135. export var bayerDitherFunctions: {
  28136. name: string;
  28137. shader: string;
  28138. };
  28139. }
  28140. declare module BABYLON {
  28141. /** @hidden */
  28142. export var shadowMapFragmentDeclaration: {
  28143. name: string;
  28144. shader: string;
  28145. };
  28146. }
  28147. declare module BABYLON {
  28148. /** @hidden */
  28149. export var shadowMapFragment: {
  28150. name: string;
  28151. shader: string;
  28152. };
  28153. }
  28154. declare module BABYLON {
  28155. /** @hidden */
  28156. export var shadowMapPixelShader: {
  28157. name: string;
  28158. shader: string;
  28159. };
  28160. }
  28161. declare module BABYLON {
  28162. /** @hidden */
  28163. export var shadowMapVertexDeclaration: {
  28164. name: string;
  28165. shader: string;
  28166. };
  28167. }
  28168. declare module BABYLON {
  28169. /** @hidden */
  28170. export var shadowMapVertexNormalBias: {
  28171. name: string;
  28172. shader: string;
  28173. };
  28174. }
  28175. declare module BABYLON {
  28176. /** @hidden */
  28177. export var shadowMapVertexMetric: {
  28178. name: string;
  28179. shader: string;
  28180. };
  28181. }
  28182. declare module BABYLON {
  28183. /** @hidden */
  28184. export var shadowMapVertexShader: {
  28185. name: string;
  28186. shader: string;
  28187. };
  28188. }
  28189. declare module BABYLON {
  28190. /** @hidden */
  28191. export var depthBoxBlurPixelShader: {
  28192. name: string;
  28193. shader: string;
  28194. };
  28195. }
  28196. declare module BABYLON {
  28197. /** @hidden */
  28198. export var shadowMapFragmentSoftTransparentShadow: {
  28199. name: string;
  28200. shader: string;
  28201. };
  28202. }
  28203. declare module BABYLON {
  28204. /**
  28205. * Creates an instance based on a source mesh.
  28206. */
  28207. export class InstancedMesh extends AbstractMesh {
  28208. private _sourceMesh;
  28209. private _currentLOD;
  28210. /** @hidden */
  28211. _indexInSourceMeshInstanceArray: number;
  28212. constructor(name: string, source: Mesh);
  28213. /**
  28214. * Returns the string "InstancedMesh".
  28215. */
  28216. getClassName(): string;
  28217. /** Gets the list of lights affecting that mesh */
  28218. get lightSources(): Light[];
  28219. _resyncLightSources(): void;
  28220. _resyncLightSource(light: Light): void;
  28221. _removeLightSource(light: Light, dispose: boolean): void;
  28222. /**
  28223. * If the source mesh receives shadows
  28224. */
  28225. get receiveShadows(): boolean;
  28226. /**
  28227. * The material of the source mesh
  28228. */
  28229. get material(): Nullable<Material>;
  28230. /**
  28231. * Visibility of the source mesh
  28232. */
  28233. get visibility(): number;
  28234. /**
  28235. * Skeleton of the source mesh
  28236. */
  28237. get skeleton(): Nullable<Skeleton>;
  28238. /**
  28239. * Rendering ground id of the source mesh
  28240. */
  28241. get renderingGroupId(): number;
  28242. set renderingGroupId(value: number);
  28243. /**
  28244. * Returns the total number of vertices (integer).
  28245. */
  28246. getTotalVertices(): number;
  28247. /**
  28248. * Returns a positive integer : the total number of indices in this mesh geometry.
  28249. * @returns the numner of indices or zero if the mesh has no geometry.
  28250. */
  28251. getTotalIndices(): number;
  28252. /**
  28253. * The source mesh of the instance
  28254. */
  28255. get sourceMesh(): Mesh;
  28256. /**
  28257. * Creates a new InstancedMesh object from the mesh model.
  28258. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28259. * @param name defines the name of the new instance
  28260. * @returns a new InstancedMesh
  28261. */
  28262. createInstance(name: string): InstancedMesh;
  28263. /**
  28264. * Is this node ready to be used/rendered
  28265. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28266. * @return {boolean} is it ready
  28267. */
  28268. isReady(completeCheck?: boolean): boolean;
  28269. /**
  28270. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28271. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28272. * @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.
  28273. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28274. */
  28275. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28276. /**
  28277. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28278. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28279. * The `data` are either a numeric array either a Float32Array.
  28280. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28281. * 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).
  28282. * Note that a new underlying VertexBuffer object is created each call.
  28283. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28284. *
  28285. * Possible `kind` values :
  28286. * - VertexBuffer.PositionKind
  28287. * - VertexBuffer.UVKind
  28288. * - VertexBuffer.UV2Kind
  28289. * - VertexBuffer.UV3Kind
  28290. * - VertexBuffer.UV4Kind
  28291. * - VertexBuffer.UV5Kind
  28292. * - VertexBuffer.UV6Kind
  28293. * - VertexBuffer.ColorKind
  28294. * - VertexBuffer.MatricesIndicesKind
  28295. * - VertexBuffer.MatricesIndicesExtraKind
  28296. * - VertexBuffer.MatricesWeightsKind
  28297. * - VertexBuffer.MatricesWeightsExtraKind
  28298. *
  28299. * Returns the Mesh.
  28300. */
  28301. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28302. /**
  28303. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28304. * If the mesh has no geometry, it is simply returned as it is.
  28305. * The `data` are either a numeric array either a Float32Array.
  28306. * No new underlying VertexBuffer object is created.
  28307. * 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.
  28308. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28309. *
  28310. * Possible `kind` values :
  28311. * - VertexBuffer.PositionKind
  28312. * - VertexBuffer.UVKind
  28313. * - VertexBuffer.UV2Kind
  28314. * - VertexBuffer.UV3Kind
  28315. * - VertexBuffer.UV4Kind
  28316. * - VertexBuffer.UV5Kind
  28317. * - VertexBuffer.UV6Kind
  28318. * - VertexBuffer.ColorKind
  28319. * - VertexBuffer.MatricesIndicesKind
  28320. * - VertexBuffer.MatricesIndicesExtraKind
  28321. * - VertexBuffer.MatricesWeightsKind
  28322. * - VertexBuffer.MatricesWeightsExtraKind
  28323. *
  28324. * Returns the Mesh.
  28325. */
  28326. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28327. /**
  28328. * Sets the mesh indices.
  28329. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28330. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28331. * This method creates a new index buffer each call.
  28332. * Returns the Mesh.
  28333. */
  28334. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28335. /**
  28336. * Boolean : True if the mesh owns the requested kind of data.
  28337. */
  28338. isVerticesDataPresent(kind: string): boolean;
  28339. /**
  28340. * Returns an array of indices (IndicesArray).
  28341. */
  28342. getIndices(): Nullable<IndicesArray>;
  28343. get _positions(): Nullable<Vector3[]>;
  28344. /**
  28345. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28346. * This means the mesh underlying bounding box and sphere are recomputed.
  28347. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28348. * @returns the current mesh
  28349. */
  28350. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28351. /** @hidden */
  28352. _preActivate(): InstancedMesh;
  28353. /** @hidden */
  28354. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28355. /** @hidden */
  28356. _postActivate(): void;
  28357. getWorldMatrix(): Matrix;
  28358. get isAnInstance(): boolean;
  28359. /**
  28360. * Returns the current associated LOD AbstractMesh.
  28361. */
  28362. getLOD(camera: Camera): AbstractMesh;
  28363. /** @hidden */
  28364. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28365. /** @hidden */
  28366. _syncSubMeshes(): InstancedMesh;
  28367. /** @hidden */
  28368. _generatePointsArray(): boolean;
  28369. /** @hidden */
  28370. _updateBoundingInfo(): AbstractMesh;
  28371. /**
  28372. * Creates a new InstancedMesh from the current mesh.
  28373. * - name (string) : the cloned mesh name
  28374. * - newParent (optional Node) : the optional Node to parent the clone to.
  28375. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28376. *
  28377. * Returns the clone.
  28378. */
  28379. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28380. /**
  28381. * Disposes the InstancedMesh.
  28382. * Returns nothing.
  28383. */
  28384. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28385. }
  28386. interface Mesh {
  28387. /**
  28388. * Register a custom buffer that will be instanced
  28389. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28390. * @param kind defines the buffer kind
  28391. * @param stride defines the stride in floats
  28392. */
  28393. registerInstancedBuffer(kind: string, stride: number): void;
  28394. /**
  28395. * true to use the edge renderer for all instances of this mesh
  28396. */
  28397. edgesShareWithInstances: boolean;
  28398. /** @hidden */
  28399. _userInstancedBuffersStorage: {
  28400. data: {
  28401. [key: string]: Float32Array;
  28402. };
  28403. sizes: {
  28404. [key: string]: number;
  28405. };
  28406. vertexBuffers: {
  28407. [key: string]: Nullable<VertexBuffer>;
  28408. };
  28409. strides: {
  28410. [key: string]: number;
  28411. };
  28412. };
  28413. }
  28414. interface AbstractMesh {
  28415. /**
  28416. * Object used to store instanced buffers defined by user
  28417. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28418. */
  28419. instancedBuffers: {
  28420. [key: string]: any;
  28421. };
  28422. }
  28423. }
  28424. declare module BABYLON {
  28425. /**
  28426. * Defines the options associated with the creation of a shader material.
  28427. */
  28428. export interface IShaderMaterialOptions {
  28429. /**
  28430. * Does the material work in alpha blend mode
  28431. */
  28432. needAlphaBlending: boolean;
  28433. /**
  28434. * Does the material work in alpha test mode
  28435. */
  28436. needAlphaTesting: boolean;
  28437. /**
  28438. * The list of attribute names used in the shader
  28439. */
  28440. attributes: string[];
  28441. /**
  28442. * The list of unifrom names used in the shader
  28443. */
  28444. uniforms: string[];
  28445. /**
  28446. * The list of UBO names used in the shader
  28447. */
  28448. uniformBuffers: string[];
  28449. /**
  28450. * The list of sampler names used in the shader
  28451. */
  28452. samplers: string[];
  28453. /**
  28454. * The list of defines used in the shader
  28455. */
  28456. defines: string[];
  28457. }
  28458. /**
  28459. * 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.
  28460. *
  28461. * This returned material effects how the mesh will look based on the code in the shaders.
  28462. *
  28463. * @see https://doc.babylonjs.com/how_to/shader_material
  28464. */
  28465. export class ShaderMaterial extends Material {
  28466. private _shaderPath;
  28467. private _options;
  28468. private _textures;
  28469. private _textureArrays;
  28470. private _floats;
  28471. private _ints;
  28472. private _floatsArrays;
  28473. private _colors3;
  28474. private _colors3Arrays;
  28475. private _colors4;
  28476. private _colors4Arrays;
  28477. private _vectors2;
  28478. private _vectors3;
  28479. private _vectors4;
  28480. private _matrices;
  28481. private _matrixArrays;
  28482. private _matrices3x3;
  28483. private _matrices2x2;
  28484. private _vectors2Arrays;
  28485. private _vectors3Arrays;
  28486. private _vectors4Arrays;
  28487. private _cachedWorldViewMatrix;
  28488. private _cachedWorldViewProjectionMatrix;
  28489. private _renderId;
  28490. private _multiview;
  28491. private _cachedDefines;
  28492. /** Define the Url to load snippets */
  28493. static SnippetUrl: string;
  28494. /** Snippet ID if the material was created from the snippet server */
  28495. snippetId: string;
  28496. /**
  28497. * Instantiate a new shader material.
  28498. * 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.
  28499. * This returned material effects how the mesh will look based on the code in the shaders.
  28500. * @see https://doc.babylonjs.com/how_to/shader_material
  28501. * @param name Define the name of the material in the scene
  28502. * @param scene Define the scene the material belongs to
  28503. * @param shaderPath Defines the route to the shader code in one of three ways:
  28504. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28505. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28506. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28507. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28508. * @param options Define the options used to create the shader
  28509. */
  28510. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28511. /**
  28512. * Gets the shader path used to define the shader code
  28513. * It can be modified to trigger a new compilation
  28514. */
  28515. get shaderPath(): any;
  28516. /**
  28517. * Sets the shader path used to define the shader code
  28518. * It can be modified to trigger a new compilation
  28519. */
  28520. set shaderPath(shaderPath: any);
  28521. /**
  28522. * Gets the options used to compile the shader.
  28523. * They can be modified to trigger a new compilation
  28524. */
  28525. get options(): IShaderMaterialOptions;
  28526. /**
  28527. * Gets the current class name of the material e.g. "ShaderMaterial"
  28528. * Mainly use in serialization.
  28529. * @returns the class name
  28530. */
  28531. getClassName(): string;
  28532. /**
  28533. * Specifies if the material will require alpha blending
  28534. * @returns a boolean specifying if alpha blending is needed
  28535. */
  28536. needAlphaBlending(): boolean;
  28537. /**
  28538. * Specifies if this material should be rendered in alpha test mode
  28539. * @returns a boolean specifying if an alpha test is needed.
  28540. */
  28541. needAlphaTesting(): boolean;
  28542. private _checkUniform;
  28543. /**
  28544. * Set a texture in the shader.
  28545. * @param name Define the name of the uniform samplers as defined in the shader
  28546. * @param texture Define the texture to bind to this sampler
  28547. * @return the material itself allowing "fluent" like uniform updates
  28548. */
  28549. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28550. /**
  28551. * Set a texture array in the shader.
  28552. * @param name Define the name of the uniform sampler array as defined in the shader
  28553. * @param textures Define the list of textures to bind to this sampler
  28554. * @return the material itself allowing "fluent" like uniform updates
  28555. */
  28556. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28557. /**
  28558. * Set a float in the shader.
  28559. * @param name Define the name of the uniform as defined in the shader
  28560. * @param value Define the value to give to the uniform
  28561. * @return the material itself allowing "fluent" like uniform updates
  28562. */
  28563. setFloat(name: string, value: number): ShaderMaterial;
  28564. /**
  28565. * Set a int in the shader.
  28566. * @param name Define the name of the uniform as defined in the shader
  28567. * @param value Define the value to give to the uniform
  28568. * @return the material itself allowing "fluent" like uniform updates
  28569. */
  28570. setInt(name: string, value: number): ShaderMaterial;
  28571. /**
  28572. * Set an array of floats in the shader.
  28573. * @param name Define the name of the uniform as defined in the shader
  28574. * @param value Define the value to give to the uniform
  28575. * @return the material itself allowing "fluent" like uniform updates
  28576. */
  28577. setFloats(name: string, value: number[]): ShaderMaterial;
  28578. /**
  28579. * Set a vec3 in the shader from a Color3.
  28580. * @param name Define the name of the uniform as defined in the shader
  28581. * @param value Define the value to give to the uniform
  28582. * @return the material itself allowing "fluent" like uniform updates
  28583. */
  28584. setColor3(name: string, value: Color3): ShaderMaterial;
  28585. /**
  28586. * Set a vec3 array in the shader from a Color3 array.
  28587. * @param name Define the name of the uniform as defined in the shader
  28588. * @param value Define the value to give to the uniform
  28589. * @return the material itself allowing "fluent" like uniform updates
  28590. */
  28591. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28592. /**
  28593. * Set a vec4 in the shader from a Color4.
  28594. * @param name Define the name of the uniform as defined in the shader
  28595. * @param value Define the value to give to the uniform
  28596. * @return the material itself allowing "fluent" like uniform updates
  28597. */
  28598. setColor4(name: string, value: Color4): ShaderMaterial;
  28599. /**
  28600. * Set a vec4 array in the shader from a Color4 array.
  28601. * @param name Define the name of the uniform as defined in the shader
  28602. * @param value Define the value to give to the uniform
  28603. * @return the material itself allowing "fluent" like uniform updates
  28604. */
  28605. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28606. /**
  28607. * Set a vec2 in the shader from a Vector2.
  28608. * @param name Define the name of the uniform as defined in the shader
  28609. * @param value Define the value to give to the uniform
  28610. * @return the material itself allowing "fluent" like uniform updates
  28611. */
  28612. setVector2(name: string, value: Vector2): ShaderMaterial;
  28613. /**
  28614. * Set a vec3 in the shader from a Vector3.
  28615. * @param name Define the name of the uniform as defined in the shader
  28616. * @param value Define the value to give to the uniform
  28617. * @return the material itself allowing "fluent" like uniform updates
  28618. */
  28619. setVector3(name: string, value: Vector3): ShaderMaterial;
  28620. /**
  28621. * Set a vec4 in the shader from a Vector4.
  28622. * @param name Define the name of the uniform as defined in the shader
  28623. * @param value Define the value to give to the uniform
  28624. * @return the material itself allowing "fluent" like uniform updates
  28625. */
  28626. setVector4(name: string, value: Vector4): ShaderMaterial;
  28627. /**
  28628. * Set a mat4 in the shader from a Matrix.
  28629. * @param name Define the name of the uniform as defined in the shader
  28630. * @param value Define the value to give to the uniform
  28631. * @return the material itself allowing "fluent" like uniform updates
  28632. */
  28633. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28634. /**
  28635. * Set a float32Array in the shader from a matrix array.
  28636. * @param name Define the name of the uniform as defined in the shader
  28637. * @param value Define the value to give to the uniform
  28638. * @return the material itself allowing "fluent" like uniform updates
  28639. */
  28640. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28641. /**
  28642. * Set a mat3 in the shader from a Float32Array.
  28643. * @param name Define the name of the uniform as defined in the shader
  28644. * @param value Define the value to give to the uniform
  28645. * @return the material itself allowing "fluent" like uniform updates
  28646. */
  28647. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28648. /**
  28649. * Set a mat2 in the shader from a Float32Array.
  28650. * @param name Define the name of the uniform as defined in the shader
  28651. * @param value Define the value to give to the uniform
  28652. * @return the material itself allowing "fluent" like uniform updates
  28653. */
  28654. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28655. /**
  28656. * Set a vec2 array in the shader from a number array.
  28657. * @param name Define the name of the uniform as defined in the shader
  28658. * @param value Define the value to give to the uniform
  28659. * @return the material itself allowing "fluent" like uniform updates
  28660. */
  28661. setArray2(name: string, value: number[]): ShaderMaterial;
  28662. /**
  28663. * Set a vec3 array in the shader from a number array.
  28664. * @param name Define the name of the uniform as defined in the shader
  28665. * @param value Define the value to give to the uniform
  28666. * @return the material itself allowing "fluent" like uniform updates
  28667. */
  28668. setArray3(name: string, value: number[]): ShaderMaterial;
  28669. /**
  28670. * Set a vec4 array in the shader from a number array.
  28671. * @param name Define the name of the uniform as defined in the shader
  28672. * @param value Define the value to give to the uniform
  28673. * @return the material itself allowing "fluent" like uniform updates
  28674. */
  28675. setArray4(name: string, value: number[]): ShaderMaterial;
  28676. private _checkCache;
  28677. /**
  28678. * Specifies that the submesh is ready to be used
  28679. * @param mesh defines the mesh to check
  28680. * @param subMesh defines which submesh to check
  28681. * @param useInstances specifies that instances should be used
  28682. * @returns a boolean indicating that the submesh is ready or not
  28683. */
  28684. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28685. /**
  28686. * Checks if the material is ready to render the requested mesh
  28687. * @param mesh Define the mesh to render
  28688. * @param useInstances Define whether or not the material is used with instances
  28689. * @returns true if ready, otherwise false
  28690. */
  28691. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28692. /**
  28693. * Binds the world matrix to the material
  28694. * @param world defines the world transformation matrix
  28695. * @param effectOverride - If provided, use this effect instead of internal effect
  28696. */
  28697. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28698. /**
  28699. * Binds the submesh to this material by preparing the effect and shader to draw
  28700. * @param world defines the world transformation matrix
  28701. * @param mesh defines the mesh containing the submesh
  28702. * @param subMesh defines the submesh to bind the material to
  28703. */
  28704. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28705. /**
  28706. * Binds the material to the mesh
  28707. * @param world defines the world transformation matrix
  28708. * @param mesh defines the mesh to bind the material to
  28709. * @param effectOverride - If provided, use this effect instead of internal effect
  28710. */
  28711. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28712. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28713. /**
  28714. * Gets the active textures from the material
  28715. * @returns an array of textures
  28716. */
  28717. getActiveTextures(): BaseTexture[];
  28718. /**
  28719. * Specifies if the material uses a texture
  28720. * @param texture defines the texture to check against the material
  28721. * @returns a boolean specifying if the material uses the texture
  28722. */
  28723. hasTexture(texture: BaseTexture): boolean;
  28724. /**
  28725. * Makes a duplicate of the material, and gives it a new name
  28726. * @param name defines the new name for the duplicated material
  28727. * @returns the cloned material
  28728. */
  28729. clone(name: string): ShaderMaterial;
  28730. /**
  28731. * Disposes the material
  28732. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28733. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28734. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28735. */
  28736. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28737. /**
  28738. * Serializes this material in a JSON representation
  28739. * @returns the serialized material object
  28740. */
  28741. serialize(): any;
  28742. /**
  28743. * Creates a shader material from parsed shader material data
  28744. * @param source defines the JSON represnetation of the material
  28745. * @param scene defines the hosting scene
  28746. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28747. * @returns a new material
  28748. */
  28749. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28750. /**
  28751. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28752. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28753. * @param url defines the url to load from
  28754. * @param scene defines the hosting scene
  28755. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28756. * @returns a promise that will resolve to the new ShaderMaterial
  28757. */
  28758. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28759. /**
  28760. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28761. * @param snippetId defines the snippet to load
  28762. * @param scene defines the hosting scene
  28763. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28764. * @returns a promise that will resolve to the new ShaderMaterial
  28765. */
  28766. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28767. }
  28768. }
  28769. declare module BABYLON {
  28770. /** @hidden */
  28771. export var colorPixelShader: {
  28772. name: string;
  28773. shader: string;
  28774. };
  28775. }
  28776. declare module BABYLON {
  28777. /** @hidden */
  28778. export var colorVertexShader: {
  28779. name: string;
  28780. shader: string;
  28781. };
  28782. }
  28783. declare module BABYLON {
  28784. /**
  28785. * Line mesh
  28786. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28787. */
  28788. export class LinesMesh extends Mesh {
  28789. /**
  28790. * If vertex color should be applied to the mesh
  28791. */
  28792. readonly useVertexColor?: boolean | undefined;
  28793. /**
  28794. * If vertex alpha should be applied to the mesh
  28795. */
  28796. readonly useVertexAlpha?: boolean | undefined;
  28797. /**
  28798. * Color of the line (Default: White)
  28799. */
  28800. color: Color3;
  28801. /**
  28802. * Alpha of the line (Default: 1)
  28803. */
  28804. alpha: number;
  28805. /**
  28806. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28807. * This margin is expressed in world space coordinates, so its value may vary.
  28808. * Default value is 0.1
  28809. */
  28810. intersectionThreshold: number;
  28811. private _colorShader;
  28812. private color4;
  28813. /**
  28814. * Creates a new LinesMesh
  28815. * @param name defines the name
  28816. * @param scene defines the hosting scene
  28817. * @param parent defines the parent mesh if any
  28818. * @param source defines the optional source LinesMesh used to clone data from
  28819. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28820. * When false, achieved by calling a clone(), also passing False.
  28821. * This will make creation of children, recursive.
  28822. * @param useVertexColor defines if this LinesMesh supports vertex color
  28823. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28824. */
  28825. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28826. /**
  28827. * If vertex color should be applied to the mesh
  28828. */
  28829. useVertexColor?: boolean | undefined,
  28830. /**
  28831. * If vertex alpha should be applied to the mesh
  28832. */
  28833. useVertexAlpha?: boolean | undefined);
  28834. private _addClipPlaneDefine;
  28835. private _removeClipPlaneDefine;
  28836. isReady(): boolean;
  28837. /**
  28838. * Returns the string "LineMesh"
  28839. */
  28840. getClassName(): string;
  28841. /**
  28842. * @hidden
  28843. */
  28844. get material(): Material;
  28845. /**
  28846. * @hidden
  28847. */
  28848. set material(value: Material);
  28849. /**
  28850. * @hidden
  28851. */
  28852. get checkCollisions(): boolean;
  28853. set checkCollisions(value: boolean);
  28854. /** @hidden */
  28855. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28856. /** @hidden */
  28857. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28858. /**
  28859. * Disposes of the line mesh
  28860. * @param doNotRecurse If children should be disposed
  28861. */
  28862. dispose(doNotRecurse?: boolean): void;
  28863. /**
  28864. * Returns a new LineMesh object cloned from the current one.
  28865. */
  28866. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28867. /**
  28868. * Creates a new InstancedLinesMesh object from the mesh model.
  28869. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28870. * @param name defines the name of the new instance
  28871. * @returns a new InstancedLinesMesh
  28872. */
  28873. createInstance(name: string): InstancedLinesMesh;
  28874. }
  28875. /**
  28876. * Creates an instance based on a source LinesMesh
  28877. */
  28878. export class InstancedLinesMesh extends InstancedMesh {
  28879. /**
  28880. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28881. * This margin is expressed in world space coordinates, so its value may vary.
  28882. * Initilized with the intersectionThreshold value of the source LinesMesh
  28883. */
  28884. intersectionThreshold: number;
  28885. constructor(name: string, source: LinesMesh);
  28886. /**
  28887. * Returns the string "InstancedLinesMesh".
  28888. */
  28889. getClassName(): string;
  28890. }
  28891. }
  28892. declare module BABYLON {
  28893. /** @hidden */
  28894. export var linePixelShader: {
  28895. name: string;
  28896. shader: string;
  28897. };
  28898. }
  28899. declare module BABYLON {
  28900. /** @hidden */
  28901. export var lineVertexShader: {
  28902. name: string;
  28903. shader: string;
  28904. };
  28905. }
  28906. declare module BABYLON {
  28907. interface Scene {
  28908. /** @hidden */
  28909. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28910. }
  28911. interface AbstractMesh {
  28912. /**
  28913. * Gets the edgesRenderer associated with the mesh
  28914. */
  28915. edgesRenderer: Nullable<EdgesRenderer>;
  28916. }
  28917. interface LinesMesh {
  28918. /**
  28919. * Enables the edge rendering mode on the mesh.
  28920. * This mode makes the mesh edges visible
  28921. * @param epsilon defines the maximal distance between two angles to detect a face
  28922. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28923. * @returns the currentAbstractMesh
  28924. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28925. */
  28926. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28927. }
  28928. interface InstancedLinesMesh {
  28929. /**
  28930. * Enables the edge rendering mode on the mesh.
  28931. * This mode makes the mesh edges visible
  28932. * @param epsilon defines the maximal distance between two angles to detect a face
  28933. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28934. * @returns the current InstancedLinesMesh
  28935. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28936. */
  28937. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28938. }
  28939. /**
  28940. * Defines the minimum contract an Edges renderer should follow.
  28941. */
  28942. export interface IEdgesRenderer extends IDisposable {
  28943. /**
  28944. * Gets or sets a boolean indicating if the edgesRenderer is active
  28945. */
  28946. isEnabled: boolean;
  28947. /**
  28948. * Renders the edges of the attached mesh,
  28949. */
  28950. render(): void;
  28951. /**
  28952. * Checks wether or not the edges renderer is ready to render.
  28953. * @return true if ready, otherwise false.
  28954. */
  28955. isReady(): boolean;
  28956. /**
  28957. * List of instances to render in case the source mesh has instances
  28958. */
  28959. customInstances: SmartArray<Matrix>;
  28960. }
  28961. /**
  28962. * Defines the additional options of the edges renderer
  28963. */
  28964. export interface IEdgesRendererOptions {
  28965. /**
  28966. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28967. * If not defined, the default value is true
  28968. */
  28969. useAlternateEdgeFinder?: boolean;
  28970. /**
  28971. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28972. * If not defined, the default value is true.
  28973. * 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)
  28974. * This option is used only if useAlternateEdgeFinder = true
  28975. */
  28976. useFastVertexMerger?: boolean;
  28977. /**
  28978. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28979. * The default value is 1e-6
  28980. * This option is used only if useAlternateEdgeFinder = true
  28981. */
  28982. epsilonVertexMerge?: number;
  28983. /**
  28984. * 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
  28985. * 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.
  28986. * This option is used only if useAlternateEdgeFinder = true
  28987. */
  28988. applyTessellation?: boolean;
  28989. /**
  28990. * 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
  28991. * The default value is 1e-6
  28992. * This option is used only if useAlternateEdgeFinder = true
  28993. */
  28994. epsilonVertexAligned?: number;
  28995. }
  28996. /**
  28997. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28998. */
  28999. export class EdgesRenderer implements IEdgesRenderer {
  29000. /**
  29001. * Define the size of the edges with an orthographic camera
  29002. */
  29003. edgesWidthScalerForOrthographic: number;
  29004. /**
  29005. * Define the size of the edges with a perspective camera
  29006. */
  29007. edgesWidthScalerForPerspective: number;
  29008. protected _source: AbstractMesh;
  29009. protected _linesPositions: number[];
  29010. protected _linesNormals: number[];
  29011. protected _linesIndices: number[];
  29012. protected _epsilon: number;
  29013. protected _indicesCount: number;
  29014. protected _lineShader: ShaderMaterial;
  29015. protected _ib: DataBuffer;
  29016. protected _buffers: {
  29017. [key: string]: Nullable<VertexBuffer>;
  29018. };
  29019. protected _buffersForInstances: {
  29020. [key: string]: Nullable<VertexBuffer>;
  29021. };
  29022. protected _checkVerticesInsteadOfIndices: boolean;
  29023. protected _options: Nullable<IEdgesRendererOptions>;
  29024. private _meshRebuildObserver;
  29025. private _meshDisposeObserver;
  29026. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29027. isEnabled: boolean;
  29028. /** Gets the vertices generated by the edge renderer */
  29029. get linesPositions(): Immutable<Array<number>>;
  29030. /** Gets the normals generated by the edge renderer */
  29031. get linesNormals(): Immutable<Array<number>>;
  29032. /** Gets the indices generated by the edge renderer */
  29033. get linesIndices(): Immutable<Array<number>>;
  29034. /**
  29035. * List of instances to render in case the source mesh has instances
  29036. */
  29037. customInstances: SmartArray<Matrix>;
  29038. private static GetShader;
  29039. /**
  29040. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29041. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29042. * @param source Mesh used to create edges
  29043. * @param epsilon sum of angles in adjacency to check for edge
  29044. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29045. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29046. * @param options The options to apply when generating the edges
  29047. */
  29048. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29049. protected _prepareRessources(): void;
  29050. /** @hidden */
  29051. _rebuild(): void;
  29052. /**
  29053. * Releases the required resources for the edges renderer
  29054. */
  29055. dispose(): void;
  29056. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29057. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29058. /**
  29059. * Checks if the pair of p0 and p1 is en edge
  29060. * @param faceIndex
  29061. * @param edge
  29062. * @param faceNormals
  29063. * @param p0
  29064. * @param p1
  29065. * @private
  29066. */
  29067. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29068. /**
  29069. * push line into the position, normal and index buffer
  29070. * @protected
  29071. */
  29072. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29073. /**
  29074. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29075. */
  29076. private _tessellateTriangle;
  29077. private _generateEdgesLinesAlternate;
  29078. /**
  29079. * Generates lines edges from adjacencjes
  29080. * @private
  29081. */
  29082. _generateEdgesLines(): void;
  29083. /**
  29084. * Checks wether or not the edges renderer is ready to render.
  29085. * @return true if ready, otherwise false.
  29086. */
  29087. isReady(): boolean;
  29088. /**
  29089. * Renders the edges of the attached mesh,
  29090. */
  29091. render(): void;
  29092. }
  29093. /**
  29094. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29095. */
  29096. export class LineEdgesRenderer extends EdgesRenderer {
  29097. /**
  29098. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29099. * @param source LineMesh used to generate edges
  29100. * @param epsilon not important (specified angle for edge detection)
  29101. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29102. */
  29103. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29104. /**
  29105. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29106. */
  29107. _generateEdgesLines(): void;
  29108. }
  29109. }
  29110. declare module BABYLON {
  29111. /**
  29112. * This represents the object necessary to create a rendering group.
  29113. * This is exclusively used and created by the rendering manager.
  29114. * To modify the behavior, you use the available helpers in your scene or meshes.
  29115. * @hidden
  29116. */
  29117. export class RenderingGroup {
  29118. index: number;
  29119. private static _zeroVector;
  29120. private _scene;
  29121. private _opaqueSubMeshes;
  29122. private _transparentSubMeshes;
  29123. private _alphaTestSubMeshes;
  29124. private _depthOnlySubMeshes;
  29125. private _particleSystems;
  29126. private _spriteManagers;
  29127. private _opaqueSortCompareFn;
  29128. private _alphaTestSortCompareFn;
  29129. private _transparentSortCompareFn;
  29130. private _renderOpaque;
  29131. private _renderAlphaTest;
  29132. private _renderTransparent;
  29133. /** @hidden */
  29134. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29135. onBeforeTransparentRendering: () => void;
  29136. /**
  29137. * Set the opaque sort comparison function.
  29138. * If null the sub meshes will be render in the order they were created
  29139. */
  29140. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29141. /**
  29142. * Set the alpha test sort comparison function.
  29143. * If null the sub meshes will be render in the order they were created
  29144. */
  29145. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29146. /**
  29147. * Set the transparent sort comparison function.
  29148. * If null the sub meshes will be render in the order they were created
  29149. */
  29150. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29151. /**
  29152. * Creates a new rendering group.
  29153. * @param index The rendering group index
  29154. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29155. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29156. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29157. */
  29158. 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>);
  29159. /**
  29160. * Render all the sub meshes contained in the group.
  29161. * @param customRenderFunction Used to override the default render behaviour of the group.
  29162. * @returns true if rendered some submeshes.
  29163. */
  29164. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29165. /**
  29166. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29167. * @param subMeshes The submeshes to render
  29168. */
  29169. private renderOpaqueSorted;
  29170. /**
  29171. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29172. * @param subMeshes The submeshes to render
  29173. */
  29174. private renderAlphaTestSorted;
  29175. /**
  29176. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29177. * @param subMeshes The submeshes to render
  29178. */
  29179. private renderTransparentSorted;
  29180. /**
  29181. * Renders the submeshes in a specified order.
  29182. * @param subMeshes The submeshes to sort before render
  29183. * @param sortCompareFn The comparison function use to sort
  29184. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29185. * @param transparent Specifies to activate blending if true
  29186. */
  29187. private static renderSorted;
  29188. /**
  29189. * Renders the submeshes in the order they were dispatched (no sort applied).
  29190. * @param subMeshes The submeshes to render
  29191. */
  29192. private static renderUnsorted;
  29193. /**
  29194. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29195. * are rendered back to front if in the same alpha index.
  29196. *
  29197. * @param a The first submesh
  29198. * @param b The second submesh
  29199. * @returns The result of the comparison
  29200. */
  29201. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29202. /**
  29203. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29204. * are rendered back to front.
  29205. *
  29206. * @param a The first submesh
  29207. * @param b The second submesh
  29208. * @returns The result of the comparison
  29209. */
  29210. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29211. /**
  29212. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29213. * are rendered front to back (prevent overdraw).
  29214. *
  29215. * @param a The first submesh
  29216. * @param b The second submesh
  29217. * @returns The result of the comparison
  29218. */
  29219. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29220. /**
  29221. * Resets the different lists of submeshes to prepare a new frame.
  29222. */
  29223. prepare(): void;
  29224. dispose(): void;
  29225. /**
  29226. * Inserts the submesh in its correct queue depending on its material.
  29227. * @param subMesh The submesh to dispatch
  29228. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29229. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29230. */
  29231. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29232. dispatchSprites(spriteManager: ISpriteManager): void;
  29233. dispatchParticles(particleSystem: IParticleSystem): void;
  29234. private _renderParticles;
  29235. private _renderSprites;
  29236. }
  29237. }
  29238. declare module BABYLON {
  29239. /**
  29240. * Interface describing the different options available in the rendering manager
  29241. * regarding Auto Clear between groups.
  29242. */
  29243. export interface IRenderingManagerAutoClearSetup {
  29244. /**
  29245. * Defines whether or not autoclear is enable.
  29246. */
  29247. autoClear: boolean;
  29248. /**
  29249. * Defines whether or not to autoclear the depth buffer.
  29250. */
  29251. depth: boolean;
  29252. /**
  29253. * Defines whether or not to autoclear the stencil buffer.
  29254. */
  29255. stencil: boolean;
  29256. }
  29257. /**
  29258. * This class is used by the onRenderingGroupObservable
  29259. */
  29260. export class RenderingGroupInfo {
  29261. /**
  29262. * The Scene that being rendered
  29263. */
  29264. scene: Scene;
  29265. /**
  29266. * The camera currently used for the rendering pass
  29267. */
  29268. camera: Nullable<Camera>;
  29269. /**
  29270. * The ID of the renderingGroup being processed
  29271. */
  29272. renderingGroupId: number;
  29273. }
  29274. /**
  29275. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29276. * It is enable to manage the different groups as well as the different necessary sort functions.
  29277. * This should not be used directly aside of the few static configurations
  29278. */
  29279. export class RenderingManager {
  29280. /**
  29281. * The max id used for rendering groups (not included)
  29282. */
  29283. static MAX_RENDERINGGROUPS: number;
  29284. /**
  29285. * The min id used for rendering groups (included)
  29286. */
  29287. static MIN_RENDERINGGROUPS: number;
  29288. /**
  29289. * Used to globally prevent autoclearing scenes.
  29290. */
  29291. static AUTOCLEAR: boolean;
  29292. /**
  29293. * @hidden
  29294. */
  29295. _useSceneAutoClearSetup: boolean;
  29296. private _scene;
  29297. private _renderingGroups;
  29298. private _depthStencilBufferAlreadyCleaned;
  29299. private _autoClearDepthStencil;
  29300. private _customOpaqueSortCompareFn;
  29301. private _customAlphaTestSortCompareFn;
  29302. private _customTransparentSortCompareFn;
  29303. private _renderingGroupInfo;
  29304. /**
  29305. * Instantiates a new rendering group for a particular scene
  29306. * @param scene Defines the scene the groups belongs to
  29307. */
  29308. constructor(scene: Scene);
  29309. private _clearDepthStencilBuffer;
  29310. /**
  29311. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29312. * @hidden
  29313. */
  29314. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29315. /**
  29316. * Resets the different information of the group to prepare a new frame
  29317. * @hidden
  29318. */
  29319. reset(): void;
  29320. /**
  29321. * Dispose and release the group and its associated resources.
  29322. * @hidden
  29323. */
  29324. dispose(): void;
  29325. /**
  29326. * Clear the info related to rendering groups preventing retention points during dispose.
  29327. */
  29328. freeRenderingGroups(): void;
  29329. private _prepareRenderingGroup;
  29330. /**
  29331. * Add a sprite manager to the rendering manager in order to render it this frame.
  29332. * @param spriteManager Define the sprite manager to render
  29333. */
  29334. dispatchSprites(spriteManager: ISpriteManager): void;
  29335. /**
  29336. * Add a particle system to the rendering manager in order to render it this frame.
  29337. * @param particleSystem Define the particle system to render
  29338. */
  29339. dispatchParticles(particleSystem: IParticleSystem): void;
  29340. /**
  29341. * Add a submesh to the manager in order to render it this frame
  29342. * @param subMesh The submesh to dispatch
  29343. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29344. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29345. */
  29346. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29347. /**
  29348. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29349. * This allowed control for front to back rendering or reversly depending of the special needs.
  29350. *
  29351. * @param renderingGroupId The rendering group id corresponding to its index
  29352. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29353. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29354. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29355. */
  29356. 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;
  29357. /**
  29358. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29359. *
  29360. * @param renderingGroupId The rendering group id corresponding to its index
  29361. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29362. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29363. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29364. */
  29365. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29366. /**
  29367. * Gets the current auto clear configuration for one rendering group of the rendering
  29368. * manager.
  29369. * @param index the rendering group index to get the information for
  29370. * @returns The auto clear setup for the requested rendering group
  29371. */
  29372. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29373. }
  29374. }
  29375. declare module BABYLON {
  29376. /**
  29377. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29378. */
  29379. export interface ICustomShaderOptions {
  29380. /**
  29381. * Gets or sets the custom shader name to use
  29382. */
  29383. shaderName: string;
  29384. /**
  29385. * The list of attribute names used in the shader
  29386. */
  29387. attributes?: string[];
  29388. /**
  29389. * The list of unifrom names used in the shader
  29390. */
  29391. uniforms?: string[];
  29392. /**
  29393. * The list of sampler names used in the shader
  29394. */
  29395. samplers?: string[];
  29396. /**
  29397. * The list of defines used in the shader
  29398. */
  29399. defines?: string[];
  29400. }
  29401. /**
  29402. * Interface to implement to create a shadow generator compatible with BJS.
  29403. */
  29404. export interface IShadowGenerator {
  29405. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29406. id: string;
  29407. /**
  29408. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29409. * @returns The render target texture if present otherwise, null
  29410. */
  29411. getShadowMap(): Nullable<RenderTargetTexture>;
  29412. /**
  29413. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29414. * @param subMesh The submesh we want to render in the shadow map
  29415. * @param useInstances Defines wether will draw in the map using instances
  29416. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29417. * @returns true if ready otherwise, false
  29418. */
  29419. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29420. /**
  29421. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29422. * @param defines Defines of the material we want to update
  29423. * @param lightIndex Index of the light in the enabled light list of the material
  29424. */
  29425. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29426. /**
  29427. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29428. * defined in the generator but impacting the effect).
  29429. * It implies the unifroms available on the materials are the standard BJS ones.
  29430. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29431. * @param effect The effect we are binfing the information for
  29432. */
  29433. bindShadowLight(lightIndex: string, effect: Effect): void;
  29434. /**
  29435. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29436. * (eq to shadow prjection matrix * light transform matrix)
  29437. * @returns The transform matrix used to create the shadow map
  29438. */
  29439. getTransformMatrix(): Matrix;
  29440. /**
  29441. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29442. * Cube and 2D textures for instance.
  29443. */
  29444. recreateShadowMap(): void;
  29445. /**
  29446. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29447. * @param onCompiled Callback triggered at the and of the effects compilation
  29448. * @param options Sets of optional options forcing the compilation with different modes
  29449. */
  29450. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29451. useInstances: boolean;
  29452. }>): void;
  29453. /**
  29454. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29455. * @param options Sets of optional options forcing the compilation with different modes
  29456. * @returns A promise that resolves when the compilation completes
  29457. */
  29458. forceCompilationAsync(options?: Partial<{
  29459. useInstances: boolean;
  29460. }>): Promise<void>;
  29461. /**
  29462. * Serializes the shadow generator setup to a json object.
  29463. * @returns The serialized JSON object
  29464. */
  29465. serialize(): any;
  29466. /**
  29467. * Disposes the Shadow map and related Textures and effects.
  29468. */
  29469. dispose(): void;
  29470. }
  29471. /**
  29472. * Default implementation IShadowGenerator.
  29473. * This is the main object responsible of generating shadows in the framework.
  29474. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29475. */
  29476. export class ShadowGenerator implements IShadowGenerator {
  29477. private static _Counter;
  29478. /**
  29479. * Name of the shadow generator class
  29480. */
  29481. static CLASSNAME: string;
  29482. /**
  29483. * Shadow generator mode None: no filtering applied.
  29484. */
  29485. static readonly FILTER_NONE: number;
  29486. /**
  29487. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29488. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29489. */
  29490. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29491. /**
  29492. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29493. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29494. */
  29495. static readonly FILTER_POISSONSAMPLING: number;
  29496. /**
  29497. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29498. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29499. */
  29500. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29501. /**
  29502. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29503. * edge artifacts on steep falloff.
  29504. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29505. */
  29506. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29507. /**
  29508. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29509. * edge artifacts on steep falloff.
  29510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29511. */
  29512. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29513. /**
  29514. * Shadow generator mode PCF: Percentage Closer Filtering
  29515. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29516. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29517. */
  29518. static readonly FILTER_PCF: number;
  29519. /**
  29520. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29521. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29522. * Contact Hardening
  29523. */
  29524. static readonly FILTER_PCSS: number;
  29525. /**
  29526. * Reserved for PCF and PCSS
  29527. * Highest Quality.
  29528. *
  29529. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29530. *
  29531. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29532. */
  29533. static readonly QUALITY_HIGH: number;
  29534. /**
  29535. * Reserved for PCF and PCSS
  29536. * Good tradeoff for quality/perf cross devices
  29537. *
  29538. * Execute PCF on a 3*3 kernel.
  29539. *
  29540. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29541. */
  29542. static readonly QUALITY_MEDIUM: number;
  29543. /**
  29544. * Reserved for PCF and PCSS
  29545. * The lowest quality but the fastest.
  29546. *
  29547. * Execute PCF on a 1*1 kernel.
  29548. *
  29549. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29550. */
  29551. static readonly QUALITY_LOW: number;
  29552. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29553. id: string;
  29554. /** Gets or sets the custom shader name to use */
  29555. customShaderOptions: ICustomShaderOptions;
  29556. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29557. customAllowRendering: (subMesh: SubMesh) => boolean;
  29558. /**
  29559. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29560. */
  29561. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29562. /**
  29563. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29564. */
  29565. onAfterShadowMapRenderObservable: Observable<Effect>;
  29566. /**
  29567. * Observable triggered before a mesh is rendered in the shadow map.
  29568. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29569. */
  29570. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29571. /**
  29572. * Observable triggered after a mesh is rendered in the shadow map.
  29573. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29574. */
  29575. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29576. protected _bias: number;
  29577. /**
  29578. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29579. */
  29580. get bias(): number;
  29581. /**
  29582. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29583. */
  29584. set bias(bias: number);
  29585. protected _normalBias: number;
  29586. /**
  29587. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29588. */
  29589. get normalBias(): number;
  29590. /**
  29591. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29592. */
  29593. set normalBias(normalBias: number);
  29594. protected _blurBoxOffset: number;
  29595. /**
  29596. * Gets the blur box offset: offset applied during the blur pass.
  29597. * Only useful if useKernelBlur = false
  29598. */
  29599. get blurBoxOffset(): number;
  29600. /**
  29601. * Sets the blur box offset: offset applied during the blur pass.
  29602. * Only useful if useKernelBlur = false
  29603. */
  29604. set blurBoxOffset(value: number);
  29605. protected _blurScale: number;
  29606. /**
  29607. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29608. * 2 means half of the size.
  29609. */
  29610. get blurScale(): number;
  29611. /**
  29612. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29613. * 2 means half of the size.
  29614. */
  29615. set blurScale(value: number);
  29616. protected _blurKernel: number;
  29617. /**
  29618. * Gets the blur kernel: kernel size of the blur pass.
  29619. * Only useful if useKernelBlur = true
  29620. */
  29621. get blurKernel(): number;
  29622. /**
  29623. * Sets the blur kernel: kernel size of the blur pass.
  29624. * Only useful if useKernelBlur = true
  29625. */
  29626. set blurKernel(value: number);
  29627. protected _useKernelBlur: boolean;
  29628. /**
  29629. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29630. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29631. */
  29632. get useKernelBlur(): boolean;
  29633. /**
  29634. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29635. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29636. */
  29637. set useKernelBlur(value: boolean);
  29638. protected _depthScale: number;
  29639. /**
  29640. * Gets the depth scale used in ESM mode.
  29641. */
  29642. get depthScale(): number;
  29643. /**
  29644. * Sets the depth scale used in ESM mode.
  29645. * This can override the scale stored on the light.
  29646. */
  29647. set depthScale(value: number);
  29648. protected _validateFilter(filter: number): number;
  29649. protected _filter: number;
  29650. /**
  29651. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29652. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29653. */
  29654. get filter(): number;
  29655. /**
  29656. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29657. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29658. */
  29659. set filter(value: number);
  29660. /**
  29661. * Gets if the current filter is set to Poisson Sampling.
  29662. */
  29663. get usePoissonSampling(): boolean;
  29664. /**
  29665. * Sets the current filter to Poisson Sampling.
  29666. */
  29667. set usePoissonSampling(value: boolean);
  29668. /**
  29669. * Gets if the current filter is set to ESM.
  29670. */
  29671. get useExponentialShadowMap(): boolean;
  29672. /**
  29673. * Sets the current filter is to ESM.
  29674. */
  29675. set useExponentialShadowMap(value: boolean);
  29676. /**
  29677. * Gets if the current filter is set to filtered ESM.
  29678. */
  29679. get useBlurExponentialShadowMap(): boolean;
  29680. /**
  29681. * Gets if the current filter is set to filtered ESM.
  29682. */
  29683. set useBlurExponentialShadowMap(value: boolean);
  29684. /**
  29685. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29686. * exponential to prevent steep falloff artifacts).
  29687. */
  29688. get useCloseExponentialShadowMap(): boolean;
  29689. /**
  29690. * Sets the current filter to "close ESM" (using the inverse of the
  29691. * exponential to prevent steep falloff artifacts).
  29692. */
  29693. set useCloseExponentialShadowMap(value: boolean);
  29694. /**
  29695. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29696. * exponential to prevent steep falloff artifacts).
  29697. */
  29698. get useBlurCloseExponentialShadowMap(): boolean;
  29699. /**
  29700. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29701. * exponential to prevent steep falloff artifacts).
  29702. */
  29703. set useBlurCloseExponentialShadowMap(value: boolean);
  29704. /**
  29705. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29706. */
  29707. get usePercentageCloserFiltering(): boolean;
  29708. /**
  29709. * Sets the current filter to "PCF" (percentage closer filtering).
  29710. */
  29711. set usePercentageCloserFiltering(value: boolean);
  29712. protected _filteringQuality: number;
  29713. /**
  29714. * Gets the PCF or PCSS Quality.
  29715. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29716. */
  29717. get filteringQuality(): number;
  29718. /**
  29719. * Sets the PCF or PCSS Quality.
  29720. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29721. */
  29722. set filteringQuality(filteringQuality: number);
  29723. /**
  29724. * Gets if the current filter is set to "PCSS" (contact hardening).
  29725. */
  29726. get useContactHardeningShadow(): boolean;
  29727. /**
  29728. * Sets the current filter to "PCSS" (contact hardening).
  29729. */
  29730. set useContactHardeningShadow(value: boolean);
  29731. protected _contactHardeningLightSizeUVRatio: number;
  29732. /**
  29733. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29734. * Using a ratio helps keeping shape stability independently of the map size.
  29735. *
  29736. * It does not account for the light projection as it was having too much
  29737. * instability during the light setup or during light position changes.
  29738. *
  29739. * Only valid if useContactHardeningShadow is true.
  29740. */
  29741. get contactHardeningLightSizeUVRatio(): number;
  29742. /**
  29743. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29744. * Using a ratio helps keeping shape stability independently of the map size.
  29745. *
  29746. * It does not account for the light projection as it was having too much
  29747. * instability during the light setup or during light position changes.
  29748. *
  29749. * Only valid if useContactHardeningShadow is true.
  29750. */
  29751. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29752. protected _darkness: number;
  29753. /** Gets or sets the actual darkness of a shadow */
  29754. get darkness(): number;
  29755. set darkness(value: number);
  29756. /**
  29757. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29758. * 0 means strongest and 1 would means no shadow.
  29759. * @returns the darkness.
  29760. */
  29761. getDarkness(): number;
  29762. /**
  29763. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29764. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29765. * @returns the shadow generator allowing fluent coding.
  29766. */
  29767. setDarkness(darkness: number): ShadowGenerator;
  29768. protected _transparencyShadow: boolean;
  29769. /** Gets or sets the ability to have transparent shadow */
  29770. get transparencyShadow(): boolean;
  29771. set transparencyShadow(value: boolean);
  29772. /**
  29773. * Sets the ability to have transparent shadow (boolean).
  29774. * @param transparent True if transparent else False
  29775. * @returns the shadow generator allowing fluent coding
  29776. */
  29777. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29778. /**
  29779. * Enables or disables shadows with varying strength based on the transparency
  29780. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29781. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29782. * mesh.visibility * alphaTexture.a
  29783. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29784. */
  29785. enableSoftTransparentShadow: boolean;
  29786. protected _shadowMap: Nullable<RenderTargetTexture>;
  29787. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29788. /**
  29789. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29790. * @returns The render target texture if present otherwise, null
  29791. */
  29792. getShadowMap(): Nullable<RenderTargetTexture>;
  29793. /**
  29794. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29795. * @returns The render target texture if the shadow map is present otherwise, null
  29796. */
  29797. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29798. /**
  29799. * Gets the class name of that object
  29800. * @returns "ShadowGenerator"
  29801. */
  29802. getClassName(): string;
  29803. /**
  29804. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29805. * @param mesh Mesh to add
  29806. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29807. * @returns the Shadow Generator itself
  29808. */
  29809. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29810. /**
  29811. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29812. * @param mesh Mesh to remove
  29813. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29814. * @returns the Shadow Generator itself
  29815. */
  29816. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29817. /**
  29818. * Controls the extent to which the shadows fade out at the edge of the frustum
  29819. */
  29820. frustumEdgeFalloff: number;
  29821. protected _light: IShadowLight;
  29822. /**
  29823. * Returns the associated light object.
  29824. * @returns the light generating the shadow
  29825. */
  29826. getLight(): IShadowLight;
  29827. /**
  29828. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29829. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29830. * It might on the other hand introduce peter panning.
  29831. */
  29832. forceBackFacesOnly: boolean;
  29833. protected _scene: Scene;
  29834. protected _lightDirection: Vector3;
  29835. protected _viewMatrix: Matrix;
  29836. protected _projectionMatrix: Matrix;
  29837. protected _transformMatrix: Matrix;
  29838. protected _cachedPosition: Vector3;
  29839. protected _cachedDirection: Vector3;
  29840. protected _cachedDefines: string;
  29841. protected _currentRenderID: number;
  29842. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29843. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29844. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29845. protected _blurPostProcesses: PostProcess[];
  29846. protected _mapSize: number;
  29847. protected _currentFaceIndex: number;
  29848. protected _currentFaceIndexCache: number;
  29849. protected _textureType: number;
  29850. protected _defaultTextureMatrix: Matrix;
  29851. protected _storedUniqueId: Nullable<number>;
  29852. protected _nameForCustomEffect: string;
  29853. /** @hidden */
  29854. static _SceneComponentInitialization: (scene: Scene) => void;
  29855. /**
  29856. * Gets or sets the size of the texture what stores the shadows
  29857. */
  29858. get mapSize(): number;
  29859. set mapSize(size: number);
  29860. /**
  29861. * Creates a ShadowGenerator object.
  29862. * A ShadowGenerator is the required tool to use the shadows.
  29863. * Each light casting shadows needs to use its own ShadowGenerator.
  29864. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29865. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29866. * @param light The light object generating the shadows.
  29867. * @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.
  29868. */
  29869. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29870. protected _initializeGenerator(): void;
  29871. protected _createTargetRenderTexture(): void;
  29872. protected _initializeShadowMap(): void;
  29873. protected _initializeBlurRTTAndPostProcesses(): void;
  29874. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29875. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29876. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29877. protected _applyFilterValues(): void;
  29878. /**
  29879. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29880. * @param onCompiled Callback triggered at the and of the effects compilation
  29881. * @param options Sets of optional options forcing the compilation with different modes
  29882. */
  29883. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29884. useInstances: boolean;
  29885. }>): void;
  29886. /**
  29887. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29888. * @param options Sets of optional options forcing the compilation with different modes
  29889. * @returns A promise that resolves when the compilation completes
  29890. */
  29891. forceCompilationAsync(options?: Partial<{
  29892. useInstances: boolean;
  29893. }>): Promise<void>;
  29894. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29895. private _prepareShadowDefines;
  29896. /**
  29897. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29898. * @param subMesh The submesh we want to render in the shadow map
  29899. * @param useInstances Defines wether will draw in the map using instances
  29900. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29901. * @returns true if ready otherwise, false
  29902. */
  29903. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29904. /**
  29905. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29906. * @param defines Defines of the material we want to update
  29907. * @param lightIndex Index of the light in the enabled light list of the material
  29908. */
  29909. prepareDefines(defines: any, lightIndex: number): void;
  29910. /**
  29911. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29912. * defined in the generator but impacting the effect).
  29913. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29914. * @param effect The effect we are binfing the information for
  29915. */
  29916. bindShadowLight(lightIndex: string, effect: Effect): void;
  29917. /**
  29918. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29919. * (eq to shadow prjection matrix * light transform matrix)
  29920. * @returns The transform matrix used to create the shadow map
  29921. */
  29922. getTransformMatrix(): Matrix;
  29923. /**
  29924. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29925. * Cube and 2D textures for instance.
  29926. */
  29927. recreateShadowMap(): void;
  29928. protected _disposeBlurPostProcesses(): void;
  29929. protected _disposeRTTandPostProcesses(): void;
  29930. /**
  29931. * Disposes the ShadowGenerator.
  29932. * Returns nothing.
  29933. */
  29934. dispose(): void;
  29935. /**
  29936. * Serializes the shadow generator setup to a json object.
  29937. * @returns The serialized JSON object
  29938. */
  29939. serialize(): any;
  29940. /**
  29941. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29942. * @param parsedShadowGenerator The JSON object to parse
  29943. * @param scene The scene to create the shadow map for
  29944. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29945. * @returns The parsed shadow generator
  29946. */
  29947. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29948. }
  29949. }
  29950. declare module BABYLON {
  29951. /**
  29952. * Options to be used when creating a shadow depth material
  29953. */
  29954. export interface IIOptionShadowDepthMaterial {
  29955. /** Variables in the vertex shader code that need to have their names remapped.
  29956. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29957. * "var_name" should be either: worldPos or vNormalW
  29958. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29959. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29960. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29961. */
  29962. remappedVariables?: string[];
  29963. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29964. standalone?: boolean;
  29965. }
  29966. /**
  29967. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29968. */
  29969. export class ShadowDepthWrapper {
  29970. private _scene;
  29971. private _options?;
  29972. private _baseMaterial;
  29973. private _onEffectCreatedObserver;
  29974. private _subMeshToEffect;
  29975. private _subMeshToDepthEffect;
  29976. private _meshes;
  29977. /** @hidden */
  29978. _matriceNames: any;
  29979. /** Gets the standalone status of the wrapper */
  29980. get standalone(): boolean;
  29981. /** Gets the base material the wrapper is built upon */
  29982. get baseMaterial(): Material;
  29983. /**
  29984. * Instantiate a new shadow depth wrapper.
  29985. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29986. * generate the shadow depth map. For more information, please refer to the documentation:
  29987. * https://doc.babylonjs.com/babylon101/shadows
  29988. * @param baseMaterial Material to wrap
  29989. * @param scene Define the scene the material belongs to
  29990. * @param options Options used to create the wrapper
  29991. */
  29992. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29993. /**
  29994. * Gets the effect to use to generate the depth map
  29995. * @param subMesh subMesh to get the effect for
  29996. * @param shadowGenerator shadow generator to get the effect for
  29997. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29998. */
  29999. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30000. /**
  30001. * Specifies that the submesh is ready to be used for depth rendering
  30002. * @param subMesh submesh to check
  30003. * @param defines the list of defines to take into account when checking the effect
  30004. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30005. * @param useInstances specifies that instances should be used
  30006. * @returns a boolean indicating that the submesh is ready or not
  30007. */
  30008. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30009. /**
  30010. * Disposes the resources
  30011. */
  30012. dispose(): void;
  30013. private _makeEffect;
  30014. }
  30015. }
  30016. declare module BABYLON {
  30017. /**
  30018. * Options for compiling materials.
  30019. */
  30020. export interface IMaterialCompilationOptions {
  30021. /**
  30022. * Defines whether clip planes are enabled.
  30023. */
  30024. clipPlane: boolean;
  30025. /**
  30026. * Defines whether instances are enabled.
  30027. */
  30028. useInstances: boolean;
  30029. }
  30030. /**
  30031. * Options passed when calling customShaderNameResolve
  30032. */
  30033. export interface ICustomShaderNameResolveOptions {
  30034. /**
  30035. * 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
  30036. */
  30037. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30038. }
  30039. /**
  30040. * Base class for the main features of a material in Babylon.js
  30041. */
  30042. export class Material implements IAnimatable {
  30043. /**
  30044. * Returns the triangle fill mode
  30045. */
  30046. static readonly TriangleFillMode: number;
  30047. /**
  30048. * Returns the wireframe mode
  30049. */
  30050. static readonly WireFrameFillMode: number;
  30051. /**
  30052. * Returns the point fill mode
  30053. */
  30054. static readonly PointFillMode: number;
  30055. /**
  30056. * Returns the point list draw mode
  30057. */
  30058. static readonly PointListDrawMode: number;
  30059. /**
  30060. * Returns the line list draw mode
  30061. */
  30062. static readonly LineListDrawMode: number;
  30063. /**
  30064. * Returns the line loop draw mode
  30065. */
  30066. static readonly LineLoopDrawMode: number;
  30067. /**
  30068. * Returns the line strip draw mode
  30069. */
  30070. static readonly LineStripDrawMode: number;
  30071. /**
  30072. * Returns the triangle strip draw mode
  30073. */
  30074. static readonly TriangleStripDrawMode: number;
  30075. /**
  30076. * Returns the triangle fan draw mode
  30077. */
  30078. static readonly TriangleFanDrawMode: number;
  30079. /**
  30080. * Stores the clock-wise side orientation
  30081. */
  30082. static readonly ClockWiseSideOrientation: number;
  30083. /**
  30084. * Stores the counter clock-wise side orientation
  30085. */
  30086. static readonly CounterClockWiseSideOrientation: number;
  30087. /**
  30088. * The dirty texture flag value
  30089. */
  30090. static readonly TextureDirtyFlag: number;
  30091. /**
  30092. * The dirty light flag value
  30093. */
  30094. static readonly LightDirtyFlag: number;
  30095. /**
  30096. * The dirty fresnel flag value
  30097. */
  30098. static readonly FresnelDirtyFlag: number;
  30099. /**
  30100. * The dirty attribute flag value
  30101. */
  30102. static readonly AttributesDirtyFlag: number;
  30103. /**
  30104. * The dirty misc flag value
  30105. */
  30106. static readonly MiscDirtyFlag: number;
  30107. /**
  30108. * The dirty prepass flag value
  30109. */
  30110. static readonly PrePassDirtyFlag: number;
  30111. /**
  30112. * The all dirty flag value
  30113. */
  30114. static readonly AllDirtyFlag: number;
  30115. /**
  30116. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30117. */
  30118. static readonly MATERIAL_OPAQUE: number;
  30119. /**
  30120. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30121. */
  30122. static readonly MATERIAL_ALPHATEST: number;
  30123. /**
  30124. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30125. */
  30126. static readonly MATERIAL_ALPHABLEND: number;
  30127. /**
  30128. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30129. * They are also discarded below the alpha cutoff threshold to improve performances.
  30130. */
  30131. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30132. /**
  30133. * The Whiteout method is used to blend normals.
  30134. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30135. */
  30136. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30137. /**
  30138. * The Reoriented Normal Mapping method is used to blend normals.
  30139. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30140. */
  30141. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30142. /**
  30143. * Custom callback helping to override the default shader used in the material.
  30144. */
  30145. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30146. /**
  30147. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30148. */
  30149. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30150. /**
  30151. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30152. * This means that the material can keep using a previous shader while a new one is being compiled.
  30153. * This is mostly used when shader parallel compilation is supported (true by default)
  30154. */
  30155. allowShaderHotSwapping: boolean;
  30156. /**
  30157. * The ID of the material
  30158. */
  30159. id: string;
  30160. /**
  30161. * Gets or sets the unique id of the material
  30162. */
  30163. uniqueId: number;
  30164. /**
  30165. * The name of the material
  30166. */
  30167. name: string;
  30168. /**
  30169. * Gets or sets user defined metadata
  30170. */
  30171. metadata: any;
  30172. /**
  30173. * For internal use only. Please do not use.
  30174. */
  30175. reservedDataStore: any;
  30176. /**
  30177. * Specifies if the ready state should be checked on each call
  30178. */
  30179. checkReadyOnEveryCall: boolean;
  30180. /**
  30181. * Specifies if the ready state should be checked once
  30182. */
  30183. checkReadyOnlyOnce: boolean;
  30184. /**
  30185. * The state of the material
  30186. */
  30187. state: string;
  30188. /**
  30189. * If the material can be rendered to several textures with MRT extension
  30190. */
  30191. get canRenderToMRT(): boolean;
  30192. /**
  30193. * The alpha value of the material
  30194. */
  30195. protected _alpha: number;
  30196. /**
  30197. * List of inspectable custom properties (used by the Inspector)
  30198. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30199. */
  30200. inspectableCustomProperties: IInspectable[];
  30201. /**
  30202. * Sets the alpha value of the material
  30203. */
  30204. set alpha(value: number);
  30205. /**
  30206. * Gets the alpha value of the material
  30207. */
  30208. get alpha(): number;
  30209. /**
  30210. * Specifies if back face culling is enabled
  30211. */
  30212. protected _backFaceCulling: boolean;
  30213. /**
  30214. * Sets the back-face culling state
  30215. */
  30216. set backFaceCulling(value: boolean);
  30217. /**
  30218. * Gets the back-face culling state
  30219. */
  30220. get backFaceCulling(): boolean;
  30221. /**
  30222. * Stores the value for side orientation
  30223. */
  30224. sideOrientation: number;
  30225. /**
  30226. * Callback triggered when the material is compiled
  30227. */
  30228. onCompiled: Nullable<(effect: Effect) => void>;
  30229. /**
  30230. * Callback triggered when an error occurs
  30231. */
  30232. onError: Nullable<(effect: Effect, errors: string) => void>;
  30233. /**
  30234. * Callback triggered to get the render target textures
  30235. */
  30236. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30237. /**
  30238. * Gets a boolean indicating that current material needs to register RTT
  30239. */
  30240. get hasRenderTargetTextures(): boolean;
  30241. /**
  30242. * Specifies if the material should be serialized
  30243. */
  30244. doNotSerialize: boolean;
  30245. /**
  30246. * @hidden
  30247. */
  30248. _storeEffectOnSubMeshes: boolean;
  30249. /**
  30250. * Stores the animations for the material
  30251. */
  30252. animations: Nullable<Array<Animation>>;
  30253. /**
  30254. * An event triggered when the material is disposed
  30255. */
  30256. onDisposeObservable: Observable<Material>;
  30257. /**
  30258. * An observer which watches for dispose events
  30259. */
  30260. private _onDisposeObserver;
  30261. private _onUnBindObservable;
  30262. /**
  30263. * Called during a dispose event
  30264. */
  30265. set onDispose(callback: () => void);
  30266. private _onBindObservable;
  30267. /**
  30268. * An event triggered when the material is bound
  30269. */
  30270. get onBindObservable(): Observable<AbstractMesh>;
  30271. /**
  30272. * An observer which watches for bind events
  30273. */
  30274. private _onBindObserver;
  30275. /**
  30276. * Called during a bind event
  30277. */
  30278. set onBind(callback: (Mesh: AbstractMesh) => void);
  30279. /**
  30280. * An event triggered when the material is unbound
  30281. */
  30282. get onUnBindObservable(): Observable<Material>;
  30283. protected _onEffectCreatedObservable: Nullable<Observable<{
  30284. effect: Effect;
  30285. subMesh: Nullable<SubMesh>;
  30286. }>>;
  30287. /**
  30288. * An event triggered when the effect is (re)created
  30289. */
  30290. get onEffectCreatedObservable(): Observable<{
  30291. effect: Effect;
  30292. subMesh: Nullable<SubMesh>;
  30293. }>;
  30294. /**
  30295. * Stores the value of the alpha mode
  30296. */
  30297. private _alphaMode;
  30298. /**
  30299. * Sets the value of the alpha mode.
  30300. *
  30301. * | Value | Type | Description |
  30302. * | --- | --- | --- |
  30303. * | 0 | ALPHA_DISABLE | |
  30304. * | 1 | ALPHA_ADD | |
  30305. * | 2 | ALPHA_COMBINE | |
  30306. * | 3 | ALPHA_SUBTRACT | |
  30307. * | 4 | ALPHA_MULTIPLY | |
  30308. * | 5 | ALPHA_MAXIMIZED | |
  30309. * | 6 | ALPHA_ONEONE | |
  30310. * | 7 | ALPHA_PREMULTIPLIED | |
  30311. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30312. * | 9 | ALPHA_INTERPOLATE | |
  30313. * | 10 | ALPHA_SCREENMODE | |
  30314. *
  30315. */
  30316. set alphaMode(value: number);
  30317. /**
  30318. * Gets the value of the alpha mode
  30319. */
  30320. get alphaMode(): number;
  30321. /**
  30322. * Stores the state of the need depth pre-pass value
  30323. */
  30324. private _needDepthPrePass;
  30325. /**
  30326. * Sets the need depth pre-pass value
  30327. */
  30328. set needDepthPrePass(value: boolean);
  30329. /**
  30330. * Gets the depth pre-pass value
  30331. */
  30332. get needDepthPrePass(): boolean;
  30333. /**
  30334. * Specifies if depth writing should be disabled
  30335. */
  30336. disableDepthWrite: boolean;
  30337. /**
  30338. * Specifies if color writing should be disabled
  30339. */
  30340. disableColorWrite: boolean;
  30341. /**
  30342. * Specifies if depth writing should be forced
  30343. */
  30344. forceDepthWrite: boolean;
  30345. /**
  30346. * Specifies the depth function that should be used. 0 means the default engine function
  30347. */
  30348. depthFunction: number;
  30349. /**
  30350. * Specifies if there should be a separate pass for culling
  30351. */
  30352. separateCullingPass: boolean;
  30353. /**
  30354. * Stores the state specifing if fog should be enabled
  30355. */
  30356. private _fogEnabled;
  30357. /**
  30358. * Sets the state for enabling fog
  30359. */
  30360. set fogEnabled(value: boolean);
  30361. /**
  30362. * Gets the value of the fog enabled state
  30363. */
  30364. get fogEnabled(): boolean;
  30365. /**
  30366. * Stores the size of points
  30367. */
  30368. pointSize: number;
  30369. /**
  30370. * Stores the z offset value
  30371. */
  30372. zOffset: number;
  30373. get wireframe(): boolean;
  30374. /**
  30375. * Sets the state of wireframe mode
  30376. */
  30377. set wireframe(value: boolean);
  30378. /**
  30379. * Gets the value specifying if point clouds are enabled
  30380. */
  30381. get pointsCloud(): boolean;
  30382. /**
  30383. * Sets the state of point cloud mode
  30384. */
  30385. set pointsCloud(value: boolean);
  30386. /**
  30387. * Gets the material fill mode
  30388. */
  30389. get fillMode(): number;
  30390. /**
  30391. * Sets the material fill mode
  30392. */
  30393. set fillMode(value: number);
  30394. /**
  30395. * @hidden
  30396. * Stores the effects for the material
  30397. */
  30398. _effect: Nullable<Effect>;
  30399. /**
  30400. * Specifies if uniform buffers should be used
  30401. */
  30402. private _useUBO;
  30403. /**
  30404. * Stores a reference to the scene
  30405. */
  30406. private _scene;
  30407. private _needToBindSceneUbo;
  30408. /**
  30409. * Stores the fill mode state
  30410. */
  30411. private _fillMode;
  30412. /**
  30413. * Specifies if the depth write state should be cached
  30414. */
  30415. private _cachedDepthWriteState;
  30416. /**
  30417. * Specifies if the color write state should be cached
  30418. */
  30419. private _cachedColorWriteState;
  30420. /**
  30421. * Specifies if the depth function state should be cached
  30422. */
  30423. private _cachedDepthFunctionState;
  30424. /**
  30425. * Stores the uniform buffer
  30426. */
  30427. protected _uniformBuffer: UniformBuffer;
  30428. /** @hidden */
  30429. _indexInSceneMaterialArray: number;
  30430. /** @hidden */
  30431. meshMap: Nullable<{
  30432. [id: string]: AbstractMesh | undefined;
  30433. }>;
  30434. /**
  30435. * Creates a material instance
  30436. * @param name defines the name of the material
  30437. * @param scene defines the scene to reference
  30438. * @param doNotAdd specifies if the material should be added to the scene
  30439. */
  30440. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30441. /**
  30442. * Returns a string representation of the current material
  30443. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30444. * @returns a string with material information
  30445. */
  30446. toString(fullDetails?: boolean): string;
  30447. /**
  30448. * Gets the class name of the material
  30449. * @returns a string with the class name of the material
  30450. */
  30451. getClassName(): string;
  30452. /**
  30453. * Specifies if updates for the material been locked
  30454. */
  30455. get isFrozen(): boolean;
  30456. /**
  30457. * Locks updates for the material
  30458. */
  30459. freeze(): void;
  30460. /**
  30461. * Unlocks updates for the material
  30462. */
  30463. unfreeze(): void;
  30464. /**
  30465. * Specifies if the material is ready to be used
  30466. * @param mesh defines the mesh to check
  30467. * @param useInstances specifies if instances should be used
  30468. * @returns a boolean indicating if the material is ready to be used
  30469. */
  30470. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30471. /**
  30472. * Specifies that the submesh is ready to be used
  30473. * @param mesh defines the mesh to check
  30474. * @param subMesh defines which submesh to check
  30475. * @param useInstances specifies that instances should be used
  30476. * @returns a boolean indicating that the submesh is ready or not
  30477. */
  30478. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30479. /**
  30480. * Returns the material effect
  30481. * @returns the effect associated with the material
  30482. */
  30483. getEffect(): Nullable<Effect>;
  30484. /**
  30485. * Returns the current scene
  30486. * @returns a Scene
  30487. */
  30488. getScene(): Scene;
  30489. /**
  30490. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30491. */
  30492. protected _forceAlphaTest: boolean;
  30493. /**
  30494. * The transparency mode of the material.
  30495. */
  30496. protected _transparencyMode: Nullable<number>;
  30497. /**
  30498. * Gets the current transparency mode.
  30499. */
  30500. get transparencyMode(): Nullable<number>;
  30501. /**
  30502. * Sets the transparency mode of the material.
  30503. *
  30504. * | Value | Type | Description |
  30505. * | ----- | ----------------------------------- | ----------- |
  30506. * | 0 | OPAQUE | |
  30507. * | 1 | ALPHATEST | |
  30508. * | 2 | ALPHABLEND | |
  30509. * | 3 | ALPHATESTANDBLEND | |
  30510. *
  30511. */
  30512. set transparencyMode(value: Nullable<number>);
  30513. /**
  30514. * Returns true if alpha blending should be disabled.
  30515. */
  30516. protected get _disableAlphaBlending(): boolean;
  30517. /**
  30518. * Specifies whether or not this material should be rendered in alpha blend mode.
  30519. * @returns a boolean specifying if alpha blending is needed
  30520. */
  30521. needAlphaBlending(): boolean;
  30522. /**
  30523. * Specifies if the mesh will require alpha blending
  30524. * @param mesh defines the mesh to check
  30525. * @returns a boolean specifying if alpha blending is needed for the mesh
  30526. */
  30527. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30528. /**
  30529. * Specifies whether or not this material should be rendered in alpha test mode.
  30530. * @returns a boolean specifying if an alpha test is needed.
  30531. */
  30532. needAlphaTesting(): boolean;
  30533. /**
  30534. * Specifies if material alpha testing should be turned on for the mesh
  30535. * @param mesh defines the mesh to check
  30536. */
  30537. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30538. /**
  30539. * Gets the texture used for the alpha test
  30540. * @returns the texture to use for alpha testing
  30541. */
  30542. getAlphaTestTexture(): Nullable<BaseTexture>;
  30543. /**
  30544. * Marks the material to indicate that it needs to be re-calculated
  30545. */
  30546. markDirty(): void;
  30547. /** @hidden */
  30548. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30549. /**
  30550. * Binds the material to the mesh
  30551. * @param world defines the world transformation matrix
  30552. * @param mesh defines the mesh to bind the material to
  30553. */
  30554. bind(world: Matrix, mesh?: Mesh): void;
  30555. /**
  30556. * Binds the submesh to the material
  30557. * @param world defines the world transformation matrix
  30558. * @param mesh defines the mesh containing the submesh
  30559. * @param subMesh defines the submesh to bind the material to
  30560. */
  30561. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30562. /**
  30563. * Binds the world matrix to the material
  30564. * @param world defines the world transformation matrix
  30565. */
  30566. bindOnlyWorldMatrix(world: Matrix): void;
  30567. /**
  30568. * Update the scene ubo before it can be used in rendering processing
  30569. * @param scene the scene to retrieve the ubo from
  30570. * @returns the scene UniformBuffer
  30571. */
  30572. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30573. /**
  30574. * Binds the scene's uniform buffer to the effect.
  30575. * @param effect defines the effect to bind to the scene uniform buffer
  30576. * @param sceneUbo defines the uniform buffer storing scene data
  30577. */
  30578. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30579. /**
  30580. * Binds the view matrix to the effect
  30581. * @param effect defines the effect to bind the view matrix to
  30582. */
  30583. bindView(effect: Effect): void;
  30584. /**
  30585. * Binds the view projection and projection matrices to the effect
  30586. * @param effect defines the effect to bind the view projection and projection matrices to
  30587. */
  30588. bindViewProjection(effect: Effect): void;
  30589. /**
  30590. * Binds the view matrix to the effect
  30591. * @param effect defines the effect to bind the view matrix to
  30592. * @param variableName name of the shader variable that will hold the eye position
  30593. */
  30594. bindEyePosition(effect: Effect, variableName?: string): void;
  30595. /**
  30596. * Processes to execute after binding the material to a mesh
  30597. * @param mesh defines the rendered mesh
  30598. */
  30599. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30600. /**
  30601. * Unbinds the material from the mesh
  30602. */
  30603. unbind(): void;
  30604. /**
  30605. * Gets the active textures from the material
  30606. * @returns an array of textures
  30607. */
  30608. getActiveTextures(): BaseTexture[];
  30609. /**
  30610. * Specifies if the material uses a texture
  30611. * @param texture defines the texture to check against the material
  30612. * @returns a boolean specifying if the material uses the texture
  30613. */
  30614. hasTexture(texture: BaseTexture): boolean;
  30615. /**
  30616. * Makes a duplicate of the material, and gives it a new name
  30617. * @param name defines the new name for the duplicated material
  30618. * @returns the cloned material
  30619. */
  30620. clone(name: string): Nullable<Material>;
  30621. /**
  30622. * Gets the meshes bound to the material
  30623. * @returns an array of meshes bound to the material
  30624. */
  30625. getBindedMeshes(): AbstractMesh[];
  30626. /**
  30627. * Force shader compilation
  30628. * @param mesh defines the mesh associated with this material
  30629. * @param onCompiled defines a function to execute once the material is compiled
  30630. * @param options defines the options to configure the compilation
  30631. * @param onError defines a function to execute if the material fails compiling
  30632. */
  30633. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30634. /**
  30635. * Force shader compilation
  30636. * @param mesh defines the mesh that will use this material
  30637. * @param options defines additional options for compiling the shaders
  30638. * @returns a promise that resolves when the compilation completes
  30639. */
  30640. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30641. private static readonly _AllDirtyCallBack;
  30642. private static readonly _ImageProcessingDirtyCallBack;
  30643. private static readonly _TextureDirtyCallBack;
  30644. private static readonly _FresnelDirtyCallBack;
  30645. private static readonly _MiscDirtyCallBack;
  30646. private static readonly _PrePassDirtyCallBack;
  30647. private static readonly _LightsDirtyCallBack;
  30648. private static readonly _AttributeDirtyCallBack;
  30649. private static _FresnelAndMiscDirtyCallBack;
  30650. private static _TextureAndMiscDirtyCallBack;
  30651. private static readonly _DirtyCallbackArray;
  30652. private static readonly _RunDirtyCallBacks;
  30653. /**
  30654. * Marks a define in the material to indicate that it needs to be re-computed
  30655. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30656. */
  30657. markAsDirty(flag: number): void;
  30658. /**
  30659. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30660. * @param func defines a function which checks material defines against the submeshes
  30661. */
  30662. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30663. /**
  30664. * Indicates that the scene should check if the rendering now needs a prepass
  30665. */
  30666. protected _markScenePrePassDirty(): void;
  30667. /**
  30668. * Indicates that we need to re-calculated for all submeshes
  30669. */
  30670. protected _markAllSubMeshesAsAllDirty(): void;
  30671. /**
  30672. * Indicates that image processing needs to be re-calculated for all submeshes
  30673. */
  30674. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30675. /**
  30676. * Indicates that textures need to be re-calculated for all submeshes
  30677. */
  30678. protected _markAllSubMeshesAsTexturesDirty(): void;
  30679. /**
  30680. * Indicates that fresnel needs to be re-calculated for all submeshes
  30681. */
  30682. protected _markAllSubMeshesAsFresnelDirty(): void;
  30683. /**
  30684. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30685. */
  30686. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30687. /**
  30688. * Indicates that lights need to be re-calculated for all submeshes
  30689. */
  30690. protected _markAllSubMeshesAsLightsDirty(): void;
  30691. /**
  30692. * Indicates that attributes need to be re-calculated for all submeshes
  30693. */
  30694. protected _markAllSubMeshesAsAttributesDirty(): void;
  30695. /**
  30696. * Indicates that misc needs to be re-calculated for all submeshes
  30697. */
  30698. protected _markAllSubMeshesAsMiscDirty(): void;
  30699. /**
  30700. * Indicates that prepass needs to be re-calculated for all submeshes
  30701. */
  30702. protected _markAllSubMeshesAsPrePassDirty(): void;
  30703. /**
  30704. * Indicates that textures and misc need to be re-calculated for all submeshes
  30705. */
  30706. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30707. /**
  30708. * Sets the required values to the prepass renderer.
  30709. * @param prePassRenderer defines the prepass renderer to setup.
  30710. * @returns true if the pre pass is needed.
  30711. */
  30712. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30713. /**
  30714. * Disposes the material
  30715. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30716. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30717. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30718. */
  30719. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30720. /** @hidden */
  30721. private releaseVertexArrayObject;
  30722. /**
  30723. * Serializes this material
  30724. * @returns the serialized material object
  30725. */
  30726. serialize(): any;
  30727. /**
  30728. * Creates a material from parsed material data
  30729. * @param parsedMaterial defines parsed material data
  30730. * @param scene defines the hosting scene
  30731. * @param rootUrl defines the root URL to use to load textures
  30732. * @returns a new material
  30733. */
  30734. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30735. }
  30736. }
  30737. declare module BABYLON {
  30738. /**
  30739. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30740. * separate meshes. This can be use to improve performances.
  30741. * @see https://doc.babylonjs.com/how_to/multi_materials
  30742. */
  30743. export class MultiMaterial extends Material {
  30744. private _subMaterials;
  30745. /**
  30746. * Gets or Sets the list of Materials used within the multi material.
  30747. * They need to be ordered according to the submeshes order in the associated mesh
  30748. */
  30749. get subMaterials(): Nullable<Material>[];
  30750. set subMaterials(value: Nullable<Material>[]);
  30751. /**
  30752. * Function used to align with Node.getChildren()
  30753. * @returns the list of Materials used within the multi material
  30754. */
  30755. getChildren(): Nullable<Material>[];
  30756. /**
  30757. * Instantiates a new Multi Material
  30758. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30759. * separate meshes. This can be use to improve performances.
  30760. * @see https://doc.babylonjs.com/how_to/multi_materials
  30761. * @param name Define the name in the scene
  30762. * @param scene Define the scene the material belongs to
  30763. */
  30764. constructor(name: string, scene: Scene);
  30765. private _hookArray;
  30766. /**
  30767. * Get one of the submaterial by its index in the submaterials array
  30768. * @param index The index to look the sub material at
  30769. * @returns The Material if the index has been defined
  30770. */
  30771. getSubMaterial(index: number): Nullable<Material>;
  30772. /**
  30773. * Get the list of active textures for the whole sub materials list.
  30774. * @returns All the textures that will be used during the rendering
  30775. */
  30776. getActiveTextures(): BaseTexture[];
  30777. /**
  30778. * Specifies if any sub-materials of this multi-material use a given texture.
  30779. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30780. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30781. */
  30782. hasTexture(texture: BaseTexture): boolean;
  30783. /**
  30784. * Gets the current class name of the material e.g. "MultiMaterial"
  30785. * Mainly use in serialization.
  30786. * @returns the class name
  30787. */
  30788. getClassName(): string;
  30789. /**
  30790. * Checks if the material is ready to render the requested sub mesh
  30791. * @param mesh Define the mesh the submesh belongs to
  30792. * @param subMesh Define the sub mesh to look readyness for
  30793. * @param useInstances Define whether or not the material is used with instances
  30794. * @returns true if ready, otherwise false
  30795. */
  30796. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30797. /**
  30798. * Clones the current material and its related sub materials
  30799. * @param name Define the name of the newly cloned material
  30800. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30801. * @returns the cloned material
  30802. */
  30803. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30804. /**
  30805. * Serializes the materials into a JSON representation.
  30806. * @returns the JSON representation
  30807. */
  30808. serialize(): any;
  30809. /**
  30810. * Dispose the material and release its associated resources
  30811. * @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)
  30812. * @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)
  30813. * @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)
  30814. */
  30815. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30816. /**
  30817. * Creates a MultiMaterial from parsed MultiMaterial data.
  30818. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30819. * @param scene defines the hosting scene
  30820. * @returns a new MultiMaterial
  30821. */
  30822. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30823. }
  30824. }
  30825. declare module BABYLON {
  30826. /** @hidden */
  30827. export interface ICustomEffect {
  30828. effect: Effect;
  30829. defines: string;
  30830. }
  30831. /**
  30832. * Defines a subdivision inside a mesh
  30833. */
  30834. export class SubMesh implements ICullable {
  30835. /** the material index to use */
  30836. materialIndex: number;
  30837. /** vertex index start */
  30838. verticesStart: number;
  30839. /** vertices count */
  30840. verticesCount: number;
  30841. /** index start */
  30842. indexStart: number;
  30843. /** indices count */
  30844. indexCount: number;
  30845. /** @hidden */
  30846. _materialDefines: Nullable<MaterialDefines>;
  30847. /** @hidden */
  30848. _materialEffect: Nullable<Effect>;
  30849. /** @hidden */
  30850. _effectOverride: Nullable<Effect>;
  30851. private _customEffects;
  30852. /**
  30853. * Gets material defines used by the effect associated to the sub mesh
  30854. */
  30855. get materialDefines(): Nullable<MaterialDefines>;
  30856. /**
  30857. * Sets material defines used by the effect associated to the sub mesh
  30858. */
  30859. set materialDefines(defines: Nullable<MaterialDefines>);
  30860. /** @hidden */
  30861. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30862. /** @hidden */
  30863. _removeCustomEffect(name: string): void;
  30864. /**
  30865. * Gets associated effect
  30866. */
  30867. get effect(): Nullable<Effect>;
  30868. /**
  30869. * Sets associated effect (effect used to render this submesh)
  30870. * @param effect defines the effect to associate with
  30871. * @param defines defines the set of defines used to compile this effect
  30872. */
  30873. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30874. /** @hidden */
  30875. _linesIndexCount: number;
  30876. private _mesh;
  30877. private _renderingMesh;
  30878. private _boundingInfo;
  30879. private _linesIndexBuffer;
  30880. /** @hidden */
  30881. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30882. /** @hidden */
  30883. _trianglePlanes: Plane[];
  30884. /** @hidden */
  30885. _lastColliderTransformMatrix: Nullable<Matrix>;
  30886. /** @hidden */
  30887. _renderId: number;
  30888. /** @hidden */
  30889. _alphaIndex: number;
  30890. /** @hidden */
  30891. _distanceToCamera: number;
  30892. /** @hidden */
  30893. _id: number;
  30894. private _currentMaterial;
  30895. /**
  30896. * Add a new submesh to a mesh
  30897. * @param materialIndex defines the material index to use
  30898. * @param verticesStart defines vertex index start
  30899. * @param verticesCount defines vertices count
  30900. * @param indexStart defines index start
  30901. * @param indexCount defines indices count
  30902. * @param mesh defines the parent mesh
  30903. * @param renderingMesh defines an optional rendering mesh
  30904. * @param createBoundingBox defines if bounding box should be created for this submesh
  30905. * @returns the new submesh
  30906. */
  30907. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30908. /**
  30909. * Creates a new submesh
  30910. * @param materialIndex defines the material index to use
  30911. * @param verticesStart defines vertex index start
  30912. * @param verticesCount defines vertices count
  30913. * @param indexStart defines index start
  30914. * @param indexCount defines indices count
  30915. * @param mesh defines the parent mesh
  30916. * @param renderingMesh defines an optional rendering mesh
  30917. * @param createBoundingBox defines if bounding box should be created for this submesh
  30918. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30919. */
  30920. constructor(
  30921. /** the material index to use */
  30922. materialIndex: number,
  30923. /** vertex index start */
  30924. verticesStart: number,
  30925. /** vertices count */
  30926. verticesCount: number,
  30927. /** index start */
  30928. indexStart: number,
  30929. /** indices count */
  30930. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30931. /**
  30932. * Returns true if this submesh covers the entire parent mesh
  30933. * @ignorenaming
  30934. */
  30935. get IsGlobal(): boolean;
  30936. /**
  30937. * Returns the submesh BoudingInfo object
  30938. * @returns current bounding info (or mesh's one if the submesh is global)
  30939. */
  30940. getBoundingInfo(): BoundingInfo;
  30941. /**
  30942. * Sets the submesh BoundingInfo
  30943. * @param boundingInfo defines the new bounding info to use
  30944. * @returns the SubMesh
  30945. */
  30946. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30947. /**
  30948. * Returns the mesh of the current submesh
  30949. * @return the parent mesh
  30950. */
  30951. getMesh(): AbstractMesh;
  30952. /**
  30953. * Returns the rendering mesh of the submesh
  30954. * @returns the rendering mesh (could be different from parent mesh)
  30955. */
  30956. getRenderingMesh(): Mesh;
  30957. /**
  30958. * Returns the replacement mesh of the submesh
  30959. * @returns the replacement mesh (could be different from parent mesh)
  30960. */
  30961. getReplacementMesh(): Nullable<AbstractMesh>;
  30962. /**
  30963. * Returns the effective mesh of the submesh
  30964. * @returns the effective mesh (could be different from parent mesh)
  30965. */
  30966. getEffectiveMesh(): AbstractMesh;
  30967. /**
  30968. * Returns the submesh material
  30969. * @returns null or the current material
  30970. */
  30971. getMaterial(): Nullable<Material>;
  30972. private _IsMultiMaterial;
  30973. /**
  30974. * Sets a new updated BoundingInfo object to the submesh
  30975. * @param data defines an optional position array to use to determine the bounding info
  30976. * @returns the SubMesh
  30977. */
  30978. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30979. /** @hidden */
  30980. _checkCollision(collider: Collider): boolean;
  30981. /**
  30982. * Updates the submesh BoundingInfo
  30983. * @param world defines the world matrix to use to update the bounding info
  30984. * @returns the submesh
  30985. */
  30986. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30987. /**
  30988. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30989. * @param frustumPlanes defines the frustum planes
  30990. * @returns true if the submesh is intersecting with the frustum
  30991. */
  30992. isInFrustum(frustumPlanes: Plane[]): boolean;
  30993. /**
  30994. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30995. * @param frustumPlanes defines the frustum planes
  30996. * @returns true if the submesh is inside the frustum
  30997. */
  30998. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30999. /**
  31000. * Renders the submesh
  31001. * @param enableAlphaMode defines if alpha needs to be used
  31002. * @returns the submesh
  31003. */
  31004. render(enableAlphaMode: boolean): SubMesh;
  31005. /**
  31006. * @hidden
  31007. */
  31008. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31009. /**
  31010. * Checks if the submesh intersects with a ray
  31011. * @param ray defines the ray to test
  31012. * @returns true is the passed ray intersects the submesh bounding box
  31013. */
  31014. canIntersects(ray: Ray): boolean;
  31015. /**
  31016. * Intersects current submesh with a ray
  31017. * @param ray defines the ray to test
  31018. * @param positions defines mesh's positions array
  31019. * @param indices defines mesh's indices array
  31020. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31021. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31022. * @returns intersection info or null if no intersection
  31023. */
  31024. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31025. /** @hidden */
  31026. private _intersectLines;
  31027. /** @hidden */
  31028. private _intersectUnIndexedLines;
  31029. /** @hidden */
  31030. private _intersectTriangles;
  31031. /** @hidden */
  31032. private _intersectUnIndexedTriangles;
  31033. /** @hidden */
  31034. _rebuild(): void;
  31035. /**
  31036. * Creates a new submesh from the passed mesh
  31037. * @param newMesh defines the new hosting mesh
  31038. * @param newRenderingMesh defines an optional rendering mesh
  31039. * @returns the new submesh
  31040. */
  31041. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31042. /**
  31043. * Release associated resources
  31044. */
  31045. dispose(): void;
  31046. /**
  31047. * Gets the class name
  31048. * @returns the string "SubMesh".
  31049. */
  31050. getClassName(): string;
  31051. /**
  31052. * Creates a new submesh from indices data
  31053. * @param materialIndex the index of the main mesh material
  31054. * @param startIndex the index where to start the copy in the mesh indices array
  31055. * @param indexCount the number of indices to copy then from the startIndex
  31056. * @param mesh the main mesh to create the submesh from
  31057. * @param renderingMesh the optional rendering mesh
  31058. * @returns a new submesh
  31059. */
  31060. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31061. }
  31062. }
  31063. declare module BABYLON {
  31064. /**
  31065. * Class used to represent data loading progression
  31066. */
  31067. export class SceneLoaderFlags {
  31068. private static _ForceFullSceneLoadingForIncremental;
  31069. private static _ShowLoadingScreen;
  31070. private static _CleanBoneMatrixWeights;
  31071. private static _loggingLevel;
  31072. /**
  31073. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31074. */
  31075. static get ForceFullSceneLoadingForIncremental(): boolean;
  31076. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31077. /**
  31078. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31079. */
  31080. static get ShowLoadingScreen(): boolean;
  31081. static set ShowLoadingScreen(value: boolean);
  31082. /**
  31083. * Defines the current logging level (while loading the scene)
  31084. * @ignorenaming
  31085. */
  31086. static get loggingLevel(): number;
  31087. static set loggingLevel(value: number);
  31088. /**
  31089. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31090. */
  31091. static get CleanBoneMatrixWeights(): boolean;
  31092. static set CleanBoneMatrixWeights(value: boolean);
  31093. }
  31094. }
  31095. declare module BABYLON {
  31096. /**
  31097. * Class used to store geometry data (vertex buffers + index buffer)
  31098. */
  31099. export class Geometry implements IGetSetVerticesData {
  31100. /**
  31101. * Gets or sets the ID of the geometry
  31102. */
  31103. id: string;
  31104. /**
  31105. * Gets or sets the unique ID of the geometry
  31106. */
  31107. uniqueId: number;
  31108. /**
  31109. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31110. */
  31111. delayLoadState: number;
  31112. /**
  31113. * Gets the file containing the data to load when running in delay load state
  31114. */
  31115. delayLoadingFile: Nullable<string>;
  31116. /**
  31117. * Callback called when the geometry is updated
  31118. */
  31119. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31120. private _scene;
  31121. private _engine;
  31122. private _meshes;
  31123. private _totalVertices;
  31124. /** @hidden */
  31125. _indices: IndicesArray;
  31126. /** @hidden */
  31127. _vertexBuffers: {
  31128. [key: string]: VertexBuffer;
  31129. };
  31130. private _isDisposed;
  31131. private _extend;
  31132. private _boundingBias;
  31133. /** @hidden */
  31134. _delayInfo: Array<string>;
  31135. private _indexBuffer;
  31136. private _indexBufferIsUpdatable;
  31137. /** @hidden */
  31138. _boundingInfo: Nullable<BoundingInfo>;
  31139. /** @hidden */
  31140. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31141. /** @hidden */
  31142. _softwareSkinningFrameId: number;
  31143. private _vertexArrayObjects;
  31144. private _updatable;
  31145. /** @hidden */
  31146. _positions: Nullable<Vector3[]>;
  31147. private _positionsCache;
  31148. /**
  31149. * 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
  31150. */
  31151. get boundingBias(): Vector2;
  31152. /**
  31153. * 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
  31154. */
  31155. set boundingBias(value: Vector2);
  31156. /**
  31157. * Static function used to attach a new empty geometry to a mesh
  31158. * @param mesh defines the mesh to attach the geometry to
  31159. * @returns the new Geometry
  31160. */
  31161. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31162. /** Get the list of meshes using this geometry */
  31163. get meshes(): Mesh[];
  31164. /**
  31165. * 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
  31166. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31167. */
  31168. useBoundingInfoFromGeometry: boolean;
  31169. /**
  31170. * Creates a new geometry
  31171. * @param id defines the unique ID
  31172. * @param scene defines the hosting scene
  31173. * @param vertexData defines the VertexData used to get geometry data
  31174. * @param updatable defines if geometry must be updatable (false by default)
  31175. * @param mesh defines the mesh that will be associated with the geometry
  31176. */
  31177. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31178. /**
  31179. * Gets the current extend of the geometry
  31180. */
  31181. get extend(): {
  31182. minimum: Vector3;
  31183. maximum: Vector3;
  31184. };
  31185. /**
  31186. * Gets the hosting scene
  31187. * @returns the hosting Scene
  31188. */
  31189. getScene(): Scene;
  31190. /**
  31191. * Gets the hosting engine
  31192. * @returns the hosting Engine
  31193. */
  31194. getEngine(): Engine;
  31195. /**
  31196. * Defines if the geometry is ready to use
  31197. * @returns true if the geometry is ready to be used
  31198. */
  31199. isReady(): boolean;
  31200. /**
  31201. * Gets a value indicating that the geometry should not be serialized
  31202. */
  31203. get doNotSerialize(): boolean;
  31204. /** @hidden */
  31205. _rebuild(): void;
  31206. /**
  31207. * Affects all geometry data in one call
  31208. * @param vertexData defines the geometry data
  31209. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31210. */
  31211. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31212. /**
  31213. * Set specific vertex data
  31214. * @param kind defines the data kind (Position, normal, etc...)
  31215. * @param data defines the vertex data to use
  31216. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31217. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31218. */
  31219. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31220. /**
  31221. * Removes a specific vertex data
  31222. * @param kind defines the data kind (Position, normal, etc...)
  31223. */
  31224. removeVerticesData(kind: string): void;
  31225. /**
  31226. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31227. * @param buffer defines the vertex buffer to use
  31228. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31229. */
  31230. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31231. /**
  31232. * Update a specific vertex buffer
  31233. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31234. * It will do nothing if the buffer is not updatable
  31235. * @param kind defines the data kind (Position, normal, etc...)
  31236. * @param data defines the data to use
  31237. * @param offset defines the offset in the target buffer where to store the data
  31238. * @param useBytes set to true if the offset is in bytes
  31239. */
  31240. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31241. /**
  31242. * Update a specific vertex buffer
  31243. * This function will create a new buffer if the current one is not updatable
  31244. * @param kind defines the data kind (Position, normal, etc...)
  31245. * @param data defines the data to use
  31246. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31247. */
  31248. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31249. private _updateBoundingInfo;
  31250. /** @hidden */
  31251. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31252. /**
  31253. * Gets total number of vertices
  31254. * @returns the total number of vertices
  31255. */
  31256. getTotalVertices(): number;
  31257. /**
  31258. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31259. * @param kind defines the data kind (Position, normal, etc...)
  31260. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31262. * @returns a float array containing vertex data
  31263. */
  31264. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31265. /**
  31266. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31267. * @param kind defines the data kind (Position, normal, etc...)
  31268. * @returns true if the vertex buffer with the specified kind is updatable
  31269. */
  31270. isVertexBufferUpdatable(kind: string): boolean;
  31271. /**
  31272. * Gets a specific vertex buffer
  31273. * @param kind defines the data kind (Position, normal, etc...)
  31274. * @returns a VertexBuffer
  31275. */
  31276. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31277. /**
  31278. * Returns all vertex buffers
  31279. * @return an object holding all vertex buffers indexed by kind
  31280. */
  31281. getVertexBuffers(): Nullable<{
  31282. [key: string]: VertexBuffer;
  31283. }>;
  31284. /**
  31285. * Gets a boolean indicating if specific vertex buffer is present
  31286. * @param kind defines the data kind (Position, normal, etc...)
  31287. * @returns true if data is present
  31288. */
  31289. isVerticesDataPresent(kind: string): boolean;
  31290. /**
  31291. * Gets a list of all attached data kinds (Position, normal, etc...)
  31292. * @returns a list of string containing all kinds
  31293. */
  31294. getVerticesDataKinds(): string[];
  31295. /**
  31296. * Update index buffer
  31297. * @param indices defines the indices to store in the index buffer
  31298. * @param offset defines the offset in the target buffer where to store the data
  31299. * @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)
  31300. */
  31301. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31302. /**
  31303. * Creates a new index buffer
  31304. * @param indices defines the indices to store in the index buffer
  31305. * @param totalVertices defines the total number of vertices (could be null)
  31306. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31307. */
  31308. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31309. /**
  31310. * Return the total number of indices
  31311. * @returns the total number of indices
  31312. */
  31313. getTotalIndices(): number;
  31314. /**
  31315. * Gets the index buffer array
  31316. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31317. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31318. * @returns the index buffer array
  31319. */
  31320. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31321. /**
  31322. * Gets the index buffer
  31323. * @return the index buffer
  31324. */
  31325. getIndexBuffer(): Nullable<DataBuffer>;
  31326. /** @hidden */
  31327. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31328. /**
  31329. * Release the associated resources for a specific mesh
  31330. * @param mesh defines the source mesh
  31331. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31332. */
  31333. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31334. /**
  31335. * Apply current geometry to a given mesh
  31336. * @param mesh defines the mesh to apply geometry to
  31337. */
  31338. applyToMesh(mesh: Mesh): void;
  31339. private _updateExtend;
  31340. private _applyToMesh;
  31341. private notifyUpdate;
  31342. /**
  31343. * Load the geometry if it was flagged as delay loaded
  31344. * @param scene defines the hosting scene
  31345. * @param onLoaded defines a callback called when the geometry is loaded
  31346. */
  31347. load(scene: Scene, onLoaded?: () => void): void;
  31348. private _queueLoad;
  31349. /**
  31350. * Invert the geometry to move from a right handed system to a left handed one.
  31351. */
  31352. toLeftHanded(): void;
  31353. /** @hidden */
  31354. _resetPointsArrayCache(): void;
  31355. /** @hidden */
  31356. _generatePointsArray(): boolean;
  31357. /**
  31358. * Gets a value indicating if the geometry is disposed
  31359. * @returns true if the geometry was disposed
  31360. */
  31361. isDisposed(): boolean;
  31362. private _disposeVertexArrayObjects;
  31363. /**
  31364. * Free all associated resources
  31365. */
  31366. dispose(): void;
  31367. /**
  31368. * Clone the current geometry into a new geometry
  31369. * @param id defines the unique ID of the new geometry
  31370. * @returns a new geometry object
  31371. */
  31372. copy(id: string): Geometry;
  31373. /**
  31374. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31375. * @return a JSON representation of the current geometry data (without the vertices data)
  31376. */
  31377. serialize(): any;
  31378. private toNumberArray;
  31379. /**
  31380. * Serialize all vertices data into a JSON oject
  31381. * @returns a JSON representation of the current geometry data
  31382. */
  31383. serializeVerticeData(): any;
  31384. /**
  31385. * Extracts a clone of a mesh geometry
  31386. * @param mesh defines the source mesh
  31387. * @param id defines the unique ID of the new geometry object
  31388. * @returns the new geometry object
  31389. */
  31390. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31391. /**
  31392. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31393. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31394. * Be aware Math.random() could cause collisions, but:
  31395. * "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"
  31396. * @returns a string containing a new GUID
  31397. */
  31398. static RandomId(): string;
  31399. /** @hidden */
  31400. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31401. private static _CleanMatricesWeights;
  31402. /**
  31403. * Create a new geometry from persisted data (Using .babylon file format)
  31404. * @param parsedVertexData defines the persisted data
  31405. * @param scene defines the hosting scene
  31406. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31407. * @returns the new geometry object
  31408. */
  31409. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31410. }
  31411. }
  31412. declare module BABYLON {
  31413. /**
  31414. * Defines a target to use with MorphTargetManager
  31415. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31416. */
  31417. export class MorphTarget implements IAnimatable {
  31418. /** defines the name of the target */
  31419. name: string;
  31420. /**
  31421. * Gets or sets the list of animations
  31422. */
  31423. animations: Animation[];
  31424. private _scene;
  31425. private _positions;
  31426. private _normals;
  31427. private _tangents;
  31428. private _uvs;
  31429. private _influence;
  31430. private _uniqueId;
  31431. /**
  31432. * Observable raised when the influence changes
  31433. */
  31434. onInfluenceChanged: Observable<boolean>;
  31435. /** @hidden */
  31436. _onDataLayoutChanged: Observable<void>;
  31437. /**
  31438. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31439. */
  31440. get influence(): number;
  31441. set influence(influence: number);
  31442. /**
  31443. * Gets or sets the id of the morph Target
  31444. */
  31445. id: string;
  31446. private _animationPropertiesOverride;
  31447. /**
  31448. * Gets or sets the animation properties override
  31449. */
  31450. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31451. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31452. /**
  31453. * Creates a new MorphTarget
  31454. * @param name defines the name of the target
  31455. * @param influence defines the influence to use
  31456. * @param scene defines the scene the morphtarget belongs to
  31457. */
  31458. constructor(
  31459. /** defines the name of the target */
  31460. name: string, influence?: number, scene?: Nullable<Scene>);
  31461. /**
  31462. * Gets the unique ID of this manager
  31463. */
  31464. get uniqueId(): number;
  31465. /**
  31466. * Gets a boolean defining if the target contains position data
  31467. */
  31468. get hasPositions(): boolean;
  31469. /**
  31470. * Gets a boolean defining if the target contains normal data
  31471. */
  31472. get hasNormals(): boolean;
  31473. /**
  31474. * Gets a boolean defining if the target contains tangent data
  31475. */
  31476. get hasTangents(): boolean;
  31477. /**
  31478. * Gets a boolean defining if the target contains texture coordinates data
  31479. */
  31480. get hasUVs(): boolean;
  31481. /**
  31482. * Affects position data to this target
  31483. * @param data defines the position data to use
  31484. */
  31485. setPositions(data: Nullable<FloatArray>): void;
  31486. /**
  31487. * Gets the position data stored in this target
  31488. * @returns a FloatArray containing the position data (or null if not present)
  31489. */
  31490. getPositions(): Nullable<FloatArray>;
  31491. /**
  31492. * Affects normal data to this target
  31493. * @param data defines the normal data to use
  31494. */
  31495. setNormals(data: Nullable<FloatArray>): void;
  31496. /**
  31497. * Gets the normal data stored in this target
  31498. * @returns a FloatArray containing the normal data (or null if not present)
  31499. */
  31500. getNormals(): Nullable<FloatArray>;
  31501. /**
  31502. * Affects tangent data to this target
  31503. * @param data defines the tangent data to use
  31504. */
  31505. setTangents(data: Nullable<FloatArray>): void;
  31506. /**
  31507. * Gets the tangent data stored in this target
  31508. * @returns a FloatArray containing the tangent data (or null if not present)
  31509. */
  31510. getTangents(): Nullable<FloatArray>;
  31511. /**
  31512. * Affects texture coordinates data to this target
  31513. * @param data defines the texture coordinates data to use
  31514. */
  31515. setUVs(data: Nullable<FloatArray>): void;
  31516. /**
  31517. * Gets the texture coordinates data stored in this target
  31518. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31519. */
  31520. getUVs(): Nullable<FloatArray>;
  31521. /**
  31522. * Clone the current target
  31523. * @returns a new MorphTarget
  31524. */
  31525. clone(): MorphTarget;
  31526. /**
  31527. * Serializes the current target into a Serialization object
  31528. * @returns the serialized object
  31529. */
  31530. serialize(): any;
  31531. /**
  31532. * Returns the string "MorphTarget"
  31533. * @returns "MorphTarget"
  31534. */
  31535. getClassName(): string;
  31536. /**
  31537. * Creates a new target from serialized data
  31538. * @param serializationObject defines the serialized data to use
  31539. * @returns a new MorphTarget
  31540. */
  31541. static Parse(serializationObject: any): MorphTarget;
  31542. /**
  31543. * Creates a MorphTarget from mesh data
  31544. * @param mesh defines the source mesh
  31545. * @param name defines the name to use for the new target
  31546. * @param influence defines the influence to attach to the target
  31547. * @returns a new MorphTarget
  31548. */
  31549. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31550. }
  31551. }
  31552. declare module BABYLON {
  31553. /**
  31554. * This class is used to deform meshes using morphing between different targets
  31555. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31556. */
  31557. export class MorphTargetManager {
  31558. private _targets;
  31559. private _targetInfluenceChangedObservers;
  31560. private _targetDataLayoutChangedObservers;
  31561. private _activeTargets;
  31562. private _scene;
  31563. private _influences;
  31564. private _supportsNormals;
  31565. private _supportsTangents;
  31566. private _supportsUVs;
  31567. private _vertexCount;
  31568. private _uniqueId;
  31569. private _tempInfluences;
  31570. /**
  31571. * Gets or sets a boolean indicating if normals must be morphed
  31572. */
  31573. enableNormalMorphing: boolean;
  31574. /**
  31575. * Gets or sets a boolean indicating if tangents must be morphed
  31576. */
  31577. enableTangentMorphing: boolean;
  31578. /**
  31579. * Gets or sets a boolean indicating if UV must be morphed
  31580. */
  31581. enableUVMorphing: boolean;
  31582. /**
  31583. * Creates a new MorphTargetManager
  31584. * @param scene defines the current scene
  31585. */
  31586. constructor(scene?: Nullable<Scene>);
  31587. /**
  31588. * Gets the unique ID of this manager
  31589. */
  31590. get uniqueId(): number;
  31591. /**
  31592. * Gets the number of vertices handled by this manager
  31593. */
  31594. get vertexCount(): number;
  31595. /**
  31596. * Gets a boolean indicating if this manager supports morphing of normals
  31597. */
  31598. get supportsNormals(): boolean;
  31599. /**
  31600. * Gets a boolean indicating if this manager supports morphing of tangents
  31601. */
  31602. get supportsTangents(): boolean;
  31603. /**
  31604. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31605. */
  31606. get supportsUVs(): boolean;
  31607. /**
  31608. * Gets the number of targets stored in this manager
  31609. */
  31610. get numTargets(): number;
  31611. /**
  31612. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31613. */
  31614. get numInfluencers(): number;
  31615. /**
  31616. * Gets the list of influences (one per target)
  31617. */
  31618. get influences(): Float32Array;
  31619. /**
  31620. * Gets the active target at specified index. An active target is a target with an influence > 0
  31621. * @param index defines the index to check
  31622. * @returns the requested target
  31623. */
  31624. getActiveTarget(index: number): MorphTarget;
  31625. /**
  31626. * Gets the target at specified index
  31627. * @param index defines the index to check
  31628. * @returns the requested target
  31629. */
  31630. getTarget(index: number): MorphTarget;
  31631. /**
  31632. * Add a new target to this manager
  31633. * @param target defines the target to add
  31634. */
  31635. addTarget(target: MorphTarget): void;
  31636. /**
  31637. * Removes a target from the manager
  31638. * @param target defines the target to remove
  31639. */
  31640. removeTarget(target: MorphTarget): void;
  31641. /**
  31642. * Clone the current manager
  31643. * @returns a new MorphTargetManager
  31644. */
  31645. clone(): MorphTargetManager;
  31646. /**
  31647. * Serializes the current manager into a Serialization object
  31648. * @returns the serialized object
  31649. */
  31650. serialize(): any;
  31651. private _syncActiveTargets;
  31652. /**
  31653. * Syncrhonize the targets with all the meshes using this morph target manager
  31654. */
  31655. synchronize(): void;
  31656. /**
  31657. * Creates a new MorphTargetManager from serialized data
  31658. * @param serializationObject defines the serialized data
  31659. * @param scene defines the hosting scene
  31660. * @returns the new MorphTargetManager
  31661. */
  31662. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31663. }
  31664. }
  31665. declare module BABYLON {
  31666. /**
  31667. * Class used to represent a specific level of detail of a mesh
  31668. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31669. */
  31670. export class MeshLODLevel {
  31671. /** Defines the distance where this level should start being displayed */
  31672. distance: number;
  31673. /** Defines the mesh to use to render this level */
  31674. mesh: Nullable<Mesh>;
  31675. /**
  31676. * Creates a new LOD level
  31677. * @param distance defines the distance where this level should star being displayed
  31678. * @param mesh defines the mesh to use to render this level
  31679. */
  31680. constructor(
  31681. /** Defines the distance where this level should start being displayed */
  31682. distance: number,
  31683. /** Defines the mesh to use to render this level */
  31684. mesh: Nullable<Mesh>);
  31685. }
  31686. }
  31687. declare module BABYLON {
  31688. /**
  31689. * Helper class used to generate a canvas to manipulate images
  31690. */
  31691. export class CanvasGenerator {
  31692. /**
  31693. * Create a new canvas (or offscreen canvas depending on the context)
  31694. * @param width defines the expected width
  31695. * @param height defines the expected height
  31696. * @return a new canvas or offscreen canvas
  31697. */
  31698. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31699. }
  31700. }
  31701. declare module BABYLON {
  31702. /**
  31703. * Mesh representing the gorund
  31704. */
  31705. export class GroundMesh extends Mesh {
  31706. /** If octree should be generated */
  31707. generateOctree: boolean;
  31708. private _heightQuads;
  31709. /** @hidden */
  31710. _subdivisionsX: number;
  31711. /** @hidden */
  31712. _subdivisionsY: number;
  31713. /** @hidden */
  31714. _width: number;
  31715. /** @hidden */
  31716. _height: number;
  31717. /** @hidden */
  31718. _minX: number;
  31719. /** @hidden */
  31720. _maxX: number;
  31721. /** @hidden */
  31722. _minZ: number;
  31723. /** @hidden */
  31724. _maxZ: number;
  31725. constructor(name: string, scene: Scene);
  31726. /**
  31727. * "GroundMesh"
  31728. * @returns "GroundMesh"
  31729. */
  31730. getClassName(): string;
  31731. /**
  31732. * The minimum of x and y subdivisions
  31733. */
  31734. get subdivisions(): number;
  31735. /**
  31736. * X subdivisions
  31737. */
  31738. get subdivisionsX(): number;
  31739. /**
  31740. * Y subdivisions
  31741. */
  31742. get subdivisionsY(): number;
  31743. /**
  31744. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31745. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31746. * @param chunksCount the number of subdivisions for x and y
  31747. * @param octreeBlocksSize (Default: 32)
  31748. */
  31749. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31750. /**
  31751. * Returns a height (y) value in the Worl system :
  31752. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31753. * @param x x coordinate
  31754. * @param z z coordinate
  31755. * @returns the ground y position if (x, z) are outside the ground surface.
  31756. */
  31757. getHeightAtCoordinates(x: number, z: number): number;
  31758. /**
  31759. * Returns a normalized vector (Vector3) orthogonal to the ground
  31760. * at the ground coordinates (x, z) expressed in the World system.
  31761. * @param x x coordinate
  31762. * @param z z coordinate
  31763. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31764. */
  31765. getNormalAtCoordinates(x: number, z: number): Vector3;
  31766. /**
  31767. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31768. * at the ground coordinates (x, z) expressed in the World system.
  31769. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31770. * @param x x coordinate
  31771. * @param z z coordinate
  31772. * @param ref vector to store the result
  31773. * @returns the GroundMesh.
  31774. */
  31775. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31776. /**
  31777. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31778. * if the ground has been updated.
  31779. * This can be used in the render loop.
  31780. * @returns the GroundMesh.
  31781. */
  31782. updateCoordinateHeights(): GroundMesh;
  31783. private _getFacetAt;
  31784. private _initHeightQuads;
  31785. private _computeHeightQuads;
  31786. /**
  31787. * Serializes this ground mesh
  31788. * @param serializationObject object to write serialization to
  31789. */
  31790. serialize(serializationObject: any): void;
  31791. /**
  31792. * Parses a serialized ground mesh
  31793. * @param parsedMesh the serialized mesh
  31794. * @param scene the scene to create the ground mesh in
  31795. * @returns the created ground mesh
  31796. */
  31797. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31798. }
  31799. }
  31800. declare module BABYLON {
  31801. /**
  31802. * Interface for Physics-Joint data
  31803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31804. */
  31805. export interface PhysicsJointData {
  31806. /**
  31807. * The main pivot of the joint
  31808. */
  31809. mainPivot?: Vector3;
  31810. /**
  31811. * The connected pivot of the joint
  31812. */
  31813. connectedPivot?: Vector3;
  31814. /**
  31815. * The main axis of the joint
  31816. */
  31817. mainAxis?: Vector3;
  31818. /**
  31819. * The connected axis of the joint
  31820. */
  31821. connectedAxis?: Vector3;
  31822. /**
  31823. * The collision of the joint
  31824. */
  31825. collision?: boolean;
  31826. /**
  31827. * Native Oimo/Cannon/Energy data
  31828. */
  31829. nativeParams?: any;
  31830. }
  31831. /**
  31832. * This is a holder class for the physics joint created by the physics plugin
  31833. * It holds a set of functions to control the underlying joint
  31834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31835. */
  31836. export class PhysicsJoint {
  31837. /**
  31838. * The type of the physics joint
  31839. */
  31840. type: number;
  31841. /**
  31842. * The data for the physics joint
  31843. */
  31844. jointData: PhysicsJointData;
  31845. private _physicsJoint;
  31846. protected _physicsPlugin: IPhysicsEnginePlugin;
  31847. /**
  31848. * Initializes the physics joint
  31849. * @param type The type of the physics joint
  31850. * @param jointData The data for the physics joint
  31851. */
  31852. constructor(
  31853. /**
  31854. * The type of the physics joint
  31855. */
  31856. type: number,
  31857. /**
  31858. * The data for the physics joint
  31859. */
  31860. jointData: PhysicsJointData);
  31861. /**
  31862. * Gets the physics joint
  31863. */
  31864. get physicsJoint(): any;
  31865. /**
  31866. * Sets the physics joint
  31867. */
  31868. set physicsJoint(newJoint: any);
  31869. /**
  31870. * Sets the physics plugin
  31871. */
  31872. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31873. /**
  31874. * Execute a function that is physics-plugin specific.
  31875. * @param {Function} func the function that will be executed.
  31876. * It accepts two parameters: the physics world and the physics joint
  31877. */
  31878. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31879. /**
  31880. * Distance-Joint type
  31881. */
  31882. static DistanceJoint: number;
  31883. /**
  31884. * Hinge-Joint type
  31885. */
  31886. static HingeJoint: number;
  31887. /**
  31888. * Ball-and-Socket joint type
  31889. */
  31890. static BallAndSocketJoint: number;
  31891. /**
  31892. * Wheel-Joint type
  31893. */
  31894. static WheelJoint: number;
  31895. /**
  31896. * Slider-Joint type
  31897. */
  31898. static SliderJoint: number;
  31899. /**
  31900. * Prismatic-Joint type
  31901. */
  31902. static PrismaticJoint: number;
  31903. /**
  31904. * Universal-Joint type
  31905. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31906. */
  31907. static UniversalJoint: number;
  31908. /**
  31909. * Hinge-Joint 2 type
  31910. */
  31911. static Hinge2Joint: number;
  31912. /**
  31913. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31914. */
  31915. static PointToPointJoint: number;
  31916. /**
  31917. * Spring-Joint type
  31918. */
  31919. static SpringJoint: number;
  31920. /**
  31921. * Lock-Joint type
  31922. */
  31923. static LockJoint: number;
  31924. }
  31925. /**
  31926. * A class representing a physics distance joint
  31927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31928. */
  31929. export class DistanceJoint extends PhysicsJoint {
  31930. /**
  31931. *
  31932. * @param jointData The data for the Distance-Joint
  31933. */
  31934. constructor(jointData: DistanceJointData);
  31935. /**
  31936. * Update the predefined distance.
  31937. * @param maxDistance The maximum preferred distance
  31938. * @param minDistance The minimum preferred distance
  31939. */
  31940. updateDistance(maxDistance: number, minDistance?: number): void;
  31941. }
  31942. /**
  31943. * Represents a Motor-Enabled Joint
  31944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31945. */
  31946. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31947. /**
  31948. * Initializes the Motor-Enabled Joint
  31949. * @param type The type of the joint
  31950. * @param jointData The physica joint data for the joint
  31951. */
  31952. constructor(type: number, jointData: PhysicsJointData);
  31953. /**
  31954. * Set the motor values.
  31955. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31956. * @param force the force to apply
  31957. * @param maxForce max force for this motor.
  31958. */
  31959. setMotor(force?: number, maxForce?: number): void;
  31960. /**
  31961. * Set the motor's limits.
  31962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31963. * @param upperLimit The upper limit of the motor
  31964. * @param lowerLimit The lower limit of the motor
  31965. */
  31966. setLimit(upperLimit: number, lowerLimit?: number): void;
  31967. }
  31968. /**
  31969. * This class represents a single physics Hinge-Joint
  31970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31971. */
  31972. export class HingeJoint extends MotorEnabledJoint {
  31973. /**
  31974. * Initializes the Hinge-Joint
  31975. * @param jointData The joint data for the Hinge-Joint
  31976. */
  31977. constructor(jointData: PhysicsJointData);
  31978. /**
  31979. * Set the motor values.
  31980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31981. * @param {number} force the force to apply
  31982. * @param {number} maxForce max force for this motor.
  31983. */
  31984. setMotor(force?: number, maxForce?: number): void;
  31985. /**
  31986. * Set the motor's limits.
  31987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31988. * @param upperLimit The upper limit of the motor
  31989. * @param lowerLimit The lower limit of the motor
  31990. */
  31991. setLimit(upperLimit: number, lowerLimit?: number): void;
  31992. }
  31993. /**
  31994. * This class represents a dual hinge physics joint (same as wheel joint)
  31995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31996. */
  31997. export class Hinge2Joint extends MotorEnabledJoint {
  31998. /**
  31999. * Initializes the Hinge2-Joint
  32000. * @param jointData The joint data for the Hinge2-Joint
  32001. */
  32002. constructor(jointData: PhysicsJointData);
  32003. /**
  32004. * Set the motor values.
  32005. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32006. * @param {number} targetSpeed the speed the motor is to reach
  32007. * @param {number} maxForce max force for this motor.
  32008. * @param {motorIndex} the motor's index, 0 or 1.
  32009. */
  32010. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32011. /**
  32012. * Set the motor limits.
  32013. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32014. * @param {number} upperLimit the upper limit
  32015. * @param {number} lowerLimit lower limit
  32016. * @param {motorIndex} the motor's index, 0 or 1.
  32017. */
  32018. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32019. }
  32020. /**
  32021. * Interface for a motor enabled joint
  32022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32023. */
  32024. export interface IMotorEnabledJoint {
  32025. /**
  32026. * Physics joint
  32027. */
  32028. physicsJoint: any;
  32029. /**
  32030. * Sets the motor of the motor-enabled joint
  32031. * @param force The force of the motor
  32032. * @param maxForce The maximum force of the motor
  32033. * @param motorIndex The index of the motor
  32034. */
  32035. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32036. /**
  32037. * Sets the limit of the motor
  32038. * @param upperLimit The upper limit of the motor
  32039. * @param lowerLimit The lower limit of the motor
  32040. * @param motorIndex The index of the motor
  32041. */
  32042. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32043. }
  32044. /**
  32045. * Joint data for a Distance-Joint
  32046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32047. */
  32048. export interface DistanceJointData extends PhysicsJointData {
  32049. /**
  32050. * Max distance the 2 joint objects can be apart
  32051. */
  32052. maxDistance: number;
  32053. }
  32054. /**
  32055. * Joint data from a spring joint
  32056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32057. */
  32058. export interface SpringJointData extends PhysicsJointData {
  32059. /**
  32060. * Length of the spring
  32061. */
  32062. length: number;
  32063. /**
  32064. * Stiffness of the spring
  32065. */
  32066. stiffness: number;
  32067. /**
  32068. * Damping of the spring
  32069. */
  32070. damping: number;
  32071. /** this callback will be called when applying the force to the impostors. */
  32072. forceApplicationCallback: () => void;
  32073. }
  32074. }
  32075. declare module BABYLON {
  32076. /**
  32077. * Holds the data for the raycast result
  32078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32079. */
  32080. export class PhysicsRaycastResult {
  32081. private _hasHit;
  32082. private _hitDistance;
  32083. private _hitNormalWorld;
  32084. private _hitPointWorld;
  32085. private _rayFromWorld;
  32086. private _rayToWorld;
  32087. /**
  32088. * Gets if there was a hit
  32089. */
  32090. get hasHit(): boolean;
  32091. /**
  32092. * Gets the distance from the hit
  32093. */
  32094. get hitDistance(): number;
  32095. /**
  32096. * Gets the hit normal/direction in the world
  32097. */
  32098. get hitNormalWorld(): Vector3;
  32099. /**
  32100. * Gets the hit point in the world
  32101. */
  32102. get hitPointWorld(): Vector3;
  32103. /**
  32104. * Gets the ray "start point" of the ray in the world
  32105. */
  32106. get rayFromWorld(): Vector3;
  32107. /**
  32108. * Gets the ray "end point" of the ray in the world
  32109. */
  32110. get rayToWorld(): Vector3;
  32111. /**
  32112. * Sets the hit data (normal & point in world space)
  32113. * @param hitNormalWorld defines the normal in world space
  32114. * @param hitPointWorld defines the point in world space
  32115. */
  32116. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32117. /**
  32118. * Sets the distance from the start point to the hit point
  32119. * @param distance
  32120. */
  32121. setHitDistance(distance: number): void;
  32122. /**
  32123. * Calculates the distance manually
  32124. */
  32125. calculateHitDistance(): void;
  32126. /**
  32127. * Resets all the values to default
  32128. * @param from The from point on world space
  32129. * @param to The to point on world space
  32130. */
  32131. reset(from?: Vector3, to?: Vector3): void;
  32132. }
  32133. /**
  32134. * Interface for the size containing width and height
  32135. */
  32136. interface IXYZ {
  32137. /**
  32138. * X
  32139. */
  32140. x: number;
  32141. /**
  32142. * Y
  32143. */
  32144. y: number;
  32145. /**
  32146. * Z
  32147. */
  32148. z: number;
  32149. }
  32150. }
  32151. declare module BABYLON {
  32152. /**
  32153. * Interface used to describe a physics joint
  32154. */
  32155. export interface PhysicsImpostorJoint {
  32156. /** Defines the main impostor to which the joint is linked */
  32157. mainImpostor: PhysicsImpostor;
  32158. /** Defines the impostor that is connected to the main impostor using this joint */
  32159. connectedImpostor: PhysicsImpostor;
  32160. /** Defines the joint itself */
  32161. joint: PhysicsJoint;
  32162. }
  32163. /** @hidden */
  32164. export interface IPhysicsEnginePlugin {
  32165. world: any;
  32166. name: string;
  32167. setGravity(gravity: Vector3): void;
  32168. setTimeStep(timeStep: number): void;
  32169. getTimeStep(): number;
  32170. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32171. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32172. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32174. removePhysicsBody(impostor: PhysicsImpostor): void;
  32175. generateJoint(joint: PhysicsImpostorJoint): void;
  32176. removeJoint(joint: PhysicsImpostorJoint): void;
  32177. isSupported(): boolean;
  32178. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32179. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32180. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32181. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32182. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32183. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32184. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32185. getBodyMass(impostor: PhysicsImpostor): number;
  32186. getBodyFriction(impostor: PhysicsImpostor): number;
  32187. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32188. getBodyRestitution(impostor: PhysicsImpostor): number;
  32189. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32190. getBodyPressure?(impostor: PhysicsImpostor): number;
  32191. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32192. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32193. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32194. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32195. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32196. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32197. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32198. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32199. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32200. sleepBody(impostor: PhysicsImpostor): void;
  32201. wakeUpBody(impostor: PhysicsImpostor): void;
  32202. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32203. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32204. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32205. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32206. getRadius(impostor: PhysicsImpostor): number;
  32207. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32208. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32209. dispose(): void;
  32210. }
  32211. /**
  32212. * Interface used to define a physics engine
  32213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32214. */
  32215. export interface IPhysicsEngine {
  32216. /**
  32217. * Gets the gravity vector used by the simulation
  32218. */
  32219. gravity: Vector3;
  32220. /**
  32221. * Sets the gravity vector used by the simulation
  32222. * @param gravity defines the gravity vector to use
  32223. */
  32224. setGravity(gravity: Vector3): void;
  32225. /**
  32226. * Set the time step of the physics engine.
  32227. * Default is 1/60.
  32228. * To slow it down, enter 1/600 for example.
  32229. * To speed it up, 1/30
  32230. * @param newTimeStep the new timestep to apply to this world.
  32231. */
  32232. setTimeStep(newTimeStep: number): void;
  32233. /**
  32234. * Get the time step of the physics engine.
  32235. * @returns the current time step
  32236. */
  32237. getTimeStep(): number;
  32238. /**
  32239. * Set the sub time step of the physics engine.
  32240. * Default is 0 meaning there is no sub steps
  32241. * To increase physics resolution precision, set a small value (like 1 ms)
  32242. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32243. */
  32244. setSubTimeStep(subTimeStep: number): void;
  32245. /**
  32246. * Get the sub time step of the physics engine.
  32247. * @returns the current sub time step
  32248. */
  32249. getSubTimeStep(): number;
  32250. /**
  32251. * Release all resources
  32252. */
  32253. dispose(): void;
  32254. /**
  32255. * Gets the name of the current physics plugin
  32256. * @returns the name of the plugin
  32257. */
  32258. getPhysicsPluginName(): string;
  32259. /**
  32260. * Adding a new impostor for the impostor tracking.
  32261. * This will be done by the impostor itself.
  32262. * @param impostor the impostor to add
  32263. */
  32264. addImpostor(impostor: PhysicsImpostor): void;
  32265. /**
  32266. * Remove an impostor from the engine.
  32267. * This impostor and its mesh will not longer be updated by the physics engine.
  32268. * @param impostor the impostor to remove
  32269. */
  32270. removeImpostor(impostor: PhysicsImpostor): void;
  32271. /**
  32272. * Add a joint to the physics engine
  32273. * @param mainImpostor defines the main impostor to which the joint is added.
  32274. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32275. * @param joint defines the joint that will connect both impostors.
  32276. */
  32277. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32278. /**
  32279. * Removes a joint from the simulation
  32280. * @param mainImpostor defines the impostor used with the joint
  32281. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32282. * @param joint defines the joint to remove
  32283. */
  32284. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32285. /**
  32286. * Gets the current plugin used to run the simulation
  32287. * @returns current plugin
  32288. */
  32289. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32290. /**
  32291. * Gets the list of physic impostors
  32292. * @returns an array of PhysicsImpostor
  32293. */
  32294. getImpostors(): Array<PhysicsImpostor>;
  32295. /**
  32296. * Gets the impostor for a physics enabled object
  32297. * @param object defines the object impersonated by the impostor
  32298. * @returns the PhysicsImpostor or null if not found
  32299. */
  32300. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32301. /**
  32302. * Gets the impostor for a physics body object
  32303. * @param body defines physics body used by the impostor
  32304. * @returns the PhysicsImpostor or null if not found
  32305. */
  32306. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32307. /**
  32308. * Does a raycast in the physics world
  32309. * @param from when should the ray start?
  32310. * @param to when should the ray end?
  32311. * @returns PhysicsRaycastResult
  32312. */
  32313. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32314. /**
  32315. * Called by the scene. No need to call it.
  32316. * @param delta defines the timespam between frames
  32317. */
  32318. _step(delta: number): void;
  32319. }
  32320. }
  32321. declare module BABYLON {
  32322. /**
  32323. * The interface for the physics imposter parameters
  32324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32325. */
  32326. export interface PhysicsImpostorParameters {
  32327. /**
  32328. * The mass of the physics imposter
  32329. */
  32330. mass: number;
  32331. /**
  32332. * The friction of the physics imposter
  32333. */
  32334. friction?: number;
  32335. /**
  32336. * The coefficient of restitution of the physics imposter
  32337. */
  32338. restitution?: number;
  32339. /**
  32340. * The native options of the physics imposter
  32341. */
  32342. nativeOptions?: any;
  32343. /**
  32344. * Specifies if the parent should be ignored
  32345. */
  32346. ignoreParent?: boolean;
  32347. /**
  32348. * Specifies if bi-directional transformations should be disabled
  32349. */
  32350. disableBidirectionalTransformation?: boolean;
  32351. /**
  32352. * The pressure inside the physics imposter, soft object only
  32353. */
  32354. pressure?: number;
  32355. /**
  32356. * The stiffness the physics imposter, soft object only
  32357. */
  32358. stiffness?: number;
  32359. /**
  32360. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32361. */
  32362. velocityIterations?: number;
  32363. /**
  32364. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32365. */
  32366. positionIterations?: number;
  32367. /**
  32368. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32369. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32370. * Add to fix multiple points
  32371. */
  32372. fixedPoints?: number;
  32373. /**
  32374. * The collision margin around a soft object
  32375. */
  32376. margin?: number;
  32377. /**
  32378. * The collision margin around a soft object
  32379. */
  32380. damping?: number;
  32381. /**
  32382. * The path for a rope based on an extrusion
  32383. */
  32384. path?: any;
  32385. /**
  32386. * The shape of an extrusion used for a rope based on an extrusion
  32387. */
  32388. shape?: any;
  32389. }
  32390. /**
  32391. * Interface for a physics-enabled object
  32392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32393. */
  32394. export interface IPhysicsEnabledObject {
  32395. /**
  32396. * The position of the physics-enabled object
  32397. */
  32398. position: Vector3;
  32399. /**
  32400. * The rotation of the physics-enabled object
  32401. */
  32402. rotationQuaternion: Nullable<Quaternion>;
  32403. /**
  32404. * The scale of the physics-enabled object
  32405. */
  32406. scaling: Vector3;
  32407. /**
  32408. * The rotation of the physics-enabled object
  32409. */
  32410. rotation?: Vector3;
  32411. /**
  32412. * The parent of the physics-enabled object
  32413. */
  32414. parent?: any;
  32415. /**
  32416. * The bounding info of the physics-enabled object
  32417. * @returns The bounding info of the physics-enabled object
  32418. */
  32419. getBoundingInfo(): BoundingInfo;
  32420. /**
  32421. * Computes the world matrix
  32422. * @param force Specifies if the world matrix should be computed by force
  32423. * @returns A world matrix
  32424. */
  32425. computeWorldMatrix(force: boolean): Matrix;
  32426. /**
  32427. * Gets the world matrix
  32428. * @returns A world matrix
  32429. */
  32430. getWorldMatrix?(): Matrix;
  32431. /**
  32432. * Gets the child meshes
  32433. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32434. * @returns An array of abstract meshes
  32435. */
  32436. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32437. /**
  32438. * Gets the vertex data
  32439. * @param kind The type of vertex data
  32440. * @returns A nullable array of numbers, or a float32 array
  32441. */
  32442. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32443. /**
  32444. * Gets the indices from the mesh
  32445. * @returns A nullable array of index arrays
  32446. */
  32447. getIndices?(): Nullable<IndicesArray>;
  32448. /**
  32449. * Gets the scene from the mesh
  32450. * @returns the indices array or null
  32451. */
  32452. getScene?(): Scene;
  32453. /**
  32454. * Gets the absolute position from the mesh
  32455. * @returns the absolute position
  32456. */
  32457. getAbsolutePosition(): Vector3;
  32458. /**
  32459. * Gets the absolute pivot point from the mesh
  32460. * @returns the absolute pivot point
  32461. */
  32462. getAbsolutePivotPoint(): Vector3;
  32463. /**
  32464. * Rotates the mesh
  32465. * @param axis The axis of rotation
  32466. * @param amount The amount of rotation
  32467. * @param space The space of the rotation
  32468. * @returns The rotation transform node
  32469. */
  32470. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32471. /**
  32472. * Translates the mesh
  32473. * @param axis The axis of translation
  32474. * @param distance The distance of translation
  32475. * @param space The space of the translation
  32476. * @returns The transform node
  32477. */
  32478. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32479. /**
  32480. * Sets the absolute position of the mesh
  32481. * @param absolutePosition The absolute position of the mesh
  32482. * @returns The transform node
  32483. */
  32484. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32485. /**
  32486. * Gets the class name of the mesh
  32487. * @returns The class name
  32488. */
  32489. getClassName(): string;
  32490. }
  32491. /**
  32492. * Represents a physics imposter
  32493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32494. */
  32495. export class PhysicsImpostor {
  32496. /**
  32497. * The physics-enabled object used as the physics imposter
  32498. */
  32499. object: IPhysicsEnabledObject;
  32500. /**
  32501. * The type of the physics imposter
  32502. */
  32503. type: number;
  32504. private _options;
  32505. private _scene?;
  32506. /**
  32507. * The default object size of the imposter
  32508. */
  32509. static DEFAULT_OBJECT_SIZE: Vector3;
  32510. /**
  32511. * The identity quaternion of the imposter
  32512. */
  32513. static IDENTITY_QUATERNION: Quaternion;
  32514. /** @hidden */
  32515. _pluginData: any;
  32516. private _physicsEngine;
  32517. private _physicsBody;
  32518. private _bodyUpdateRequired;
  32519. private _onBeforePhysicsStepCallbacks;
  32520. private _onAfterPhysicsStepCallbacks;
  32521. /** @hidden */
  32522. _onPhysicsCollideCallbacks: Array<{
  32523. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32524. otherImpostors: Array<PhysicsImpostor>;
  32525. }>;
  32526. private _deltaPosition;
  32527. private _deltaRotation;
  32528. private _deltaRotationConjugated;
  32529. /** @hidden */
  32530. _isFromLine: boolean;
  32531. private _parent;
  32532. private _isDisposed;
  32533. private static _tmpVecs;
  32534. private static _tmpQuat;
  32535. /**
  32536. * Specifies if the physics imposter is disposed
  32537. */
  32538. get isDisposed(): boolean;
  32539. /**
  32540. * Gets the mass of the physics imposter
  32541. */
  32542. get mass(): number;
  32543. set mass(value: number);
  32544. /**
  32545. * Gets the coefficient of friction
  32546. */
  32547. get friction(): number;
  32548. /**
  32549. * Sets the coefficient of friction
  32550. */
  32551. set friction(value: number);
  32552. /**
  32553. * Gets the coefficient of restitution
  32554. */
  32555. get restitution(): number;
  32556. /**
  32557. * Sets the coefficient of restitution
  32558. */
  32559. set restitution(value: number);
  32560. /**
  32561. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32562. */
  32563. get pressure(): number;
  32564. /**
  32565. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32566. */
  32567. set pressure(value: number);
  32568. /**
  32569. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32570. */
  32571. get stiffness(): number;
  32572. /**
  32573. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32574. */
  32575. set stiffness(value: number);
  32576. /**
  32577. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32578. */
  32579. get velocityIterations(): number;
  32580. /**
  32581. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32582. */
  32583. set velocityIterations(value: number);
  32584. /**
  32585. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32586. */
  32587. get positionIterations(): number;
  32588. /**
  32589. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32590. */
  32591. set positionIterations(value: number);
  32592. /**
  32593. * The unique id of the physics imposter
  32594. * set by the physics engine when adding this impostor to the array
  32595. */
  32596. uniqueId: number;
  32597. /**
  32598. * @hidden
  32599. */
  32600. soft: boolean;
  32601. /**
  32602. * @hidden
  32603. */
  32604. segments: number;
  32605. private _joints;
  32606. /**
  32607. * Initializes the physics imposter
  32608. * @param object The physics-enabled object used as the physics imposter
  32609. * @param type The type of the physics imposter
  32610. * @param _options The options for the physics imposter
  32611. * @param _scene The Babylon scene
  32612. */
  32613. constructor(
  32614. /**
  32615. * The physics-enabled object used as the physics imposter
  32616. */
  32617. object: IPhysicsEnabledObject,
  32618. /**
  32619. * The type of the physics imposter
  32620. */
  32621. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32622. /**
  32623. * This function will completly initialize this impostor.
  32624. * It will create a new body - but only if this mesh has no parent.
  32625. * If it has, this impostor will not be used other than to define the impostor
  32626. * of the child mesh.
  32627. * @hidden
  32628. */
  32629. _init(): void;
  32630. private _getPhysicsParent;
  32631. /**
  32632. * Should a new body be generated.
  32633. * @returns boolean specifying if body initialization is required
  32634. */
  32635. isBodyInitRequired(): boolean;
  32636. /**
  32637. * Sets the updated scaling
  32638. * @param updated Specifies if the scaling is updated
  32639. */
  32640. setScalingUpdated(): void;
  32641. /**
  32642. * Force a regeneration of this or the parent's impostor's body.
  32643. * Use under cautious - This will remove all joints already implemented.
  32644. */
  32645. forceUpdate(): void;
  32646. /**
  32647. * Gets the body that holds this impostor. Either its own, or its parent.
  32648. */
  32649. get physicsBody(): any;
  32650. /**
  32651. * Get the parent of the physics imposter
  32652. * @returns Physics imposter or null
  32653. */
  32654. get parent(): Nullable<PhysicsImpostor>;
  32655. /**
  32656. * Sets the parent of the physics imposter
  32657. */
  32658. set parent(value: Nullable<PhysicsImpostor>);
  32659. /**
  32660. * Set the physics body. Used mainly by the physics engine/plugin
  32661. */
  32662. set physicsBody(physicsBody: any);
  32663. /**
  32664. * Resets the update flags
  32665. */
  32666. resetUpdateFlags(): void;
  32667. /**
  32668. * Gets the object extend size
  32669. * @returns the object extend size
  32670. */
  32671. getObjectExtendSize(): Vector3;
  32672. /**
  32673. * Gets the object center
  32674. * @returns The object center
  32675. */
  32676. getObjectCenter(): Vector3;
  32677. /**
  32678. * Get a specific parameter from the options parameters
  32679. * @param paramName The object parameter name
  32680. * @returns The object parameter
  32681. */
  32682. getParam(paramName: string): any;
  32683. /**
  32684. * Sets a specific parameter in the options given to the physics plugin
  32685. * @param paramName The parameter name
  32686. * @param value The value of the parameter
  32687. */
  32688. setParam(paramName: string, value: number): void;
  32689. /**
  32690. * Specifically change the body's mass option. Won't recreate the physics body object
  32691. * @param mass The mass of the physics imposter
  32692. */
  32693. setMass(mass: number): void;
  32694. /**
  32695. * Gets the linear velocity
  32696. * @returns linear velocity or null
  32697. */
  32698. getLinearVelocity(): Nullable<Vector3>;
  32699. /**
  32700. * Sets the linear velocity
  32701. * @param velocity linear velocity or null
  32702. */
  32703. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32704. /**
  32705. * Gets the angular velocity
  32706. * @returns angular velocity or null
  32707. */
  32708. getAngularVelocity(): Nullable<Vector3>;
  32709. /**
  32710. * Sets the angular velocity
  32711. * @param velocity The velocity or null
  32712. */
  32713. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32714. /**
  32715. * Execute a function with the physics plugin native code
  32716. * Provide a function the will have two variables - the world object and the physics body object
  32717. * @param func The function to execute with the physics plugin native code
  32718. */
  32719. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32720. /**
  32721. * Register a function that will be executed before the physics world is stepping forward
  32722. * @param func The function to execute before the physics world is stepped forward
  32723. */
  32724. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32725. /**
  32726. * Unregister a function that will be executed before the physics world is stepping forward
  32727. * @param func The function to execute before the physics world is stepped forward
  32728. */
  32729. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32730. /**
  32731. * Register a function that will be executed after the physics step
  32732. * @param func The function to execute after physics step
  32733. */
  32734. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32735. /**
  32736. * Unregisters a function that will be executed after the physics step
  32737. * @param func The function to execute after physics step
  32738. */
  32739. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32740. /**
  32741. * register a function that will be executed when this impostor collides against a different body
  32742. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32743. * @param func Callback that is executed on collision
  32744. */
  32745. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32746. /**
  32747. * Unregisters the physics imposter on contact
  32748. * @param collideAgainst The physics object to collide against
  32749. * @param func Callback to execute on collision
  32750. */
  32751. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32752. private _tmpQuat;
  32753. private _tmpQuat2;
  32754. /**
  32755. * Get the parent rotation
  32756. * @returns The parent rotation
  32757. */
  32758. getParentsRotation(): Quaternion;
  32759. /**
  32760. * this function is executed by the physics engine.
  32761. */
  32762. beforeStep: () => void;
  32763. /**
  32764. * this function is executed by the physics engine
  32765. */
  32766. afterStep: () => void;
  32767. /**
  32768. * Legacy collision detection event support
  32769. */
  32770. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32771. /**
  32772. * event and body object due to cannon's event-based architecture.
  32773. */
  32774. onCollide: (e: {
  32775. body: any;
  32776. point: Nullable<Vector3>;
  32777. }) => void;
  32778. /**
  32779. * Apply a force
  32780. * @param force The force to apply
  32781. * @param contactPoint The contact point for the force
  32782. * @returns The physics imposter
  32783. */
  32784. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32785. /**
  32786. * Apply an impulse
  32787. * @param force The impulse force
  32788. * @param contactPoint The contact point for the impulse force
  32789. * @returns The physics imposter
  32790. */
  32791. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32792. /**
  32793. * A help function to create a joint
  32794. * @param otherImpostor A physics imposter used to create a joint
  32795. * @param jointType The type of joint
  32796. * @param jointData The data for the joint
  32797. * @returns The physics imposter
  32798. */
  32799. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32800. /**
  32801. * Add a joint to this impostor with a different impostor
  32802. * @param otherImpostor A physics imposter used to add a joint
  32803. * @param joint The joint to add
  32804. * @returns The physics imposter
  32805. */
  32806. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32807. /**
  32808. * Add an anchor to a cloth impostor
  32809. * @param otherImpostor rigid impostor to anchor to
  32810. * @param width ratio across width from 0 to 1
  32811. * @param height ratio up height from 0 to 1
  32812. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32813. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32814. * @returns impostor the soft imposter
  32815. */
  32816. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32817. /**
  32818. * Add a hook to a rope impostor
  32819. * @param otherImpostor rigid impostor to anchor to
  32820. * @param length ratio across rope from 0 to 1
  32821. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32822. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32823. * @returns impostor the rope imposter
  32824. */
  32825. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32826. /**
  32827. * Will keep this body still, in a sleep mode.
  32828. * @returns the physics imposter
  32829. */
  32830. sleep(): PhysicsImpostor;
  32831. /**
  32832. * Wake the body up.
  32833. * @returns The physics imposter
  32834. */
  32835. wakeUp(): PhysicsImpostor;
  32836. /**
  32837. * Clones the physics imposter
  32838. * @param newObject The physics imposter clones to this physics-enabled object
  32839. * @returns A nullable physics imposter
  32840. */
  32841. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32842. /**
  32843. * Disposes the physics imposter
  32844. */
  32845. dispose(): void;
  32846. /**
  32847. * Sets the delta position
  32848. * @param position The delta position amount
  32849. */
  32850. setDeltaPosition(position: Vector3): void;
  32851. /**
  32852. * Sets the delta rotation
  32853. * @param rotation The delta rotation amount
  32854. */
  32855. setDeltaRotation(rotation: Quaternion): void;
  32856. /**
  32857. * Gets the box size of the physics imposter and stores the result in the input parameter
  32858. * @param result Stores the box size
  32859. * @returns The physics imposter
  32860. */
  32861. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32862. /**
  32863. * Gets the radius of the physics imposter
  32864. * @returns Radius of the physics imposter
  32865. */
  32866. getRadius(): number;
  32867. /**
  32868. * Sync a bone with this impostor
  32869. * @param bone The bone to sync to the impostor.
  32870. * @param boneMesh The mesh that the bone is influencing.
  32871. * @param jointPivot The pivot of the joint / bone in local space.
  32872. * @param distToJoint Optional distance from the impostor to the joint.
  32873. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32874. */
  32875. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32876. /**
  32877. * Sync impostor to a bone
  32878. * @param bone The bone that the impostor will be synced to.
  32879. * @param boneMesh The mesh that the bone is influencing.
  32880. * @param jointPivot The pivot of the joint / bone in local space.
  32881. * @param distToJoint Optional distance from the impostor to the joint.
  32882. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32883. * @param boneAxis Optional vector3 axis the bone is aligned with
  32884. */
  32885. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32886. /**
  32887. * No-Imposter type
  32888. */
  32889. static NoImpostor: number;
  32890. /**
  32891. * Sphere-Imposter type
  32892. */
  32893. static SphereImpostor: number;
  32894. /**
  32895. * Box-Imposter type
  32896. */
  32897. static BoxImpostor: number;
  32898. /**
  32899. * Plane-Imposter type
  32900. */
  32901. static PlaneImpostor: number;
  32902. /**
  32903. * Mesh-imposter type
  32904. */
  32905. static MeshImpostor: number;
  32906. /**
  32907. * Capsule-Impostor type (Ammo.js plugin only)
  32908. */
  32909. static CapsuleImpostor: number;
  32910. /**
  32911. * Cylinder-Imposter type
  32912. */
  32913. static CylinderImpostor: number;
  32914. /**
  32915. * Particle-Imposter type
  32916. */
  32917. static ParticleImpostor: number;
  32918. /**
  32919. * Heightmap-Imposter type
  32920. */
  32921. static HeightmapImpostor: number;
  32922. /**
  32923. * ConvexHull-Impostor type (Ammo.js plugin only)
  32924. */
  32925. static ConvexHullImpostor: number;
  32926. /**
  32927. * Custom-Imposter type (Ammo.js plugin only)
  32928. */
  32929. static CustomImpostor: number;
  32930. /**
  32931. * Rope-Imposter type
  32932. */
  32933. static RopeImpostor: number;
  32934. /**
  32935. * Cloth-Imposter type
  32936. */
  32937. static ClothImpostor: number;
  32938. /**
  32939. * Softbody-Imposter type
  32940. */
  32941. static SoftbodyImpostor: number;
  32942. }
  32943. }
  32944. declare module BABYLON {
  32945. /**
  32946. * @hidden
  32947. **/
  32948. export class _CreationDataStorage {
  32949. closePath?: boolean;
  32950. closeArray?: boolean;
  32951. idx: number[];
  32952. dashSize: number;
  32953. gapSize: number;
  32954. path3D: Path3D;
  32955. pathArray: Vector3[][];
  32956. arc: number;
  32957. radius: number;
  32958. cap: number;
  32959. tessellation: number;
  32960. }
  32961. /**
  32962. * @hidden
  32963. **/
  32964. class _InstanceDataStorage {
  32965. visibleInstances: any;
  32966. batchCache: _InstancesBatch;
  32967. instancesBufferSize: number;
  32968. instancesBuffer: Nullable<Buffer>;
  32969. instancesData: Float32Array;
  32970. overridenInstanceCount: number;
  32971. isFrozen: boolean;
  32972. previousBatch: Nullable<_InstancesBatch>;
  32973. hardwareInstancedRendering: boolean;
  32974. sideOrientation: number;
  32975. manualUpdate: boolean;
  32976. previousRenderId: number;
  32977. }
  32978. /**
  32979. * @hidden
  32980. **/
  32981. export class _InstancesBatch {
  32982. mustReturn: boolean;
  32983. visibleInstances: Nullable<InstancedMesh[]>[];
  32984. renderSelf: boolean[];
  32985. hardwareInstancedRendering: boolean[];
  32986. }
  32987. /**
  32988. * @hidden
  32989. **/
  32990. class _ThinInstanceDataStorage {
  32991. instancesCount: number;
  32992. matrixBuffer: Nullable<Buffer>;
  32993. matrixBufferSize: number;
  32994. matrixData: Nullable<Float32Array>;
  32995. boundingVectors: Array<Vector3>;
  32996. worldMatrices: Nullable<Matrix[]>;
  32997. }
  32998. /**
  32999. * Class used to represent renderable models
  33000. */
  33001. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33002. /**
  33003. * Mesh side orientation : usually the external or front surface
  33004. */
  33005. static readonly FRONTSIDE: number;
  33006. /**
  33007. * Mesh side orientation : usually the internal or back surface
  33008. */
  33009. static readonly BACKSIDE: number;
  33010. /**
  33011. * Mesh side orientation : both internal and external or front and back surfaces
  33012. */
  33013. static readonly DOUBLESIDE: number;
  33014. /**
  33015. * Mesh side orientation : by default, `FRONTSIDE`
  33016. */
  33017. static readonly DEFAULTSIDE: number;
  33018. /**
  33019. * Mesh cap setting : no cap
  33020. */
  33021. static readonly NO_CAP: number;
  33022. /**
  33023. * Mesh cap setting : one cap at the beginning of the mesh
  33024. */
  33025. static readonly CAP_START: number;
  33026. /**
  33027. * Mesh cap setting : one cap at the end of the mesh
  33028. */
  33029. static readonly CAP_END: number;
  33030. /**
  33031. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33032. */
  33033. static readonly CAP_ALL: number;
  33034. /**
  33035. * Mesh pattern setting : no flip or rotate
  33036. */
  33037. static readonly NO_FLIP: number;
  33038. /**
  33039. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33040. */
  33041. static readonly FLIP_TILE: number;
  33042. /**
  33043. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33044. */
  33045. static readonly ROTATE_TILE: number;
  33046. /**
  33047. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33048. */
  33049. static readonly FLIP_ROW: number;
  33050. /**
  33051. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33052. */
  33053. static readonly ROTATE_ROW: number;
  33054. /**
  33055. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33056. */
  33057. static readonly FLIP_N_ROTATE_TILE: number;
  33058. /**
  33059. * Mesh pattern setting : rotate pattern and rotate
  33060. */
  33061. static readonly FLIP_N_ROTATE_ROW: number;
  33062. /**
  33063. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33064. */
  33065. static readonly CENTER: number;
  33066. /**
  33067. * Mesh tile positioning : part tiles on left
  33068. */
  33069. static readonly LEFT: number;
  33070. /**
  33071. * Mesh tile positioning : part tiles on right
  33072. */
  33073. static readonly RIGHT: number;
  33074. /**
  33075. * Mesh tile positioning : part tiles on top
  33076. */
  33077. static readonly TOP: number;
  33078. /**
  33079. * Mesh tile positioning : part tiles on bottom
  33080. */
  33081. static readonly BOTTOM: number;
  33082. /**
  33083. * Gets the default side orientation.
  33084. * @param orientation the orientation to value to attempt to get
  33085. * @returns the default orientation
  33086. * @hidden
  33087. */
  33088. static _GetDefaultSideOrientation(orientation?: number): number;
  33089. private _internalMeshDataInfo;
  33090. get computeBonesUsingShaders(): boolean;
  33091. set computeBonesUsingShaders(value: boolean);
  33092. /**
  33093. * An event triggered before rendering the mesh
  33094. */
  33095. get onBeforeRenderObservable(): Observable<Mesh>;
  33096. /**
  33097. * An event triggered before binding the mesh
  33098. */
  33099. get onBeforeBindObservable(): Observable<Mesh>;
  33100. /**
  33101. * An event triggered after rendering the mesh
  33102. */
  33103. get onAfterRenderObservable(): Observable<Mesh>;
  33104. /**
  33105. * An event triggered before drawing the mesh
  33106. */
  33107. get onBeforeDrawObservable(): Observable<Mesh>;
  33108. private _onBeforeDrawObserver;
  33109. /**
  33110. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33111. */
  33112. set onBeforeDraw(callback: () => void);
  33113. get hasInstances(): boolean;
  33114. get hasThinInstances(): boolean;
  33115. /**
  33116. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33117. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33118. */
  33119. delayLoadState: number;
  33120. /**
  33121. * Gets the list of instances created from this mesh
  33122. * it is not supposed to be modified manually.
  33123. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33124. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33125. */
  33126. instances: InstancedMesh[];
  33127. /**
  33128. * Gets the file containing delay loading data for this mesh
  33129. */
  33130. delayLoadingFile: string;
  33131. /** @hidden */
  33132. _binaryInfo: any;
  33133. /**
  33134. * User defined function used to change how LOD level selection is done
  33135. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33136. */
  33137. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33138. /**
  33139. * Gets or sets the morph target manager
  33140. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33141. */
  33142. get morphTargetManager(): Nullable<MorphTargetManager>;
  33143. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33144. /** @hidden */
  33145. _creationDataStorage: Nullable<_CreationDataStorage>;
  33146. /** @hidden */
  33147. _geometry: Nullable<Geometry>;
  33148. /** @hidden */
  33149. _delayInfo: Array<string>;
  33150. /** @hidden */
  33151. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33152. /** @hidden */
  33153. _instanceDataStorage: _InstanceDataStorage;
  33154. /** @hidden */
  33155. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33156. private _effectiveMaterial;
  33157. /** @hidden */
  33158. _shouldGenerateFlatShading: boolean;
  33159. /** @hidden */
  33160. _originalBuilderSideOrientation: number;
  33161. /**
  33162. * Use this property to change the original side orientation defined at construction time
  33163. */
  33164. overrideMaterialSideOrientation: Nullable<number>;
  33165. /**
  33166. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33167. * Note this will reduce performance when set to true.
  33168. */
  33169. ignoreCameraMaxZ: boolean;
  33170. /**
  33171. * Gets the source mesh (the one used to clone this one from)
  33172. */
  33173. get source(): Nullable<Mesh>;
  33174. /**
  33175. * Gets the list of clones of this mesh
  33176. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33177. * Note that useClonedMeshMap=true is the default setting
  33178. */
  33179. get cloneMeshMap(): Nullable<{
  33180. [id: string]: Mesh | undefined;
  33181. }>;
  33182. /**
  33183. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33184. */
  33185. get isUnIndexed(): boolean;
  33186. set isUnIndexed(value: boolean);
  33187. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33188. get worldMatrixInstancedBuffer(): Float32Array;
  33189. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33190. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33191. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33192. /**
  33193. * @constructor
  33194. * @param name The value used by scene.getMeshByName() to do a lookup.
  33195. * @param scene The scene to add this mesh to.
  33196. * @param parent The parent of this mesh, if it has one
  33197. * @param source An optional Mesh from which geometry is shared, cloned.
  33198. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33199. * When false, achieved by calling a clone(), also passing False.
  33200. * This will make creation of children, recursive.
  33201. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33202. */
  33203. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33204. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33205. doNotInstantiate: boolean;
  33206. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33207. /**
  33208. * Gets the class name
  33209. * @returns the string "Mesh".
  33210. */
  33211. getClassName(): string;
  33212. /** @hidden */
  33213. get _isMesh(): boolean;
  33214. /**
  33215. * Returns a description of this mesh
  33216. * @param fullDetails define if full details about this mesh must be used
  33217. * @returns a descriptive string representing this mesh
  33218. */
  33219. toString(fullDetails?: boolean): string;
  33220. /** @hidden */
  33221. _unBindEffect(): void;
  33222. /**
  33223. * Gets a boolean indicating if this mesh has LOD
  33224. */
  33225. get hasLODLevels(): boolean;
  33226. /**
  33227. * Gets the list of MeshLODLevel associated with the current mesh
  33228. * @returns an array of MeshLODLevel
  33229. */
  33230. getLODLevels(): MeshLODLevel[];
  33231. private _sortLODLevels;
  33232. /**
  33233. * Add a mesh as LOD level triggered at the given distance.
  33234. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33235. * @param distance The distance from the center of the object to show this level
  33236. * @param mesh The mesh to be added as LOD level (can be null)
  33237. * @return This mesh (for chaining)
  33238. */
  33239. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33240. /**
  33241. * Returns the LOD level mesh at the passed distance or null if not found.
  33242. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33243. * @param distance The distance from the center of the object to show this level
  33244. * @returns a Mesh or `null`
  33245. */
  33246. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33247. /**
  33248. * Remove a mesh from the LOD array
  33249. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33250. * @param mesh defines the mesh to be removed
  33251. * @return This mesh (for chaining)
  33252. */
  33253. removeLODLevel(mesh: Mesh): Mesh;
  33254. /**
  33255. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33256. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33257. * @param camera defines the camera to use to compute distance
  33258. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33259. * @return This mesh (for chaining)
  33260. */
  33261. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33262. /**
  33263. * Gets the mesh internal Geometry object
  33264. */
  33265. get geometry(): Nullable<Geometry>;
  33266. /**
  33267. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33268. * @returns the total number of vertices
  33269. */
  33270. getTotalVertices(): number;
  33271. /**
  33272. * Returns the content of an associated vertex buffer
  33273. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33274. * - VertexBuffer.PositionKind
  33275. * - VertexBuffer.UVKind
  33276. * - VertexBuffer.UV2Kind
  33277. * - VertexBuffer.UV3Kind
  33278. * - VertexBuffer.UV4Kind
  33279. * - VertexBuffer.UV5Kind
  33280. * - VertexBuffer.UV6Kind
  33281. * - VertexBuffer.ColorKind
  33282. * - VertexBuffer.MatricesIndicesKind
  33283. * - VertexBuffer.MatricesIndicesExtraKind
  33284. * - VertexBuffer.MatricesWeightsKind
  33285. * - VertexBuffer.MatricesWeightsExtraKind
  33286. * @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
  33287. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33288. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33289. */
  33290. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33291. /**
  33292. * Returns the mesh VertexBuffer object from the requested `kind`
  33293. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33294. * - VertexBuffer.PositionKind
  33295. * - VertexBuffer.NormalKind
  33296. * - VertexBuffer.UVKind
  33297. * - VertexBuffer.UV2Kind
  33298. * - VertexBuffer.UV3Kind
  33299. * - VertexBuffer.UV4Kind
  33300. * - VertexBuffer.UV5Kind
  33301. * - VertexBuffer.UV6Kind
  33302. * - VertexBuffer.ColorKind
  33303. * - VertexBuffer.MatricesIndicesKind
  33304. * - VertexBuffer.MatricesIndicesExtraKind
  33305. * - VertexBuffer.MatricesWeightsKind
  33306. * - VertexBuffer.MatricesWeightsExtraKind
  33307. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33308. */
  33309. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33310. /**
  33311. * Tests if a specific vertex buffer is associated with this mesh
  33312. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33313. * - VertexBuffer.PositionKind
  33314. * - VertexBuffer.NormalKind
  33315. * - VertexBuffer.UVKind
  33316. * - VertexBuffer.UV2Kind
  33317. * - VertexBuffer.UV3Kind
  33318. * - VertexBuffer.UV4Kind
  33319. * - VertexBuffer.UV5Kind
  33320. * - VertexBuffer.UV6Kind
  33321. * - VertexBuffer.ColorKind
  33322. * - VertexBuffer.MatricesIndicesKind
  33323. * - VertexBuffer.MatricesIndicesExtraKind
  33324. * - VertexBuffer.MatricesWeightsKind
  33325. * - VertexBuffer.MatricesWeightsExtraKind
  33326. * @returns a boolean
  33327. */
  33328. isVerticesDataPresent(kind: string): boolean;
  33329. /**
  33330. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33331. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33332. * - VertexBuffer.PositionKind
  33333. * - VertexBuffer.UVKind
  33334. * - VertexBuffer.UV2Kind
  33335. * - VertexBuffer.UV3Kind
  33336. * - VertexBuffer.UV4Kind
  33337. * - VertexBuffer.UV5Kind
  33338. * - VertexBuffer.UV6Kind
  33339. * - VertexBuffer.ColorKind
  33340. * - VertexBuffer.MatricesIndicesKind
  33341. * - VertexBuffer.MatricesIndicesExtraKind
  33342. * - VertexBuffer.MatricesWeightsKind
  33343. * - VertexBuffer.MatricesWeightsExtraKind
  33344. * @returns a boolean
  33345. */
  33346. isVertexBufferUpdatable(kind: string): boolean;
  33347. /**
  33348. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33349. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33350. * - VertexBuffer.PositionKind
  33351. * - VertexBuffer.NormalKind
  33352. * - VertexBuffer.UVKind
  33353. * - VertexBuffer.UV2Kind
  33354. * - VertexBuffer.UV3Kind
  33355. * - VertexBuffer.UV4Kind
  33356. * - VertexBuffer.UV5Kind
  33357. * - VertexBuffer.UV6Kind
  33358. * - VertexBuffer.ColorKind
  33359. * - VertexBuffer.MatricesIndicesKind
  33360. * - VertexBuffer.MatricesIndicesExtraKind
  33361. * - VertexBuffer.MatricesWeightsKind
  33362. * - VertexBuffer.MatricesWeightsExtraKind
  33363. * @returns an array of strings
  33364. */
  33365. getVerticesDataKinds(): string[];
  33366. /**
  33367. * Returns a positive integer : the total number of indices in this mesh geometry.
  33368. * @returns the numner of indices or zero if the mesh has no geometry.
  33369. */
  33370. getTotalIndices(): number;
  33371. /**
  33372. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33373. * @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.
  33374. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33375. * @returns the indices array or an empty array if the mesh has no geometry
  33376. */
  33377. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33378. get isBlocked(): boolean;
  33379. /**
  33380. * Determine if the current mesh is ready to be rendered
  33381. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33382. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33383. * @returns true if all associated assets are ready (material, textures, shaders)
  33384. */
  33385. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33386. /**
  33387. * 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.
  33388. */
  33389. get areNormalsFrozen(): boolean;
  33390. /**
  33391. * 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.
  33392. * @returns the current mesh
  33393. */
  33394. freezeNormals(): Mesh;
  33395. /**
  33396. * 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
  33397. * @returns the current mesh
  33398. */
  33399. unfreezeNormals(): Mesh;
  33400. /**
  33401. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33402. */
  33403. set overridenInstanceCount(count: number);
  33404. /** @hidden */
  33405. _preActivate(): Mesh;
  33406. /** @hidden */
  33407. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33408. /** @hidden */
  33409. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33410. protected _afterComputeWorldMatrix(): void;
  33411. /** @hidden */
  33412. _postActivate(): void;
  33413. /**
  33414. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33415. * This means the mesh underlying bounding box and sphere are recomputed.
  33416. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33417. * @returns the current mesh
  33418. */
  33419. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33420. /** @hidden */
  33421. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33422. /**
  33423. * This function will subdivide the mesh into multiple submeshes
  33424. * @param count defines the expected number of submeshes
  33425. */
  33426. subdivide(count: number): void;
  33427. /**
  33428. * Copy a FloatArray into a specific associated vertex buffer
  33429. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33430. * - VertexBuffer.PositionKind
  33431. * - VertexBuffer.UVKind
  33432. * - VertexBuffer.UV2Kind
  33433. * - VertexBuffer.UV3Kind
  33434. * - VertexBuffer.UV4Kind
  33435. * - VertexBuffer.UV5Kind
  33436. * - VertexBuffer.UV6Kind
  33437. * - VertexBuffer.ColorKind
  33438. * - VertexBuffer.MatricesIndicesKind
  33439. * - VertexBuffer.MatricesIndicesExtraKind
  33440. * - VertexBuffer.MatricesWeightsKind
  33441. * - VertexBuffer.MatricesWeightsExtraKind
  33442. * @param data defines the data source
  33443. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33444. * @param stride defines the data stride size (can be null)
  33445. * @returns the current mesh
  33446. */
  33447. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33448. /**
  33449. * Delete a vertex buffer associated with this mesh
  33450. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33451. * - VertexBuffer.PositionKind
  33452. * - VertexBuffer.UVKind
  33453. * - VertexBuffer.UV2Kind
  33454. * - VertexBuffer.UV3Kind
  33455. * - VertexBuffer.UV4Kind
  33456. * - VertexBuffer.UV5Kind
  33457. * - VertexBuffer.UV6Kind
  33458. * - VertexBuffer.ColorKind
  33459. * - VertexBuffer.MatricesIndicesKind
  33460. * - VertexBuffer.MatricesIndicesExtraKind
  33461. * - VertexBuffer.MatricesWeightsKind
  33462. * - VertexBuffer.MatricesWeightsExtraKind
  33463. */
  33464. removeVerticesData(kind: string): void;
  33465. /**
  33466. * Flags an associated vertex buffer as updatable
  33467. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33468. * - VertexBuffer.PositionKind
  33469. * - VertexBuffer.UVKind
  33470. * - VertexBuffer.UV2Kind
  33471. * - VertexBuffer.UV3Kind
  33472. * - VertexBuffer.UV4Kind
  33473. * - VertexBuffer.UV5Kind
  33474. * - VertexBuffer.UV6Kind
  33475. * - VertexBuffer.ColorKind
  33476. * - VertexBuffer.MatricesIndicesKind
  33477. * - VertexBuffer.MatricesIndicesExtraKind
  33478. * - VertexBuffer.MatricesWeightsKind
  33479. * - VertexBuffer.MatricesWeightsExtraKind
  33480. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33481. */
  33482. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33483. /**
  33484. * Sets the mesh global Vertex Buffer
  33485. * @param buffer defines the buffer to use
  33486. * @returns the current mesh
  33487. */
  33488. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33489. /**
  33490. * Update a specific associated vertex buffer
  33491. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33492. * - VertexBuffer.PositionKind
  33493. * - VertexBuffer.UVKind
  33494. * - VertexBuffer.UV2Kind
  33495. * - VertexBuffer.UV3Kind
  33496. * - VertexBuffer.UV4Kind
  33497. * - VertexBuffer.UV5Kind
  33498. * - VertexBuffer.UV6Kind
  33499. * - VertexBuffer.ColorKind
  33500. * - VertexBuffer.MatricesIndicesKind
  33501. * - VertexBuffer.MatricesIndicesExtraKind
  33502. * - VertexBuffer.MatricesWeightsKind
  33503. * - VertexBuffer.MatricesWeightsExtraKind
  33504. * @param data defines the data source
  33505. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33506. * @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)
  33507. * @returns the current mesh
  33508. */
  33509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33510. /**
  33511. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33512. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33513. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33514. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33515. * @returns the current mesh
  33516. */
  33517. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33518. /**
  33519. * Creates a un-shared specific occurence of the geometry for the mesh.
  33520. * @returns the current mesh
  33521. */
  33522. makeGeometryUnique(): Mesh;
  33523. /**
  33524. * Set the index buffer of this mesh
  33525. * @param indices defines the source data
  33526. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33527. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33528. * @returns the current mesh
  33529. */
  33530. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33531. /**
  33532. * Update the current index buffer
  33533. * @param indices defines the source data
  33534. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33535. * @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)
  33536. * @returns the current mesh
  33537. */
  33538. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33539. /**
  33540. * Invert the geometry to move from a right handed system to a left handed one.
  33541. * @returns the current mesh
  33542. */
  33543. toLeftHanded(): Mesh;
  33544. /** @hidden */
  33545. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33546. /** @hidden */
  33547. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33548. /**
  33549. * Registers for this mesh a javascript function called just before the rendering process
  33550. * @param func defines the function to call before rendering this mesh
  33551. * @returns the current mesh
  33552. */
  33553. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33554. /**
  33555. * Disposes a previously registered javascript function called before the rendering
  33556. * @param func defines the function to remove
  33557. * @returns the current mesh
  33558. */
  33559. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33560. /**
  33561. * Registers for this mesh a javascript function called just after the rendering is complete
  33562. * @param func defines the function to call after rendering this mesh
  33563. * @returns the current mesh
  33564. */
  33565. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33566. /**
  33567. * Disposes a previously registered javascript function called after the rendering.
  33568. * @param func defines the function to remove
  33569. * @returns the current mesh
  33570. */
  33571. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33572. /** @hidden */
  33573. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33574. /** @hidden */
  33575. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33576. /** @hidden */
  33577. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33578. /** @hidden */
  33579. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33580. /** @hidden */
  33581. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33582. /** @hidden */
  33583. _rebuild(): void;
  33584. /** @hidden */
  33585. _freeze(): void;
  33586. /** @hidden */
  33587. _unFreeze(): void;
  33588. /**
  33589. * 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
  33590. * @param subMesh defines the subMesh to render
  33591. * @param enableAlphaMode defines if alpha mode can be changed
  33592. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33593. * @returns the current mesh
  33594. */
  33595. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33596. private _onBeforeDraw;
  33597. /**
  33598. * Renormalize the mesh and patch it up if there are no weights
  33599. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33600. * However in the case of zero weights then we set just a single influence to 1.
  33601. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33602. */
  33603. cleanMatrixWeights(): void;
  33604. private normalizeSkinFourWeights;
  33605. private normalizeSkinWeightsAndExtra;
  33606. /**
  33607. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33608. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33609. * the user know there was an issue with importing the mesh
  33610. * @returns a validation object with skinned, valid and report string
  33611. */
  33612. validateSkinning(): {
  33613. skinned: boolean;
  33614. valid: boolean;
  33615. report: string;
  33616. };
  33617. /** @hidden */
  33618. _checkDelayState(): Mesh;
  33619. private _queueLoad;
  33620. /**
  33621. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33622. * A mesh is in the frustum if its bounding box intersects the frustum
  33623. * @param frustumPlanes defines the frustum to test
  33624. * @returns true if the mesh is in the frustum planes
  33625. */
  33626. isInFrustum(frustumPlanes: Plane[]): boolean;
  33627. /**
  33628. * Sets the mesh material by the material or multiMaterial `id` property
  33629. * @param id is a string identifying the material or the multiMaterial
  33630. * @returns the current mesh
  33631. */
  33632. setMaterialByID(id: string): Mesh;
  33633. /**
  33634. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33635. * @returns an array of IAnimatable
  33636. */
  33637. getAnimatables(): IAnimatable[];
  33638. /**
  33639. * Modifies the mesh geometry according to the passed transformation matrix.
  33640. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33641. * The mesh normals are modified using the same transformation.
  33642. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33643. * @param transform defines the transform matrix to use
  33644. * @see https://doc.babylonjs.com/resources/baking_transformations
  33645. * @returns the current mesh
  33646. */
  33647. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33648. /**
  33649. * Modifies the mesh geometry according to its own current World Matrix.
  33650. * The mesh World Matrix is then reset.
  33651. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33652. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33653. * @see https://doc.babylonjs.com/resources/baking_transformations
  33654. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33655. * @returns the current mesh
  33656. */
  33657. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33658. /** @hidden */
  33659. get _positions(): Nullable<Vector3[]>;
  33660. /** @hidden */
  33661. _resetPointsArrayCache(): Mesh;
  33662. /** @hidden */
  33663. _generatePointsArray(): boolean;
  33664. /**
  33665. * Returns a new Mesh object generated from the current mesh properties.
  33666. * This method must not get confused with createInstance()
  33667. * @param name is a string, the name given to the new mesh
  33668. * @param newParent can be any Node object (default `null`)
  33669. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33670. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33671. * @returns a new mesh
  33672. */
  33673. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33674. /**
  33675. * Releases resources associated with this mesh.
  33676. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33677. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33678. */
  33679. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33680. /** @hidden */
  33681. _disposeInstanceSpecificData(): void;
  33682. /** @hidden */
  33683. _disposeThinInstanceSpecificData(): void;
  33684. /**
  33685. * Modifies the mesh geometry according to a displacement map.
  33686. * 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.
  33687. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33688. * @param url is a string, the URL from the image file is to be downloaded.
  33689. * @param minHeight is the lower limit of the displacement.
  33690. * @param maxHeight is the upper limit of the displacement.
  33691. * @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.
  33692. * @param uvOffset is an optional vector2 used to offset UV.
  33693. * @param uvScale is an optional vector2 used to scale UV.
  33694. * @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.
  33695. * @returns the Mesh.
  33696. */
  33697. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33698. /**
  33699. * Modifies the mesh geometry according to a displacementMap buffer.
  33700. * 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.
  33701. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33702. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33703. * @param heightMapWidth is the width of the buffer image.
  33704. * @param heightMapHeight is the height of the buffer image.
  33705. * @param minHeight is the lower limit of the displacement.
  33706. * @param maxHeight is the upper limit of the displacement.
  33707. * @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.
  33708. * @param uvOffset is an optional vector2 used to offset UV.
  33709. * @param uvScale is an optional vector2 used to scale UV.
  33710. * @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.
  33711. * @returns the Mesh.
  33712. */
  33713. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33714. /**
  33715. * Modify the mesh to get a flat shading rendering.
  33716. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33717. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33718. * @returns current mesh
  33719. */
  33720. convertToFlatShadedMesh(): Mesh;
  33721. /**
  33722. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33723. * In other words, more vertices, no more indices and a single bigger VBO.
  33724. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33725. * @returns current mesh
  33726. */
  33727. convertToUnIndexedMesh(): Mesh;
  33728. /**
  33729. * Inverses facet orientations.
  33730. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33731. * @param flipNormals will also inverts the normals
  33732. * @returns current mesh
  33733. */
  33734. flipFaces(flipNormals?: boolean): Mesh;
  33735. /**
  33736. * Increase the number of facets and hence vertices in a mesh
  33737. * Vertex normals are interpolated from existing vertex normals
  33738. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33739. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33740. */
  33741. increaseVertices(numberPerEdge: number): void;
  33742. /**
  33743. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33744. * This will undo any application of covertToFlatShadedMesh
  33745. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33746. */
  33747. forceSharedVertices(): void;
  33748. /** @hidden */
  33749. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33750. /** @hidden */
  33751. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33752. /**
  33753. * Creates a new InstancedMesh object from the mesh model.
  33754. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33755. * @param name defines the name of the new instance
  33756. * @returns a new InstancedMesh
  33757. */
  33758. createInstance(name: string): InstancedMesh;
  33759. /**
  33760. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33761. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33762. * @returns the current mesh
  33763. */
  33764. synchronizeInstances(): Mesh;
  33765. /**
  33766. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33767. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33768. * This should be used together with the simplification to avoid disappearing triangles.
  33769. * @param successCallback an optional success callback to be called after the optimization finished.
  33770. * @returns the current mesh
  33771. */
  33772. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33773. /**
  33774. * Serialize current mesh
  33775. * @param serializationObject defines the object which will receive the serialization data
  33776. */
  33777. serialize(serializationObject: any): void;
  33778. /** @hidden */
  33779. _syncGeometryWithMorphTargetManager(): void;
  33780. /** @hidden */
  33781. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33782. /**
  33783. * Returns a new Mesh object parsed from the source provided.
  33784. * @param parsedMesh is the source
  33785. * @param scene defines the hosting scene
  33786. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33787. * @returns a new Mesh
  33788. */
  33789. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33790. /**
  33791. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33793. * @param name defines the name of the mesh to create
  33794. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33795. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33796. * @param closePath creates a seam between the first and the last points of each path of the path array
  33797. * @param offset is taken in account only if the `pathArray` is containing a single path
  33798. * @param scene defines the hosting scene
  33799. * @param updatable defines if the mesh must be flagged as updatable
  33800. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33801. * @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)
  33802. * @returns a new Mesh
  33803. */
  33804. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33805. /**
  33806. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33807. * @param name defines the name of the mesh to create
  33808. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33809. * @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
  33810. * @param scene defines the hosting scene
  33811. * @param updatable defines if the mesh must be flagged as updatable
  33812. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33813. * @returns a new Mesh
  33814. */
  33815. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33816. /**
  33817. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33818. * @param name defines the name of the mesh to create
  33819. * @param size sets the size (float) of each box side (default 1)
  33820. * @param scene defines the hosting scene
  33821. * @param updatable defines if the mesh must be flagged as updatable
  33822. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33823. * @returns a new Mesh
  33824. */
  33825. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33826. /**
  33827. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33828. * @param name defines the name of the mesh to create
  33829. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33830. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33831. * @param scene defines the hosting scene
  33832. * @param updatable defines if the mesh must be flagged as updatable
  33833. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33834. * @returns a new Mesh
  33835. */
  33836. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33837. /**
  33838. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33839. * @param name defines the name of the mesh to create
  33840. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33841. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33842. * @param scene defines the hosting scene
  33843. * @returns a new Mesh
  33844. */
  33845. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33846. /**
  33847. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33848. * @param name defines the name of the mesh to create
  33849. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33850. * @param diameterTop set the top cap diameter (floats, default 1)
  33851. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33852. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33853. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33854. * @param scene defines the hosting scene
  33855. * @param updatable defines if the mesh must be flagged as updatable
  33856. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33857. * @returns a new Mesh
  33858. */
  33859. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33860. /**
  33861. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33862. * @param name defines the name of the mesh to create
  33863. * @param diameter sets the diameter size (float) of the torus (default 1)
  33864. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33865. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33866. * @param scene defines the hosting scene
  33867. * @param updatable defines if the mesh must be flagged as updatable
  33868. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33869. * @returns a new Mesh
  33870. */
  33871. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33872. /**
  33873. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33874. * @param name defines the name of the mesh to create
  33875. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33876. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33877. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33878. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33879. * @param p the number of windings on X axis (positive integers, default 2)
  33880. * @param q the number of windings on Y axis (positive integers, default 3)
  33881. * @param scene defines the hosting scene
  33882. * @param updatable defines if the mesh must be flagged as updatable
  33883. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33884. * @returns a new Mesh
  33885. */
  33886. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33887. /**
  33888. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33889. * @param name defines the name of the mesh to create
  33890. * @param points is an array successive Vector3
  33891. * @param scene defines the hosting scene
  33892. * @param updatable defines if the mesh must be flagged as updatable
  33893. * @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).
  33894. * @returns a new Mesh
  33895. */
  33896. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33897. /**
  33898. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33899. * @param name defines the name of the mesh to create
  33900. * @param points is an array successive Vector3
  33901. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33902. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33903. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33904. * @param scene defines the hosting scene
  33905. * @param updatable defines if the mesh must be flagged as updatable
  33906. * @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)
  33907. * @returns a new Mesh
  33908. */
  33909. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33910. /**
  33911. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33912. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33913. * 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.
  33914. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33915. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33916. * Remember you can only change the shape positions, not their number when updating a polygon.
  33917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33918. * @param name defines the name of the mesh to create
  33919. * @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
  33920. * @param scene defines the hosting scene
  33921. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33922. * @param updatable defines if the mesh must be flagged as updatable
  33923. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33924. * @param earcutInjection can be used to inject your own earcut reference
  33925. * @returns a new Mesh
  33926. */
  33927. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33928. /**
  33929. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33931. * @param name defines the name of the mesh to create
  33932. * @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
  33933. * @param depth defines the height of extrusion
  33934. * @param scene defines the hosting scene
  33935. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33936. * @param updatable defines if the mesh must be flagged as updatable
  33937. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33938. * @param earcutInjection can be used to inject your own earcut reference
  33939. * @returns a new Mesh
  33940. */
  33941. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33942. /**
  33943. * Creates an extruded shape mesh.
  33944. * 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
  33945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33947. * @param name defines the name of the mesh to create
  33948. * @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
  33949. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33950. * @param scale is the value to scale the shape
  33951. * @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
  33952. * @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
  33953. * @param scene defines the hosting scene
  33954. * @param updatable defines if the mesh must be flagged as updatable
  33955. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33956. * @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)
  33957. * @returns a new Mesh
  33958. */
  33959. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33960. /**
  33961. * Creates an custom extruded shape mesh.
  33962. * The custom extrusion is a parametric shape.
  33963. * It has no predefined shape. Its final shape will depend on the input parameters.
  33964. * Please consider using the same method from the MeshBuilder class instead
  33965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33966. * @param name defines the name of the mesh to create
  33967. * @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
  33968. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33969. * @param scaleFunction is a custom Javascript function called on each path point
  33970. * @param rotationFunction is a custom Javascript function called on each path point
  33971. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33972. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33973. * @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
  33974. * @param scene defines the hosting scene
  33975. * @param updatable defines if the mesh must be flagged as updatable
  33976. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33977. * @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)
  33978. * @returns a new Mesh
  33979. */
  33980. 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;
  33981. /**
  33982. * Creates lathe mesh.
  33983. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33984. * Please consider using the same method from the MeshBuilder class instead
  33985. * @param name defines the name of the mesh to create
  33986. * @param 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
  33987. * @param radius is the radius value of the lathe
  33988. * @param tessellation is the side number of the lathe.
  33989. * @param scene defines the hosting scene
  33990. * @param updatable defines if the mesh must be flagged as updatable
  33991. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33992. * @returns a new Mesh
  33993. */
  33994. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33995. /**
  33996. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33997. * @param name defines the name of the mesh to create
  33998. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33999. * @param scene defines the hosting scene
  34000. * @param updatable defines if the mesh must be flagged as updatable
  34001. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34002. * @returns a new Mesh
  34003. */
  34004. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34005. /**
  34006. * Creates a ground mesh.
  34007. * Please consider using the same method from the MeshBuilder class instead
  34008. * @param name defines the name of the mesh to create
  34009. * @param width set the width of the ground
  34010. * @param height set the height of the ground
  34011. * @param subdivisions sets the number of subdivisions per side
  34012. * @param scene defines the hosting scene
  34013. * @param updatable defines if the mesh must be flagged as updatable
  34014. * @returns a new Mesh
  34015. */
  34016. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34017. /**
  34018. * Creates a tiled ground mesh.
  34019. * Please consider using the same method from the MeshBuilder class instead
  34020. * @param name defines the name of the mesh to create
  34021. * @param xmin set the ground minimum X coordinate
  34022. * @param zmin set the ground minimum Y coordinate
  34023. * @param xmax set the ground maximum X coordinate
  34024. * @param zmax set the ground maximum Z coordinate
  34025. * @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
  34026. * @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
  34027. * @param scene defines the hosting scene
  34028. * @param updatable defines if the mesh must be flagged as updatable
  34029. * @returns a new Mesh
  34030. */
  34031. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34032. w: number;
  34033. h: number;
  34034. }, precision: {
  34035. w: number;
  34036. h: number;
  34037. }, scene: Scene, updatable?: boolean): Mesh;
  34038. /**
  34039. * Creates a ground mesh from a height map.
  34040. * Please consider using the same method from the MeshBuilder class instead
  34041. * @see https://doc.babylonjs.com/babylon101/height_map
  34042. * @param name defines the name of the mesh to create
  34043. * @param url sets the URL of the height map image resource
  34044. * @param width set the ground width size
  34045. * @param height set the ground height size
  34046. * @param subdivisions sets the number of subdivision per side
  34047. * @param minHeight is the minimum altitude on the ground
  34048. * @param maxHeight is the maximum altitude on the ground
  34049. * @param scene defines the hosting scene
  34050. * @param updatable defines if the mesh must be flagged as updatable
  34051. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34052. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34053. * @returns a new Mesh
  34054. */
  34055. 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;
  34056. /**
  34057. * Creates a tube mesh.
  34058. * The tube is a parametric shape.
  34059. * It has no predefined shape. Its final shape will depend on the input parameters.
  34060. * Please consider using the same method from the MeshBuilder class instead
  34061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34062. * @param name defines the name of the mesh to create
  34063. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34064. * @param radius sets the tube radius size
  34065. * @param tessellation is the number of sides on the tubular surface
  34066. * @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
  34067. * @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
  34068. * @param scene defines the hosting scene
  34069. * @param updatable defines if the mesh must be flagged as updatable
  34070. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34071. * @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)
  34072. * @returns a new Mesh
  34073. */
  34074. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34075. (i: number, distance: number): number;
  34076. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34077. /**
  34078. * Creates a polyhedron mesh.
  34079. * Please consider using the same method from the MeshBuilder class instead.
  34080. * * 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
  34081. * * The parameter `size` (positive float, default 1) sets the polygon size
  34082. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34083. * * 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`
  34084. * * 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
  34085. * * 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)`)
  34086. * * 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
  34087. * * 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
  34088. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34089. * * 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
  34090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34091. * @param name defines the name of the mesh to create
  34092. * @param options defines the options used to create the mesh
  34093. * @param scene defines the hosting scene
  34094. * @returns a new Mesh
  34095. */
  34096. static CreatePolyhedron(name: string, options: {
  34097. type?: number;
  34098. size?: number;
  34099. sizeX?: number;
  34100. sizeY?: number;
  34101. sizeZ?: number;
  34102. custom?: any;
  34103. faceUV?: Vector4[];
  34104. faceColors?: Color4[];
  34105. updatable?: boolean;
  34106. sideOrientation?: number;
  34107. }, scene: Scene): Mesh;
  34108. /**
  34109. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34110. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34111. * * 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`)
  34112. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34113. * * 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
  34114. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34115. * * 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
  34116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34117. * @param name defines the name of the mesh
  34118. * @param options defines the options used to create the mesh
  34119. * @param scene defines the hosting scene
  34120. * @returns a new Mesh
  34121. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34122. */
  34123. static CreateIcoSphere(name: string, options: {
  34124. radius?: number;
  34125. flat?: boolean;
  34126. subdivisions?: number;
  34127. sideOrientation?: number;
  34128. updatable?: boolean;
  34129. }, scene: Scene): Mesh;
  34130. /**
  34131. * Creates a decal mesh.
  34132. * Please consider using the same method from the MeshBuilder class instead.
  34133. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34134. * @param name defines the name of the mesh
  34135. * @param sourceMesh defines the mesh receiving the decal
  34136. * @param position sets the position of the decal in world coordinates
  34137. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34138. * @param size sets the decal scaling
  34139. * @param angle sets the angle to rotate the decal
  34140. * @returns a new Mesh
  34141. */
  34142. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34143. /** Creates a Capsule Mesh
  34144. * @param name defines the name of the mesh.
  34145. * @param options the constructors options used to shape the mesh.
  34146. * @param scene defines the scene the mesh is scoped to.
  34147. * @returns the capsule mesh
  34148. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34149. */
  34150. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34151. /**
  34152. * Prepare internal position array for software CPU skinning
  34153. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34154. */
  34155. setPositionsForCPUSkinning(): Float32Array;
  34156. /**
  34157. * Prepare internal normal array for software CPU skinning
  34158. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34159. */
  34160. setNormalsForCPUSkinning(): Float32Array;
  34161. /**
  34162. * Updates the vertex buffer by applying transformation from the bones
  34163. * @param skeleton defines the skeleton to apply to current mesh
  34164. * @returns the current mesh
  34165. */
  34166. applySkeleton(skeleton: Skeleton): Mesh;
  34167. /**
  34168. * 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
  34169. * @param meshes defines the list of meshes to scan
  34170. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34171. */
  34172. static MinMax(meshes: AbstractMesh[]): {
  34173. min: Vector3;
  34174. max: Vector3;
  34175. };
  34176. /**
  34177. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34178. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34179. * @returns a vector3
  34180. */
  34181. static Center(meshesOrMinMaxVector: {
  34182. min: Vector3;
  34183. max: Vector3;
  34184. } | AbstractMesh[]): Vector3;
  34185. /**
  34186. * Merge the array of meshes into a single mesh for performance reasons.
  34187. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34188. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34189. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34190. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34191. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34192. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34193. * @returns a new mesh
  34194. */
  34195. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34196. /** @hidden */
  34197. addInstance(instance: InstancedMesh): void;
  34198. /** @hidden */
  34199. removeInstance(instance: InstancedMesh): void;
  34200. }
  34201. }
  34202. declare module BABYLON {
  34203. /**
  34204. * The options Interface for creating a Capsule Mesh
  34205. */
  34206. export interface ICreateCapsuleOptions {
  34207. /** The Orientation of the capsule. Default : Vector3.Up() */
  34208. orientation?: Vector3;
  34209. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34210. subdivisions: number;
  34211. /** Number of cylindrical segments on the capsule. */
  34212. tessellation: number;
  34213. /** Height or Length of the capsule. */
  34214. height: number;
  34215. /** Radius of the capsule. */
  34216. radius: number;
  34217. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34218. capSubdivisions: number;
  34219. /** Overwrite for the top radius. */
  34220. radiusTop?: number;
  34221. /** Overwrite for the bottom radius. */
  34222. radiusBottom?: number;
  34223. /** Overwrite for the top capSubdivisions. */
  34224. topCapSubdivisions?: number;
  34225. /** Overwrite for the bottom capSubdivisions. */
  34226. bottomCapSubdivisions?: number;
  34227. }
  34228. /**
  34229. * Class containing static functions to help procedurally build meshes
  34230. */
  34231. export class CapsuleBuilder {
  34232. /**
  34233. * Creates a capsule or a pill mesh
  34234. * @param name defines the name of the mesh
  34235. * @param options The constructors options.
  34236. * @param scene The scene the mesh is scoped to.
  34237. * @returns Capsule Mesh
  34238. */
  34239. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34240. }
  34241. }
  34242. declare module BABYLON {
  34243. /**
  34244. * Define an interface for all classes that will get and set the data on vertices
  34245. */
  34246. export interface IGetSetVerticesData {
  34247. /**
  34248. * Gets a boolean indicating if specific vertex data is present
  34249. * @param kind defines the vertex data kind to use
  34250. * @returns true is data kind is present
  34251. */
  34252. isVerticesDataPresent(kind: string): boolean;
  34253. /**
  34254. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34255. * @param kind defines the data kind (Position, normal, etc...)
  34256. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34257. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34258. * @returns a float array containing vertex data
  34259. */
  34260. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34261. /**
  34262. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34263. * @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.
  34264. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34265. * @returns the indices array or an empty array if the mesh has no geometry
  34266. */
  34267. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34268. /**
  34269. * Set specific vertex data
  34270. * @param kind defines the data kind (Position, normal, etc...)
  34271. * @param data defines the vertex data to use
  34272. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34273. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34274. */
  34275. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34276. /**
  34277. * Update a specific associated vertex buffer
  34278. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34279. * - VertexBuffer.PositionKind
  34280. * - VertexBuffer.UVKind
  34281. * - VertexBuffer.UV2Kind
  34282. * - VertexBuffer.UV3Kind
  34283. * - VertexBuffer.UV4Kind
  34284. * - VertexBuffer.UV5Kind
  34285. * - VertexBuffer.UV6Kind
  34286. * - VertexBuffer.ColorKind
  34287. * - VertexBuffer.MatricesIndicesKind
  34288. * - VertexBuffer.MatricesIndicesExtraKind
  34289. * - VertexBuffer.MatricesWeightsKind
  34290. * - VertexBuffer.MatricesWeightsExtraKind
  34291. * @param data defines the data source
  34292. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34293. * @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)
  34294. */
  34295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34296. /**
  34297. * Creates a new index buffer
  34298. * @param indices defines the indices to store in the index buffer
  34299. * @param totalVertices defines the total number of vertices (could be null)
  34300. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34301. */
  34302. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34303. }
  34304. /**
  34305. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34306. */
  34307. export class VertexData {
  34308. /**
  34309. * Mesh side orientation : usually the external or front surface
  34310. */
  34311. static readonly FRONTSIDE: number;
  34312. /**
  34313. * Mesh side orientation : usually the internal or back surface
  34314. */
  34315. static readonly BACKSIDE: number;
  34316. /**
  34317. * Mesh side orientation : both internal and external or front and back surfaces
  34318. */
  34319. static readonly DOUBLESIDE: number;
  34320. /**
  34321. * Mesh side orientation : by default, `FRONTSIDE`
  34322. */
  34323. static readonly DEFAULTSIDE: number;
  34324. /**
  34325. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34326. */
  34327. positions: Nullable<FloatArray>;
  34328. /**
  34329. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34330. */
  34331. normals: Nullable<FloatArray>;
  34332. /**
  34333. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34334. */
  34335. tangents: Nullable<FloatArray>;
  34336. /**
  34337. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34338. */
  34339. uvs: Nullable<FloatArray>;
  34340. /**
  34341. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34342. */
  34343. uvs2: Nullable<FloatArray>;
  34344. /**
  34345. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34346. */
  34347. uvs3: Nullable<FloatArray>;
  34348. /**
  34349. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34350. */
  34351. uvs4: Nullable<FloatArray>;
  34352. /**
  34353. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34354. */
  34355. uvs5: Nullable<FloatArray>;
  34356. /**
  34357. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34358. */
  34359. uvs6: Nullable<FloatArray>;
  34360. /**
  34361. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34362. */
  34363. colors: Nullable<FloatArray>;
  34364. /**
  34365. * 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).
  34366. */
  34367. matricesIndices: Nullable<FloatArray>;
  34368. /**
  34369. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34370. */
  34371. matricesWeights: Nullable<FloatArray>;
  34372. /**
  34373. * An array extending the number of possible indices
  34374. */
  34375. matricesIndicesExtra: Nullable<FloatArray>;
  34376. /**
  34377. * An array extending the number of possible weights when the number of indices is extended
  34378. */
  34379. matricesWeightsExtra: Nullable<FloatArray>;
  34380. /**
  34381. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34382. */
  34383. indices: Nullable<IndicesArray>;
  34384. /**
  34385. * Uses the passed data array to set the set the values for the specified kind of data
  34386. * @param data a linear array of floating numbers
  34387. * @param kind the type of data that is being set, eg positions, colors etc
  34388. */
  34389. set(data: FloatArray, kind: string): void;
  34390. /**
  34391. * Associates the vertexData to the passed Mesh.
  34392. * Sets it as updatable or not (default `false`)
  34393. * @param mesh the mesh the vertexData is applied to
  34394. * @param updatable when used and having the value true allows new data to update the vertexData
  34395. * @returns the VertexData
  34396. */
  34397. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34398. /**
  34399. * Associates the vertexData to the passed Geometry.
  34400. * Sets it as updatable or not (default `false`)
  34401. * @param geometry the geometry the vertexData is applied to
  34402. * @param updatable when used and having the value true allows new data to update the vertexData
  34403. * @returns VertexData
  34404. */
  34405. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34406. /**
  34407. * Updates the associated mesh
  34408. * @param mesh the mesh to be updated
  34409. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34410. * @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
  34411. * @returns VertexData
  34412. */
  34413. updateMesh(mesh: Mesh): VertexData;
  34414. /**
  34415. * Updates the associated geometry
  34416. * @param geometry the geometry to be updated
  34417. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34418. * @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
  34419. * @returns VertexData.
  34420. */
  34421. updateGeometry(geometry: Geometry): VertexData;
  34422. private _applyTo;
  34423. private _update;
  34424. /**
  34425. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34426. * @param matrix the transforming matrix
  34427. * @returns the VertexData
  34428. */
  34429. transform(matrix: Matrix): VertexData;
  34430. /**
  34431. * Merges the passed VertexData into the current one
  34432. * @param other the VertexData to be merged into the current one
  34433. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34434. * @returns the modified VertexData
  34435. */
  34436. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34437. private _mergeElement;
  34438. private _validate;
  34439. /**
  34440. * Serializes the VertexData
  34441. * @returns a serialized object
  34442. */
  34443. serialize(): any;
  34444. /**
  34445. * Extracts the vertexData from a mesh
  34446. * @param mesh the mesh from which to extract the VertexData
  34447. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34448. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34449. * @returns the object VertexData associated to the passed mesh
  34450. */
  34451. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34452. /**
  34453. * Extracts the vertexData from the geometry
  34454. * @param geometry the geometry from which to extract the VertexData
  34455. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34456. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34457. * @returns the object VertexData associated to the passed mesh
  34458. */
  34459. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34460. private static _ExtractFrom;
  34461. /**
  34462. * Creates the VertexData for a Ribbon
  34463. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34464. * * pathArray array of paths, each of which an array of successive Vector3
  34465. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34466. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34467. * * 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
  34468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34469. * * 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)
  34470. * * 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)
  34471. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34472. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34473. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34474. * @returns the VertexData of the ribbon
  34475. */
  34476. static CreateRibbon(options: {
  34477. pathArray: Vector3[][];
  34478. closeArray?: boolean;
  34479. closePath?: boolean;
  34480. offset?: number;
  34481. sideOrientation?: number;
  34482. frontUVs?: Vector4;
  34483. backUVs?: Vector4;
  34484. invertUV?: boolean;
  34485. uvs?: Vector2[];
  34486. colors?: Color4[];
  34487. }): VertexData;
  34488. /**
  34489. * Creates the VertexData for a box
  34490. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34491. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34492. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34493. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34494. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34495. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34496. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34498. * * 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)
  34499. * * 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)
  34500. * @returns the VertexData of the box
  34501. */
  34502. static CreateBox(options: {
  34503. size?: number;
  34504. width?: number;
  34505. height?: number;
  34506. depth?: number;
  34507. faceUV?: Vector4[];
  34508. faceColors?: Color4[];
  34509. sideOrientation?: number;
  34510. frontUVs?: Vector4;
  34511. backUVs?: Vector4;
  34512. }): VertexData;
  34513. /**
  34514. * Creates the VertexData for a tiled box
  34515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34516. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34517. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34518. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34520. * @returns the VertexData of the box
  34521. */
  34522. static CreateTiledBox(options: {
  34523. pattern?: number;
  34524. width?: number;
  34525. height?: number;
  34526. depth?: number;
  34527. tileSize?: number;
  34528. tileWidth?: number;
  34529. tileHeight?: number;
  34530. alignHorizontal?: number;
  34531. alignVertical?: number;
  34532. faceUV?: Vector4[];
  34533. faceColors?: Color4[];
  34534. sideOrientation?: number;
  34535. }): VertexData;
  34536. /**
  34537. * Creates the VertexData for a tiled plane
  34538. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34539. * * pattern a limited pattern arrangement depending on the number
  34540. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34541. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34542. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34543. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34544. * * 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)
  34545. * * 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)
  34546. * @returns the VertexData of the tiled plane
  34547. */
  34548. static CreateTiledPlane(options: {
  34549. pattern?: number;
  34550. tileSize?: number;
  34551. tileWidth?: number;
  34552. tileHeight?: number;
  34553. size?: number;
  34554. width?: number;
  34555. height?: number;
  34556. alignHorizontal?: number;
  34557. alignVertical?: number;
  34558. sideOrientation?: number;
  34559. frontUVs?: Vector4;
  34560. backUVs?: Vector4;
  34561. }): VertexData;
  34562. /**
  34563. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34564. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34565. * * segments sets the number of horizontal strips optional, default 32
  34566. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34567. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34568. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34569. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34570. * * 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
  34571. * * 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
  34572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34573. * * 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)
  34574. * * 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)
  34575. * @returns the VertexData of the ellipsoid
  34576. */
  34577. static CreateSphere(options: {
  34578. segments?: number;
  34579. diameter?: number;
  34580. diameterX?: number;
  34581. diameterY?: number;
  34582. diameterZ?: number;
  34583. arc?: number;
  34584. slice?: number;
  34585. sideOrientation?: number;
  34586. frontUVs?: Vector4;
  34587. backUVs?: Vector4;
  34588. }): VertexData;
  34589. /**
  34590. * Creates the VertexData for a cylinder, cone or prism
  34591. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34592. * * height sets the height (y direction) of the cylinder, optional, default 2
  34593. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34594. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34595. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34596. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34597. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34598. * * 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
  34599. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34600. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34601. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34602. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34604. * * 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)
  34605. * * 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)
  34606. * @returns the VertexData of the cylinder, cone or prism
  34607. */
  34608. static CreateCylinder(options: {
  34609. height?: number;
  34610. diameterTop?: number;
  34611. diameterBottom?: number;
  34612. diameter?: number;
  34613. tessellation?: number;
  34614. subdivisions?: number;
  34615. arc?: number;
  34616. faceColors?: Color4[];
  34617. faceUV?: Vector4[];
  34618. hasRings?: boolean;
  34619. enclose?: boolean;
  34620. sideOrientation?: number;
  34621. frontUVs?: Vector4;
  34622. backUVs?: Vector4;
  34623. }): VertexData;
  34624. /**
  34625. * Creates the VertexData for a torus
  34626. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34627. * * diameter the diameter of the torus, optional default 1
  34628. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34629. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34631. * * 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)
  34632. * * 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)
  34633. * @returns the VertexData of the torus
  34634. */
  34635. static CreateTorus(options: {
  34636. diameter?: number;
  34637. thickness?: number;
  34638. tessellation?: number;
  34639. sideOrientation?: number;
  34640. frontUVs?: Vector4;
  34641. backUVs?: Vector4;
  34642. }): VertexData;
  34643. /**
  34644. * Creates the VertexData of the LineSystem
  34645. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34646. * - lines an array of lines, each line being an array of successive Vector3
  34647. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34648. * @returns the VertexData of the LineSystem
  34649. */
  34650. static CreateLineSystem(options: {
  34651. lines: Vector3[][];
  34652. colors?: Nullable<Color4[][]>;
  34653. }): VertexData;
  34654. /**
  34655. * Create the VertexData for a DashedLines
  34656. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34657. * - points an array successive Vector3
  34658. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34659. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34660. * - dashNb the intended total number of dashes, optional, default 200
  34661. * @returns the VertexData for the DashedLines
  34662. */
  34663. static CreateDashedLines(options: {
  34664. points: Vector3[];
  34665. dashSize?: number;
  34666. gapSize?: number;
  34667. dashNb?: number;
  34668. }): VertexData;
  34669. /**
  34670. * Creates the VertexData for a Ground
  34671. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34672. * - width the width (x direction) of the ground, optional, default 1
  34673. * - height the height (z direction) of the ground, optional, default 1
  34674. * - subdivisions the number of subdivisions per side, optional, default 1
  34675. * @returns the VertexData of the Ground
  34676. */
  34677. static CreateGround(options: {
  34678. width?: number;
  34679. height?: number;
  34680. subdivisions?: number;
  34681. subdivisionsX?: number;
  34682. subdivisionsY?: number;
  34683. }): VertexData;
  34684. /**
  34685. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34686. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34687. * * xmin the ground minimum X coordinate, optional, default -1
  34688. * * zmin the ground minimum Z coordinate, optional, default -1
  34689. * * xmax the ground maximum X coordinate, optional, default 1
  34690. * * zmax the ground maximum Z coordinate, optional, default 1
  34691. * * 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}
  34692. * * 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}
  34693. * @returns the VertexData of the TiledGround
  34694. */
  34695. static CreateTiledGround(options: {
  34696. xmin: number;
  34697. zmin: number;
  34698. xmax: number;
  34699. zmax: number;
  34700. subdivisions?: {
  34701. w: number;
  34702. h: number;
  34703. };
  34704. precision?: {
  34705. w: number;
  34706. h: number;
  34707. };
  34708. }): VertexData;
  34709. /**
  34710. * Creates the VertexData of the Ground designed from a heightmap
  34711. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34712. * * width the width (x direction) of the ground
  34713. * * height the height (z direction) of the ground
  34714. * * subdivisions the number of subdivisions per side
  34715. * * minHeight the minimum altitude on the ground, optional, default 0
  34716. * * maxHeight the maximum altitude on the ground, optional default 1
  34717. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34718. * * buffer the array holding the image color data
  34719. * * bufferWidth the width of image
  34720. * * bufferHeight the height of image
  34721. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34722. * @returns the VertexData of the Ground designed from a heightmap
  34723. */
  34724. static CreateGroundFromHeightMap(options: {
  34725. width: number;
  34726. height: number;
  34727. subdivisions: number;
  34728. minHeight: number;
  34729. maxHeight: number;
  34730. colorFilter: Color3;
  34731. buffer: Uint8Array;
  34732. bufferWidth: number;
  34733. bufferHeight: number;
  34734. alphaFilter: number;
  34735. }): VertexData;
  34736. /**
  34737. * Creates the VertexData for a Plane
  34738. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34739. * * size sets the width and height of the plane to the value of size, optional default 1
  34740. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34741. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34743. * * 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)
  34744. * * 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)
  34745. * @returns the VertexData of the box
  34746. */
  34747. static CreatePlane(options: {
  34748. size?: number;
  34749. width?: number;
  34750. height?: number;
  34751. sideOrientation?: number;
  34752. frontUVs?: Vector4;
  34753. backUVs?: Vector4;
  34754. }): VertexData;
  34755. /**
  34756. * Creates the VertexData of the Disc or regular Polygon
  34757. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34758. * * radius the radius of the disc, optional default 0.5
  34759. * * tessellation the number of polygon sides, optional, default 64
  34760. * * 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
  34761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34762. * * 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)
  34763. * * 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)
  34764. * @returns the VertexData of the box
  34765. */
  34766. static CreateDisc(options: {
  34767. radius?: number;
  34768. tessellation?: number;
  34769. arc?: number;
  34770. sideOrientation?: number;
  34771. frontUVs?: Vector4;
  34772. backUVs?: Vector4;
  34773. }): VertexData;
  34774. /**
  34775. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34776. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34777. * @param polygon a mesh built from polygonTriangulation.build()
  34778. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34779. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34780. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34781. * @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)
  34782. * @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)
  34783. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34784. * @returns the VertexData of the Polygon
  34785. */
  34786. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34787. /**
  34788. * Creates the VertexData of the IcoSphere
  34789. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34790. * * radius the radius of the IcoSphere, optional default 1
  34791. * * radiusX allows stretching in the x direction, optional, default radius
  34792. * * radiusY allows stretching in the y direction, optional, default radius
  34793. * * radiusZ allows stretching in the z direction, optional, default radius
  34794. * * flat when true creates a flat shaded mesh, optional, default true
  34795. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34797. * * 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)
  34798. * * 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)
  34799. * @returns the VertexData of the IcoSphere
  34800. */
  34801. static CreateIcoSphere(options: {
  34802. radius?: number;
  34803. radiusX?: number;
  34804. radiusY?: number;
  34805. radiusZ?: number;
  34806. flat?: boolean;
  34807. subdivisions?: number;
  34808. sideOrientation?: number;
  34809. frontUVs?: Vector4;
  34810. backUVs?: Vector4;
  34811. }): VertexData;
  34812. /**
  34813. * Creates the VertexData for a Polyhedron
  34814. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34815. * * type provided types are:
  34816. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34817. * * 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)
  34818. * * size the size of the IcoSphere, optional default 1
  34819. * * sizeX allows stretching in the x direction, optional, default size
  34820. * * sizeY allows stretching in the y direction, optional, default size
  34821. * * sizeZ allows stretching in the z direction, optional, default size
  34822. * * 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
  34823. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34824. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34825. * * flat when true creates a flat shaded mesh, optional, default true
  34826. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34828. * * 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)
  34829. * * 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)
  34830. * @returns the VertexData of the Polyhedron
  34831. */
  34832. static CreatePolyhedron(options: {
  34833. type?: number;
  34834. size?: number;
  34835. sizeX?: number;
  34836. sizeY?: number;
  34837. sizeZ?: number;
  34838. custom?: any;
  34839. faceUV?: Vector4[];
  34840. faceColors?: Color4[];
  34841. flat?: boolean;
  34842. sideOrientation?: number;
  34843. frontUVs?: Vector4;
  34844. backUVs?: Vector4;
  34845. }): VertexData;
  34846. /**
  34847. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34848. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34849. * @returns the VertexData of the Capsule
  34850. */
  34851. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34852. /**
  34853. * Creates the VertexData for a TorusKnot
  34854. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34855. * * radius the radius of the torus knot, optional, default 2
  34856. * * tube the thickness of the tube, optional, default 0.5
  34857. * * radialSegments the number of sides on each tube segments, optional, default 32
  34858. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34859. * * p the number of windings around the z axis, optional, default 2
  34860. * * q the number of windings around the x axis, optional, default 3
  34861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34862. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34863. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34864. * @returns the VertexData of the Torus Knot
  34865. */
  34866. static CreateTorusKnot(options: {
  34867. radius?: number;
  34868. tube?: number;
  34869. radialSegments?: number;
  34870. tubularSegments?: number;
  34871. p?: number;
  34872. q?: number;
  34873. sideOrientation?: number;
  34874. frontUVs?: Vector4;
  34875. backUVs?: Vector4;
  34876. }): VertexData;
  34877. /**
  34878. * Compute normals for given positions and indices
  34879. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34880. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34881. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34882. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34883. * * facetNormals : optional array of facet normals (vector3)
  34884. * * facetPositions : optional array of facet positions (vector3)
  34885. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34886. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34887. * * bInfo : optional bounding info, required for facetPartitioning computation
  34888. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34889. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34890. * * useRightHandedSystem: optional boolean to for right handed system computation
  34891. * * depthSort : optional boolean to enable the facet depth sort computation
  34892. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34893. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34894. */
  34895. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34896. facetNormals?: any;
  34897. facetPositions?: any;
  34898. facetPartitioning?: any;
  34899. ratio?: number;
  34900. bInfo?: any;
  34901. bbSize?: Vector3;
  34902. subDiv?: any;
  34903. useRightHandedSystem?: boolean;
  34904. depthSort?: boolean;
  34905. distanceTo?: Vector3;
  34906. depthSortedFacets?: any;
  34907. }): void;
  34908. /** @hidden */
  34909. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34910. /**
  34911. * Applies VertexData created from the imported parameters to the geometry
  34912. * @param parsedVertexData the parsed data from an imported file
  34913. * @param geometry the geometry to apply the VertexData to
  34914. */
  34915. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34916. }
  34917. }
  34918. declare module BABYLON {
  34919. /**
  34920. * Class containing static functions to help procedurally build meshes
  34921. */
  34922. export class DiscBuilder {
  34923. /**
  34924. * Creates a plane polygonal mesh. By default, this is a disc
  34925. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34926. * * 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
  34927. * * 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
  34928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34929. * * 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
  34930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34931. * @param name defines the name of the mesh
  34932. * @param options defines the options used to create the mesh
  34933. * @param scene defines the hosting scene
  34934. * @returns the plane polygonal mesh
  34935. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34936. */
  34937. static CreateDisc(name: string, options: {
  34938. radius?: number;
  34939. tessellation?: number;
  34940. arc?: number;
  34941. updatable?: boolean;
  34942. sideOrientation?: number;
  34943. frontUVs?: Vector4;
  34944. backUVs?: Vector4;
  34945. }, scene?: Nullable<Scene>): Mesh;
  34946. }
  34947. }
  34948. declare module BABYLON {
  34949. /**
  34950. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34951. *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.
  34952. * The SPS is also a particle system. It provides some methods to manage the particles.
  34953. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34954. *
  34955. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34956. */
  34957. export class SolidParticleSystem implements IDisposable {
  34958. /**
  34959. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34960. * Example : var p = SPS.particles[i];
  34961. */
  34962. particles: SolidParticle[];
  34963. /**
  34964. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34965. */
  34966. nbParticles: number;
  34967. /**
  34968. * If the particles must ever face the camera (default false). Useful for planar particles.
  34969. */
  34970. billboard: boolean;
  34971. /**
  34972. * Recompute normals when adding a shape
  34973. */
  34974. recomputeNormals: boolean;
  34975. /**
  34976. * This a counter ofr your own usage. It's not set by any SPS functions.
  34977. */
  34978. counter: number;
  34979. /**
  34980. * The SPS name. This name is also given to the underlying mesh.
  34981. */
  34982. name: string;
  34983. /**
  34984. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34985. */
  34986. mesh: Mesh;
  34987. /**
  34988. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34989. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34990. */
  34991. vars: any;
  34992. /**
  34993. * This array is populated when the SPS is set as 'pickable'.
  34994. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34995. * Each element of this array is an object `{idx: int, faceId: int}`.
  34996. * `idx` is the picked particle index in the `SPS.particles` array
  34997. * `faceId` is the picked face index counted within this particle.
  34998. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34999. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35000. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35001. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35002. */
  35003. pickedParticles: {
  35004. idx: number;
  35005. faceId: number;
  35006. }[];
  35007. /**
  35008. * This array is populated when the SPS is set as 'pickable'
  35009. * Each key of this array is a submesh index.
  35010. * Each element of this array is a second array defined like this :
  35011. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35012. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35013. * `idx` is the picked particle index in the `SPS.particles` array
  35014. * `faceId` is the picked face index counted within this particle.
  35015. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35016. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35017. */
  35018. pickedBySubMesh: {
  35019. idx: number;
  35020. faceId: number;
  35021. }[][];
  35022. /**
  35023. * This array is populated when `enableDepthSort` is set to true.
  35024. * Each element of this array is an instance of the class DepthSortedParticle.
  35025. */
  35026. depthSortedParticles: DepthSortedParticle[];
  35027. /**
  35028. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35029. * @hidden
  35030. */
  35031. _bSphereOnly: boolean;
  35032. /**
  35033. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35034. * @hidden
  35035. */
  35036. _bSphereRadiusFactor: number;
  35037. private _scene;
  35038. private _positions;
  35039. private _indices;
  35040. private _normals;
  35041. private _colors;
  35042. private _uvs;
  35043. private _indices32;
  35044. private _positions32;
  35045. private _normals32;
  35046. private _fixedNormal32;
  35047. private _colors32;
  35048. private _uvs32;
  35049. private _index;
  35050. private _updatable;
  35051. private _pickable;
  35052. private _isVisibilityBoxLocked;
  35053. private _alwaysVisible;
  35054. private _depthSort;
  35055. private _expandable;
  35056. private _shapeCounter;
  35057. private _copy;
  35058. private _color;
  35059. private _computeParticleColor;
  35060. private _computeParticleTexture;
  35061. private _computeParticleRotation;
  35062. private _computeParticleVertex;
  35063. private _computeBoundingBox;
  35064. private _depthSortParticles;
  35065. private _camera;
  35066. private _mustUnrotateFixedNormals;
  35067. private _particlesIntersect;
  35068. private _needs32Bits;
  35069. private _isNotBuilt;
  35070. private _lastParticleId;
  35071. private _idxOfId;
  35072. private _multimaterialEnabled;
  35073. private _useModelMaterial;
  35074. private _indicesByMaterial;
  35075. private _materialIndexes;
  35076. private _depthSortFunction;
  35077. private _materialSortFunction;
  35078. private _materials;
  35079. private _multimaterial;
  35080. private _materialIndexesById;
  35081. private _defaultMaterial;
  35082. private _autoUpdateSubMeshes;
  35083. private _tmpVertex;
  35084. /**
  35085. * Creates a SPS (Solid Particle System) object.
  35086. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35087. * @param scene (Scene) is the scene in which the SPS is added.
  35088. * @param options defines the options of the sps e.g.
  35089. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35090. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35091. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35092. * * 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.
  35093. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35094. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35095. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35096. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35097. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35098. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35099. */
  35100. constructor(name: string, scene: Scene, options?: {
  35101. updatable?: boolean;
  35102. isPickable?: boolean;
  35103. enableDepthSort?: boolean;
  35104. particleIntersection?: boolean;
  35105. boundingSphereOnly?: boolean;
  35106. bSphereRadiusFactor?: number;
  35107. expandable?: boolean;
  35108. useModelMaterial?: boolean;
  35109. enableMultiMaterial?: boolean;
  35110. });
  35111. /**
  35112. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35113. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35114. * @returns the created mesh
  35115. */
  35116. buildMesh(): Mesh;
  35117. /**
  35118. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35119. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35120. * Thus the particles generated from `digest()` have their property `position` set yet.
  35121. * @param mesh ( Mesh ) is the mesh to be digested
  35122. * @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
  35123. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35124. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35125. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35126. * @returns the current SPS
  35127. */
  35128. digest(mesh: Mesh, options?: {
  35129. facetNb?: number;
  35130. number?: number;
  35131. delta?: number;
  35132. storage?: [];
  35133. }): SolidParticleSystem;
  35134. /**
  35135. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35136. * @hidden
  35137. */
  35138. private _unrotateFixedNormals;
  35139. /**
  35140. * Resets the temporary working copy particle
  35141. * @hidden
  35142. */
  35143. private _resetCopy;
  35144. /**
  35145. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35146. * @param p the current index in the positions array to be updated
  35147. * @param ind the current index in the indices array
  35148. * @param shape a Vector3 array, the shape geometry
  35149. * @param positions the positions array to be updated
  35150. * @param meshInd the shape indices array
  35151. * @param indices the indices array to be updated
  35152. * @param meshUV the shape uv array
  35153. * @param uvs the uv array to be updated
  35154. * @param meshCol the shape color array
  35155. * @param colors the color array to be updated
  35156. * @param meshNor the shape normals array
  35157. * @param normals the normals array to be updated
  35158. * @param idx the particle index
  35159. * @param idxInShape the particle index in its shape
  35160. * @param options the addShape() method passed options
  35161. * @model the particle model
  35162. * @hidden
  35163. */
  35164. private _meshBuilder;
  35165. /**
  35166. * Returns a shape Vector3 array from positions float array
  35167. * @param positions float array
  35168. * @returns a vector3 array
  35169. * @hidden
  35170. */
  35171. private _posToShape;
  35172. /**
  35173. * Returns a shapeUV array from a float uvs (array deep copy)
  35174. * @param uvs as a float array
  35175. * @returns a shapeUV array
  35176. * @hidden
  35177. */
  35178. private _uvsToShapeUV;
  35179. /**
  35180. * Adds a new particle object in the particles array
  35181. * @param idx particle index in particles array
  35182. * @param id particle id
  35183. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35184. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35185. * @param model particle ModelShape object
  35186. * @param shapeId model shape identifier
  35187. * @param idxInShape index of the particle in the current model
  35188. * @param bInfo model bounding info object
  35189. * @param storage target storage array, if any
  35190. * @hidden
  35191. */
  35192. private _addParticle;
  35193. /**
  35194. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35195. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35196. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35197. * @param nb (positive integer) the number of particles to be created from this model
  35198. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35199. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35200. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35201. * @returns the number of shapes in the system
  35202. */
  35203. addShape(mesh: Mesh, nb: number, options?: {
  35204. positionFunction?: any;
  35205. vertexFunction?: any;
  35206. storage?: [];
  35207. }): number;
  35208. /**
  35209. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35210. * @hidden
  35211. */
  35212. private _rebuildParticle;
  35213. /**
  35214. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35215. * @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.
  35216. * @returns the SPS.
  35217. */
  35218. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35219. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35220. * Returns an array with the removed particles.
  35221. * 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.
  35222. * The SPS can't be empty so at least one particle needs to remain in place.
  35223. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35224. * @param start index of the first particle to remove
  35225. * @param end index of the last particle to remove (included)
  35226. * @returns an array populated with the removed particles
  35227. */
  35228. removeParticles(start: number, end: number): SolidParticle[];
  35229. /**
  35230. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35231. * @param solidParticleArray an array populated with Solid Particles objects
  35232. * @returns the SPS
  35233. */
  35234. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35235. /**
  35236. * Creates a new particle and modifies the SPS mesh geometry :
  35237. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35238. * - calls _addParticle() to populate the particle array
  35239. * factorized code from addShape() and insertParticlesFromArray()
  35240. * @param idx particle index in the particles array
  35241. * @param i particle index in its shape
  35242. * @param modelShape particle ModelShape object
  35243. * @param shape shape vertex array
  35244. * @param meshInd shape indices array
  35245. * @param meshUV shape uv array
  35246. * @param meshCol shape color array
  35247. * @param meshNor shape normals array
  35248. * @param bbInfo shape bounding info
  35249. * @param storage target particle storage
  35250. * @options addShape() passed options
  35251. * @hidden
  35252. */
  35253. private _insertNewParticle;
  35254. /**
  35255. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35256. * This method calls `updateParticle()` for each particle of the SPS.
  35257. * For an animated SPS, it is usually called within the render loop.
  35258. * 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.
  35259. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35260. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35261. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35262. * @returns the SPS.
  35263. */
  35264. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35265. /**
  35266. * Disposes the SPS.
  35267. */
  35268. dispose(): void;
  35269. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35270. * idx is the particle index in the SPS
  35271. * faceId is the picked face index counted within this particle.
  35272. * Returns null if the pickInfo can't identify a picked particle.
  35273. * @param pickingInfo (PickingInfo object)
  35274. * @returns {idx: number, faceId: number} or null
  35275. */
  35276. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35277. idx: number;
  35278. faceId: number;
  35279. }>;
  35280. /**
  35281. * Returns a SolidParticle object from its identifier : particle.id
  35282. * @param id (integer) the particle Id
  35283. * @returns the searched particle or null if not found in the SPS.
  35284. */
  35285. getParticleById(id: number): Nullable<SolidParticle>;
  35286. /**
  35287. * Returns a new array populated with the particles having the passed shapeId.
  35288. * @param shapeId (integer) the shape identifier
  35289. * @returns a new solid particle array
  35290. */
  35291. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35292. /**
  35293. * Populates the passed array "ref" with the particles having the passed shapeId.
  35294. * @param shapeId the shape identifier
  35295. * @returns the SPS
  35296. * @param ref
  35297. */
  35298. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35299. /**
  35300. * Computes the required SubMeshes according the materials assigned to the particles.
  35301. * @returns the solid particle system.
  35302. * Does nothing if called before the SPS mesh is built.
  35303. */
  35304. computeSubMeshes(): SolidParticleSystem;
  35305. /**
  35306. * Sorts the solid particles by material when MultiMaterial is enabled.
  35307. * Updates the indices32 array.
  35308. * Updates the indicesByMaterial array.
  35309. * Updates the mesh indices array.
  35310. * @returns the SPS
  35311. * @hidden
  35312. */
  35313. private _sortParticlesByMaterial;
  35314. /**
  35315. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35316. * @hidden
  35317. */
  35318. private _setMaterialIndexesById;
  35319. /**
  35320. * Returns an array with unique values of Materials from the passed array
  35321. * @param array the material array to be checked and filtered
  35322. * @hidden
  35323. */
  35324. private _filterUniqueMaterialId;
  35325. /**
  35326. * Sets a new Standard Material as _defaultMaterial if not already set.
  35327. * @hidden
  35328. */
  35329. private _setDefaultMaterial;
  35330. /**
  35331. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35332. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35333. * @returns the SPS.
  35334. */
  35335. refreshVisibleSize(): SolidParticleSystem;
  35336. /**
  35337. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35338. * @param size the size (float) of the visibility box
  35339. * note : this doesn't lock the SPS mesh bounding box.
  35340. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35341. */
  35342. setVisibilityBox(size: number): void;
  35343. /**
  35344. * Gets whether the SPS as always visible or not
  35345. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35346. */
  35347. get isAlwaysVisible(): boolean;
  35348. /**
  35349. * Sets the SPS as always visible or not
  35350. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35351. */
  35352. set isAlwaysVisible(val: boolean);
  35353. /**
  35354. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35355. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35356. */
  35357. set isVisibilityBoxLocked(val: boolean);
  35358. /**
  35359. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35360. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35361. */
  35362. get isVisibilityBoxLocked(): boolean;
  35363. /**
  35364. * Tells to `setParticles()` to compute the particle rotations or not.
  35365. * Default value : true. The SPS is faster when it's set to false.
  35366. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35367. */
  35368. set computeParticleRotation(val: boolean);
  35369. /**
  35370. * Tells to `setParticles()` to compute the particle colors or not.
  35371. * Default value : true. The SPS is faster when it's set to false.
  35372. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35373. */
  35374. set computeParticleColor(val: boolean);
  35375. set computeParticleTexture(val: boolean);
  35376. /**
  35377. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35378. * Default value : false. The SPS is faster when it's set to false.
  35379. * Note : the particle custom vertex positions aren't stored values.
  35380. */
  35381. set computeParticleVertex(val: boolean);
  35382. /**
  35383. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35384. */
  35385. set computeBoundingBox(val: boolean);
  35386. /**
  35387. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35388. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35389. * Default : `true`
  35390. */
  35391. set depthSortParticles(val: boolean);
  35392. /**
  35393. * Gets if `setParticles()` computes the particle rotations or not.
  35394. * Default value : true. The SPS is faster when it's set to false.
  35395. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35396. */
  35397. get computeParticleRotation(): boolean;
  35398. /**
  35399. * Gets if `setParticles()` computes the particle colors or not.
  35400. * Default value : true. The SPS is faster when it's set to false.
  35401. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35402. */
  35403. get computeParticleColor(): boolean;
  35404. /**
  35405. * Gets if `setParticles()` computes the particle textures or not.
  35406. * Default value : true. The SPS is faster when it's set to false.
  35407. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35408. */
  35409. get computeParticleTexture(): boolean;
  35410. /**
  35411. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35412. * Default value : false. The SPS is faster when it's set to false.
  35413. * Note : the particle custom vertex positions aren't stored values.
  35414. */
  35415. get computeParticleVertex(): boolean;
  35416. /**
  35417. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35418. */
  35419. get computeBoundingBox(): boolean;
  35420. /**
  35421. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35422. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35423. * Default : `true`
  35424. */
  35425. get depthSortParticles(): boolean;
  35426. /**
  35427. * Gets if the SPS is created as expandable at construction time.
  35428. * Default : `false`
  35429. */
  35430. get expandable(): boolean;
  35431. /**
  35432. * Gets if the SPS supports the Multi Materials
  35433. */
  35434. get multimaterialEnabled(): boolean;
  35435. /**
  35436. * Gets if the SPS uses the model materials for its own multimaterial.
  35437. */
  35438. get useModelMaterial(): boolean;
  35439. /**
  35440. * The SPS used material array.
  35441. */
  35442. get materials(): Material[];
  35443. /**
  35444. * Sets the SPS MultiMaterial from the passed materials.
  35445. * Note : the passed array is internally copied and not used then by reference.
  35446. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35447. */
  35448. setMultiMaterial(materials: Material[]): void;
  35449. /**
  35450. * The SPS computed multimaterial object
  35451. */
  35452. get multimaterial(): MultiMaterial;
  35453. set multimaterial(mm: MultiMaterial);
  35454. /**
  35455. * If the subMeshes must be updated on the next call to setParticles()
  35456. */
  35457. get autoUpdateSubMeshes(): boolean;
  35458. set autoUpdateSubMeshes(val: boolean);
  35459. /**
  35460. * This function does nothing. It may be overwritten to set all the particle first values.
  35461. * The SPS doesn't call this function, you may have to call it by your own.
  35462. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35463. */
  35464. initParticles(): void;
  35465. /**
  35466. * This function does nothing. It may be overwritten to recycle a particle.
  35467. * The SPS doesn't call this function, you may have to call it by your own.
  35468. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35469. * @param particle The particle to recycle
  35470. * @returns the recycled particle
  35471. */
  35472. recycleParticle(particle: SolidParticle): SolidParticle;
  35473. /**
  35474. * Updates a particle : this function should be overwritten by the user.
  35475. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35476. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35477. * @example : just set a particle position or velocity and recycle conditions
  35478. * @param particle The particle to update
  35479. * @returns the updated particle
  35480. */
  35481. updateParticle(particle: SolidParticle): SolidParticle;
  35482. /**
  35483. * Updates a vertex of a particle : it can be overwritten by the user.
  35484. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35485. * @param particle the current particle
  35486. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35487. * @param pt the index of the current vertex in the particle shape
  35488. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35489. * @example : just set a vertex particle position or color
  35490. * @returns the sps
  35491. */
  35492. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35493. /**
  35494. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35495. * This does nothing and may be overwritten by the user.
  35496. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35497. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35498. * @param update the boolean update value actually passed to setParticles()
  35499. */
  35500. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35501. /**
  35502. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35503. * This will be passed three parameters.
  35504. * This does nothing and may be overwritten by the user.
  35505. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35506. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35507. * @param update the boolean update value actually passed to setParticles()
  35508. */
  35509. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35510. }
  35511. }
  35512. declare module BABYLON {
  35513. /**
  35514. * Represents one particle of a solid particle system.
  35515. */
  35516. export class SolidParticle {
  35517. /**
  35518. * particle global index
  35519. */
  35520. idx: number;
  35521. /**
  35522. * particle identifier
  35523. */
  35524. id: number;
  35525. /**
  35526. * The color of the particle
  35527. */
  35528. color: Nullable<Color4>;
  35529. /**
  35530. * The world space position of the particle.
  35531. */
  35532. position: Vector3;
  35533. /**
  35534. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35535. */
  35536. rotation: Vector3;
  35537. /**
  35538. * The world space rotation quaternion of the particle.
  35539. */
  35540. rotationQuaternion: Nullable<Quaternion>;
  35541. /**
  35542. * The scaling of the particle.
  35543. */
  35544. scaling: Vector3;
  35545. /**
  35546. * The uvs of the particle.
  35547. */
  35548. uvs: Vector4;
  35549. /**
  35550. * The current speed of the particle.
  35551. */
  35552. velocity: Vector3;
  35553. /**
  35554. * The pivot point in the particle local space.
  35555. */
  35556. pivot: Vector3;
  35557. /**
  35558. * Must the particle be translated from its pivot point in its local space ?
  35559. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35560. * Default : false
  35561. */
  35562. translateFromPivot: boolean;
  35563. /**
  35564. * Is the particle active or not ?
  35565. */
  35566. alive: boolean;
  35567. /**
  35568. * Is the particle visible or not ?
  35569. */
  35570. isVisible: boolean;
  35571. /**
  35572. * Index of this particle in the global "positions" array (Internal use)
  35573. * @hidden
  35574. */
  35575. _pos: number;
  35576. /**
  35577. * @hidden Index of this particle in the global "indices" array (Internal use)
  35578. */
  35579. _ind: number;
  35580. /**
  35581. * @hidden ModelShape of this particle (Internal use)
  35582. */
  35583. _model: ModelShape;
  35584. /**
  35585. * ModelShape id of this particle
  35586. */
  35587. shapeId: number;
  35588. /**
  35589. * Index of the particle in its shape id
  35590. */
  35591. idxInShape: number;
  35592. /**
  35593. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35594. */
  35595. _modelBoundingInfo: BoundingInfo;
  35596. /**
  35597. * @hidden Particle BoundingInfo object (Internal use)
  35598. */
  35599. _boundingInfo: BoundingInfo;
  35600. /**
  35601. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35602. */
  35603. _sps: SolidParticleSystem;
  35604. /**
  35605. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35606. */
  35607. _stillInvisible: boolean;
  35608. /**
  35609. * @hidden Last computed particle rotation matrix
  35610. */
  35611. _rotationMatrix: number[];
  35612. /**
  35613. * Parent particle Id, if any.
  35614. * Default null.
  35615. */
  35616. parentId: Nullable<number>;
  35617. /**
  35618. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35619. */
  35620. materialIndex: Nullable<number>;
  35621. /**
  35622. * Custom object or properties.
  35623. */
  35624. props: Nullable<any>;
  35625. /**
  35626. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35627. * The possible values are :
  35628. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35629. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35630. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35631. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35632. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35633. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35634. * */
  35635. cullingStrategy: number;
  35636. /**
  35637. * @hidden Internal global position in the SPS.
  35638. */
  35639. _globalPosition: Vector3;
  35640. /**
  35641. * Creates a Solid Particle object.
  35642. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35643. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35644. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35645. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35646. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35647. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35648. * @param shapeId (integer) is the model shape identifier in the SPS.
  35649. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35650. * @param sps defines the sps it is associated to
  35651. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35652. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35653. */
  35654. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35655. /**
  35656. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35657. * @param target the particle target
  35658. * @returns the current particle
  35659. */
  35660. copyToRef(target: SolidParticle): SolidParticle;
  35661. /**
  35662. * Legacy support, changed scale to scaling
  35663. */
  35664. get scale(): Vector3;
  35665. /**
  35666. * Legacy support, changed scale to scaling
  35667. */
  35668. set scale(scale: Vector3);
  35669. /**
  35670. * Legacy support, changed quaternion to rotationQuaternion
  35671. */
  35672. get quaternion(): Nullable<Quaternion>;
  35673. /**
  35674. * Legacy support, changed quaternion to rotationQuaternion
  35675. */
  35676. set quaternion(q: Nullable<Quaternion>);
  35677. /**
  35678. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35679. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35680. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35681. * @returns true if it intersects
  35682. */
  35683. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35684. /**
  35685. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35686. * A particle is in the frustum if its bounding box intersects the frustum
  35687. * @param frustumPlanes defines the frustum to test
  35688. * @returns true if the particle is in the frustum planes
  35689. */
  35690. isInFrustum(frustumPlanes: Plane[]): boolean;
  35691. /**
  35692. * get the rotation matrix of the particle
  35693. * @hidden
  35694. */
  35695. getRotationMatrix(m: Matrix): void;
  35696. }
  35697. /**
  35698. * Represents the shape of the model used by one particle of a solid particle system.
  35699. * SPS internal tool, don't use it manually.
  35700. */
  35701. export class ModelShape {
  35702. /**
  35703. * The shape id
  35704. * @hidden
  35705. */
  35706. shapeID: number;
  35707. /**
  35708. * flat array of model positions (internal use)
  35709. * @hidden
  35710. */
  35711. _shape: Vector3[];
  35712. /**
  35713. * flat array of model UVs (internal use)
  35714. * @hidden
  35715. */
  35716. _shapeUV: number[];
  35717. /**
  35718. * color array of the model
  35719. * @hidden
  35720. */
  35721. _shapeColors: number[];
  35722. /**
  35723. * indices array of the model
  35724. * @hidden
  35725. */
  35726. _indices: number[];
  35727. /**
  35728. * normals array of the model
  35729. * @hidden
  35730. */
  35731. _normals: number[];
  35732. /**
  35733. * length of the shape in the model indices array (internal use)
  35734. * @hidden
  35735. */
  35736. _indicesLength: number;
  35737. /**
  35738. * Custom position function (internal use)
  35739. * @hidden
  35740. */
  35741. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35742. /**
  35743. * Custom vertex function (internal use)
  35744. * @hidden
  35745. */
  35746. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35747. /**
  35748. * Model material (internal use)
  35749. * @hidden
  35750. */
  35751. _material: Nullable<Material>;
  35752. /**
  35753. * 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.
  35754. * SPS internal tool, don't use it manually.
  35755. * @hidden
  35756. */
  35757. 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>);
  35758. }
  35759. /**
  35760. * Represents a Depth Sorted Particle in the solid particle system.
  35761. * @hidden
  35762. */
  35763. export class DepthSortedParticle {
  35764. /**
  35765. * Particle index
  35766. */
  35767. idx: number;
  35768. /**
  35769. * Index of the particle in the "indices" array
  35770. */
  35771. ind: number;
  35772. /**
  35773. * Length of the particle shape in the "indices" array
  35774. */
  35775. indicesLength: number;
  35776. /**
  35777. * Squared distance from the particle to the camera
  35778. */
  35779. sqDistance: number;
  35780. /**
  35781. * Material index when used with MultiMaterials
  35782. */
  35783. materialIndex: number;
  35784. /**
  35785. * Creates a new sorted particle
  35786. * @param materialIndex
  35787. */
  35788. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35789. }
  35790. /**
  35791. * Represents a solid particle vertex
  35792. */
  35793. export class SolidParticleVertex {
  35794. /**
  35795. * Vertex position
  35796. */
  35797. position: Vector3;
  35798. /**
  35799. * Vertex color
  35800. */
  35801. color: Color4;
  35802. /**
  35803. * Vertex UV
  35804. */
  35805. uv: Vector2;
  35806. /**
  35807. * Creates a new solid particle vertex
  35808. */
  35809. constructor();
  35810. /** Vertex x coordinate */
  35811. get x(): number;
  35812. set x(val: number);
  35813. /** Vertex y coordinate */
  35814. get y(): number;
  35815. set y(val: number);
  35816. /** Vertex z coordinate */
  35817. get z(): number;
  35818. set z(val: number);
  35819. }
  35820. }
  35821. declare module BABYLON {
  35822. /**
  35823. * @hidden
  35824. */
  35825. export class _MeshCollisionData {
  35826. _checkCollisions: boolean;
  35827. _collisionMask: number;
  35828. _collisionGroup: number;
  35829. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35830. _collider: Nullable<Collider>;
  35831. _oldPositionForCollisions: Vector3;
  35832. _diffPositionForCollisions: Vector3;
  35833. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35834. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35835. _collisionResponse: boolean;
  35836. }
  35837. }
  35838. declare module BABYLON {
  35839. /** @hidden */
  35840. class _FacetDataStorage {
  35841. facetPositions: Vector3[];
  35842. facetNormals: Vector3[];
  35843. facetPartitioning: number[][];
  35844. facetNb: number;
  35845. partitioningSubdivisions: number;
  35846. partitioningBBoxRatio: number;
  35847. facetDataEnabled: boolean;
  35848. facetParameters: any;
  35849. bbSize: Vector3;
  35850. subDiv: {
  35851. max: number;
  35852. X: number;
  35853. Y: number;
  35854. Z: number;
  35855. };
  35856. facetDepthSort: boolean;
  35857. facetDepthSortEnabled: boolean;
  35858. depthSortedIndices: IndicesArray;
  35859. depthSortedFacets: {
  35860. ind: number;
  35861. sqDistance: number;
  35862. }[];
  35863. facetDepthSortFunction: (f1: {
  35864. ind: number;
  35865. sqDistance: number;
  35866. }, f2: {
  35867. ind: number;
  35868. sqDistance: number;
  35869. }) => number;
  35870. facetDepthSortFrom: Vector3;
  35871. facetDepthSortOrigin: Vector3;
  35872. invertedMatrix: Matrix;
  35873. }
  35874. /**
  35875. * @hidden
  35876. **/
  35877. class _InternalAbstractMeshDataInfo {
  35878. _hasVertexAlpha: boolean;
  35879. _useVertexColors: boolean;
  35880. _numBoneInfluencers: number;
  35881. _applyFog: boolean;
  35882. _receiveShadows: boolean;
  35883. _facetData: _FacetDataStorage;
  35884. _visibility: number;
  35885. _skeleton: Nullable<Skeleton>;
  35886. _layerMask: number;
  35887. _computeBonesUsingShaders: boolean;
  35888. _isActive: boolean;
  35889. _onlyForInstances: boolean;
  35890. _isActiveIntermediate: boolean;
  35891. _onlyForInstancesIntermediate: boolean;
  35892. _actAsRegularMesh: boolean;
  35893. _currentLOD: Nullable<AbstractMesh>;
  35894. _currentLODIsUpToDate: boolean;
  35895. }
  35896. /**
  35897. * Class used to store all common mesh properties
  35898. */
  35899. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35900. /** No occlusion */
  35901. static OCCLUSION_TYPE_NONE: number;
  35902. /** Occlusion set to optimisitic */
  35903. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35904. /** Occlusion set to strict */
  35905. static OCCLUSION_TYPE_STRICT: number;
  35906. /** Use an accurante occlusion algorithm */
  35907. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35908. /** Use a conservative occlusion algorithm */
  35909. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35910. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35911. * Test order :
  35912. * Is the bounding sphere outside the frustum ?
  35913. * If not, are the bounding box vertices outside the frustum ?
  35914. * It not, then the cullable object is in the frustum.
  35915. */
  35916. static readonly CULLINGSTRATEGY_STANDARD: number;
  35917. /** Culling strategy : Bounding Sphere Only.
  35918. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35919. * It's also less accurate than the standard because some not visible objects can still be selected.
  35920. * Test : is the bounding sphere outside the frustum ?
  35921. * If not, then the cullable object is in the frustum.
  35922. */
  35923. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35924. /** Culling strategy : Optimistic Inclusion.
  35925. * This in an inclusion test first, then the standard exclusion test.
  35926. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35927. * 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.
  35928. * Anyway, it's as accurate as the standard strategy.
  35929. * Test :
  35930. * Is the cullable object bounding sphere center in the frustum ?
  35931. * If not, apply the default culling strategy.
  35932. */
  35933. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35934. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35935. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35936. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35937. * 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.
  35938. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35939. * Test :
  35940. * Is the cullable object bounding sphere center in the frustum ?
  35941. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35942. */
  35943. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35944. /**
  35945. * No billboard
  35946. */
  35947. static get BILLBOARDMODE_NONE(): number;
  35948. /** Billboard on X axis */
  35949. static get BILLBOARDMODE_X(): number;
  35950. /** Billboard on Y axis */
  35951. static get BILLBOARDMODE_Y(): number;
  35952. /** Billboard on Z axis */
  35953. static get BILLBOARDMODE_Z(): number;
  35954. /** Billboard on all axes */
  35955. static get BILLBOARDMODE_ALL(): number;
  35956. /** Billboard on using position instead of orientation */
  35957. static get BILLBOARDMODE_USE_POSITION(): number;
  35958. /** @hidden */
  35959. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35960. /**
  35961. * The culling strategy to use to check whether the mesh must be rendered or not.
  35962. * This value can be changed at any time and will be used on the next render mesh selection.
  35963. * The possible values are :
  35964. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35965. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35967. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35968. * Please read each static variable documentation to get details about the culling process.
  35969. * */
  35970. cullingStrategy: number;
  35971. /**
  35972. * Gets the number of facets in the mesh
  35973. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35974. */
  35975. get facetNb(): number;
  35976. /**
  35977. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35978. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35979. */
  35980. get partitioningSubdivisions(): number;
  35981. set partitioningSubdivisions(nb: number);
  35982. /**
  35983. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35984. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35985. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35986. */
  35987. get partitioningBBoxRatio(): number;
  35988. set partitioningBBoxRatio(ratio: number);
  35989. /**
  35990. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35991. * Works only for updatable meshes.
  35992. * Doesn't work with multi-materials
  35993. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35994. */
  35995. get mustDepthSortFacets(): boolean;
  35996. set mustDepthSortFacets(sort: boolean);
  35997. /**
  35998. * The location (Vector3) where the facet depth sort must be computed from.
  35999. * By default, the active camera position.
  36000. * Used only when facet depth sort is enabled
  36001. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36002. */
  36003. get facetDepthSortFrom(): Vector3;
  36004. set facetDepthSortFrom(location: Vector3);
  36005. /**
  36006. * gets a boolean indicating if facetData is enabled
  36007. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36008. */
  36009. get isFacetDataEnabled(): boolean;
  36010. /** @hidden */
  36011. _updateNonUniformScalingState(value: boolean): boolean;
  36012. /**
  36013. * An event triggered when this mesh collides with another one
  36014. */
  36015. onCollideObservable: Observable<AbstractMesh>;
  36016. /** Set a function to call when this mesh collides with another one */
  36017. set onCollide(callback: () => void);
  36018. /**
  36019. * An event triggered when the collision's position changes
  36020. */
  36021. onCollisionPositionChangeObservable: Observable<Vector3>;
  36022. /** Set a function to call when the collision's position changes */
  36023. set onCollisionPositionChange(callback: () => void);
  36024. /**
  36025. * An event triggered when material is changed
  36026. */
  36027. onMaterialChangedObservable: Observable<AbstractMesh>;
  36028. /**
  36029. * Gets or sets the orientation for POV movement & rotation
  36030. */
  36031. definedFacingForward: boolean;
  36032. /** @hidden */
  36033. _occlusionQuery: Nullable<WebGLQuery>;
  36034. /** @hidden */
  36035. _renderingGroup: Nullable<RenderingGroup>;
  36036. /**
  36037. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36038. */
  36039. get visibility(): number;
  36040. /**
  36041. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36042. */
  36043. set visibility(value: number);
  36044. /** Gets or sets the alpha index used to sort transparent meshes
  36045. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36046. */
  36047. alphaIndex: number;
  36048. /**
  36049. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36050. */
  36051. isVisible: boolean;
  36052. /**
  36053. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36054. */
  36055. isPickable: boolean;
  36056. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36057. showSubMeshesBoundingBox: boolean;
  36058. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36059. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36060. */
  36061. isBlocker: boolean;
  36062. /**
  36063. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36064. */
  36065. enablePointerMoveEvents: boolean;
  36066. private _renderingGroupId;
  36067. /**
  36068. * Specifies the rendering group id for this mesh (0 by default)
  36069. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36070. */
  36071. get renderingGroupId(): number;
  36072. set renderingGroupId(value: number);
  36073. private _material;
  36074. /** Gets or sets current material */
  36075. get material(): Nullable<Material>;
  36076. set material(value: Nullable<Material>);
  36077. /**
  36078. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36079. * @see https://doc.babylonjs.com/babylon101/shadows
  36080. */
  36081. get receiveShadows(): boolean;
  36082. set receiveShadows(value: boolean);
  36083. /** Defines color to use when rendering outline */
  36084. outlineColor: Color3;
  36085. /** Define width to use when rendering outline */
  36086. outlineWidth: number;
  36087. /** Defines color to use when rendering overlay */
  36088. overlayColor: Color3;
  36089. /** Defines alpha to use when rendering overlay */
  36090. overlayAlpha: number;
  36091. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36092. get hasVertexAlpha(): boolean;
  36093. set hasVertexAlpha(value: boolean);
  36094. /** 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) */
  36095. get useVertexColors(): boolean;
  36096. set useVertexColors(value: boolean);
  36097. /**
  36098. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36099. */
  36100. get computeBonesUsingShaders(): boolean;
  36101. set computeBonesUsingShaders(value: boolean);
  36102. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36103. get numBoneInfluencers(): number;
  36104. set numBoneInfluencers(value: number);
  36105. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36106. get applyFog(): boolean;
  36107. set applyFog(value: boolean);
  36108. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36109. useOctreeForRenderingSelection: boolean;
  36110. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36111. useOctreeForPicking: boolean;
  36112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36113. useOctreeForCollisions: boolean;
  36114. /**
  36115. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36116. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36117. */
  36118. get layerMask(): number;
  36119. set layerMask(value: number);
  36120. /**
  36121. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36122. */
  36123. alwaysSelectAsActiveMesh: boolean;
  36124. /**
  36125. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36126. */
  36127. doNotSyncBoundingInfo: boolean;
  36128. /**
  36129. * Gets or sets the current action manager
  36130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36131. */
  36132. actionManager: Nullable<AbstractActionManager>;
  36133. private _meshCollisionData;
  36134. /**
  36135. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36136. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36137. */
  36138. ellipsoid: Vector3;
  36139. /**
  36140. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36141. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36142. */
  36143. ellipsoidOffset: Vector3;
  36144. /**
  36145. * Gets or sets a collision mask used to mask collisions (default is -1).
  36146. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36147. */
  36148. get collisionMask(): number;
  36149. set collisionMask(mask: number);
  36150. /**
  36151. * Gets or sets a collision response flag (default is true).
  36152. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36153. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36154. * to respond to the collision.
  36155. */
  36156. get collisionResponse(): boolean;
  36157. set collisionResponse(response: boolean);
  36158. /**
  36159. * Gets or sets the current collision group mask (-1 by default).
  36160. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36161. */
  36162. get collisionGroup(): number;
  36163. set collisionGroup(mask: number);
  36164. /**
  36165. * Gets or sets current surrounding meshes (null by default).
  36166. *
  36167. * By default collision detection is tested against every mesh in the scene.
  36168. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36169. * meshes will be tested for the collision.
  36170. *
  36171. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36172. */
  36173. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36174. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36175. /**
  36176. * Defines edge width used when edgesRenderer is enabled
  36177. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36178. */
  36179. edgesWidth: number;
  36180. /**
  36181. * Defines edge color used when edgesRenderer is enabled
  36182. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36183. */
  36184. edgesColor: Color4;
  36185. /** @hidden */
  36186. _edgesRenderer: Nullable<IEdgesRenderer>;
  36187. /** @hidden */
  36188. _masterMesh: Nullable<AbstractMesh>;
  36189. /** @hidden */
  36190. _boundingInfo: Nullable<BoundingInfo>;
  36191. /** @hidden */
  36192. _renderId: number;
  36193. /**
  36194. * Gets or sets the list of subMeshes
  36195. * @see https://doc.babylonjs.com/how_to/multi_materials
  36196. */
  36197. subMeshes: SubMesh[];
  36198. /** @hidden */
  36199. _intersectionsInProgress: AbstractMesh[];
  36200. /** @hidden */
  36201. _unIndexed: boolean;
  36202. /** @hidden */
  36203. _lightSources: Light[];
  36204. /** Gets the list of lights affecting that mesh */
  36205. get lightSources(): Light[];
  36206. /** @hidden */
  36207. get _positions(): Nullable<Vector3[]>;
  36208. /** @hidden */
  36209. _waitingData: {
  36210. lods: Nullable<any>;
  36211. actions: Nullable<any>;
  36212. freezeWorldMatrix: Nullable<boolean>;
  36213. };
  36214. /** @hidden */
  36215. _bonesTransformMatrices: Nullable<Float32Array>;
  36216. /** @hidden */
  36217. _transformMatrixTexture: Nullable<RawTexture>;
  36218. /**
  36219. * Gets or sets a skeleton to apply skining transformations
  36220. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36221. */
  36222. set skeleton(value: Nullable<Skeleton>);
  36223. get skeleton(): Nullable<Skeleton>;
  36224. /**
  36225. * An event triggered when the mesh is rebuilt.
  36226. */
  36227. onRebuildObservable: Observable<AbstractMesh>;
  36228. /**
  36229. * The current mesh unifom buffer.
  36230. * @hidden Internal use only.
  36231. */
  36232. _uniformBuffer: UniformBuffer;
  36233. /**
  36234. * Creates a new AbstractMesh
  36235. * @param name defines the name of the mesh
  36236. * @param scene defines the hosting scene
  36237. */
  36238. constructor(name: string, scene?: Nullable<Scene>);
  36239. protected _buildUniformLayout(): void;
  36240. /**
  36241. * Transfer the mesh values to its UBO.
  36242. * @param world The world matrix associated with the mesh
  36243. */
  36244. transferToEffect(world: Matrix): void;
  36245. /**
  36246. * Gets the mesh uniform buffer.
  36247. * @return the uniform buffer of the mesh.
  36248. */
  36249. getMeshUniformBuffer(): UniformBuffer;
  36250. /**
  36251. * Returns the string "AbstractMesh"
  36252. * @returns "AbstractMesh"
  36253. */
  36254. getClassName(): string;
  36255. /**
  36256. * Gets a string representation of the current mesh
  36257. * @param fullDetails defines a boolean indicating if full details must be included
  36258. * @returns a string representation of the current mesh
  36259. */
  36260. toString(fullDetails?: boolean): string;
  36261. /**
  36262. * @hidden
  36263. */
  36264. protected _getEffectiveParent(): Nullable<Node>;
  36265. /** @hidden */
  36266. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36267. /** @hidden */
  36268. _rebuild(): void;
  36269. /** @hidden */
  36270. _resyncLightSources(): void;
  36271. /** @hidden */
  36272. _resyncLightSource(light: Light): void;
  36273. /** @hidden */
  36274. _unBindEffect(): void;
  36275. /** @hidden */
  36276. _removeLightSource(light: Light, dispose: boolean): void;
  36277. private _markSubMeshesAsDirty;
  36278. /** @hidden */
  36279. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36280. /** @hidden */
  36281. _markSubMeshesAsAttributesDirty(): void;
  36282. /** @hidden */
  36283. _markSubMeshesAsMiscDirty(): void;
  36284. /**
  36285. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36286. */
  36287. get scaling(): Vector3;
  36288. set scaling(newScaling: Vector3);
  36289. /**
  36290. * Returns true if the mesh is blocked. Implemented by child classes
  36291. */
  36292. get isBlocked(): boolean;
  36293. /**
  36294. * Returns the mesh itself by default. Implemented by child classes
  36295. * @param camera defines the camera to use to pick the right LOD level
  36296. * @returns the currentAbstractMesh
  36297. */
  36298. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36299. /**
  36300. * Returns 0 by default. Implemented by child classes
  36301. * @returns an integer
  36302. */
  36303. getTotalVertices(): number;
  36304. /**
  36305. * Returns a positive integer : the total number of indices in this mesh geometry.
  36306. * @returns the numner of indices or zero if the mesh has no geometry.
  36307. */
  36308. getTotalIndices(): number;
  36309. /**
  36310. * Returns null by default. Implemented by child classes
  36311. * @returns null
  36312. */
  36313. getIndices(): Nullable<IndicesArray>;
  36314. /**
  36315. * Returns the array of the requested vertex data kind. Implemented by child classes
  36316. * @param kind defines the vertex data kind to use
  36317. * @returns null
  36318. */
  36319. getVerticesData(kind: string): Nullable<FloatArray>;
  36320. /**
  36321. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36322. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36323. * Note that a new underlying VertexBuffer object is created each call.
  36324. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36325. * @param kind defines vertex data kind:
  36326. * * VertexBuffer.PositionKind
  36327. * * VertexBuffer.UVKind
  36328. * * VertexBuffer.UV2Kind
  36329. * * VertexBuffer.UV3Kind
  36330. * * VertexBuffer.UV4Kind
  36331. * * VertexBuffer.UV5Kind
  36332. * * VertexBuffer.UV6Kind
  36333. * * VertexBuffer.ColorKind
  36334. * * VertexBuffer.MatricesIndicesKind
  36335. * * VertexBuffer.MatricesIndicesExtraKind
  36336. * * VertexBuffer.MatricesWeightsKind
  36337. * * VertexBuffer.MatricesWeightsExtraKind
  36338. * @param data defines the data source
  36339. * @param updatable defines if the data must be flagged as updatable (or static)
  36340. * @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
  36341. * @returns the current mesh
  36342. */
  36343. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36344. /**
  36345. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36346. * If the mesh has no geometry, it is simply returned as it is.
  36347. * @param kind defines vertex data kind:
  36348. * * VertexBuffer.PositionKind
  36349. * * VertexBuffer.UVKind
  36350. * * VertexBuffer.UV2Kind
  36351. * * VertexBuffer.UV3Kind
  36352. * * VertexBuffer.UV4Kind
  36353. * * VertexBuffer.UV5Kind
  36354. * * VertexBuffer.UV6Kind
  36355. * * VertexBuffer.ColorKind
  36356. * * VertexBuffer.MatricesIndicesKind
  36357. * * VertexBuffer.MatricesIndicesExtraKind
  36358. * * VertexBuffer.MatricesWeightsKind
  36359. * * VertexBuffer.MatricesWeightsExtraKind
  36360. * @param data defines the data source
  36361. * @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
  36362. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36363. * @returns the current mesh
  36364. */
  36365. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36366. /**
  36367. * Sets the mesh indices,
  36368. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36369. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36370. * @param totalVertices Defines the total number of vertices
  36371. * @returns the current mesh
  36372. */
  36373. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36374. /**
  36375. * Gets a boolean indicating if specific vertex data is present
  36376. * @param kind defines the vertex data kind to use
  36377. * @returns true is data kind is present
  36378. */
  36379. isVerticesDataPresent(kind: string): boolean;
  36380. /**
  36381. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36382. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36383. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36384. * @returns a BoundingInfo
  36385. */
  36386. getBoundingInfo(): BoundingInfo;
  36387. /**
  36388. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36389. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36390. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36391. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36392. * @returns the current mesh
  36393. */
  36394. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36395. /**
  36396. * Overwrite the current bounding info
  36397. * @param boundingInfo defines the new bounding info
  36398. * @returns the current mesh
  36399. */
  36400. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36401. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36402. get useBones(): boolean;
  36403. /** @hidden */
  36404. _preActivate(): void;
  36405. /** @hidden */
  36406. _preActivateForIntermediateRendering(renderId: number): void;
  36407. /** @hidden */
  36408. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36409. /** @hidden */
  36410. _postActivate(): void;
  36411. /** @hidden */
  36412. _freeze(): void;
  36413. /** @hidden */
  36414. _unFreeze(): void;
  36415. /**
  36416. * Gets the current world matrix
  36417. * @returns a Matrix
  36418. */
  36419. getWorldMatrix(): Matrix;
  36420. /** @hidden */
  36421. _getWorldMatrixDeterminant(): number;
  36422. /**
  36423. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36424. */
  36425. get isAnInstance(): boolean;
  36426. /**
  36427. * Gets a boolean indicating if this mesh has instances
  36428. */
  36429. get hasInstances(): boolean;
  36430. /**
  36431. * Gets a boolean indicating if this mesh has thin instances
  36432. */
  36433. get hasThinInstances(): boolean;
  36434. /**
  36435. * Perform relative position change from the point of view of behind the front of the mesh.
  36436. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36437. * Supports definition of mesh facing forward or backward
  36438. * @param amountRight defines the distance on the right axis
  36439. * @param amountUp defines the distance on the up axis
  36440. * @param amountForward defines the distance on the forward axis
  36441. * @returns the current mesh
  36442. */
  36443. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36444. /**
  36445. * Calculate relative position change from the point of view of behind the front of the mesh.
  36446. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36447. * Supports definition of mesh facing forward or backward
  36448. * @param amountRight defines the distance on the right axis
  36449. * @param amountUp defines the distance on the up axis
  36450. * @param amountForward defines the distance on the forward axis
  36451. * @returns the new displacement vector
  36452. */
  36453. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36454. /**
  36455. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36456. * Supports definition of mesh facing forward or backward
  36457. * @param flipBack defines the flip
  36458. * @param twirlClockwise defines the twirl
  36459. * @param tiltRight defines the tilt
  36460. * @returns the current mesh
  36461. */
  36462. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36463. /**
  36464. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36465. * Supports definition of mesh facing forward or backward.
  36466. * @param flipBack defines the flip
  36467. * @param twirlClockwise defines the twirl
  36468. * @param tiltRight defines the tilt
  36469. * @returns the new rotation vector
  36470. */
  36471. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36472. /**
  36473. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36474. * This means the mesh underlying bounding box and sphere are recomputed.
  36475. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36476. * @returns the current mesh
  36477. */
  36478. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36479. /** @hidden */
  36480. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36481. /** @hidden */
  36482. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36483. /** @hidden */
  36484. _updateBoundingInfo(): AbstractMesh;
  36485. /** @hidden */
  36486. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36487. /** @hidden */
  36488. protected _afterComputeWorldMatrix(): void;
  36489. /** @hidden */
  36490. get _effectiveMesh(): AbstractMesh;
  36491. /**
  36492. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36493. * A mesh is in the frustum if its bounding box intersects the frustum
  36494. * @param frustumPlanes defines the frustum to test
  36495. * @returns true if the mesh is in the frustum planes
  36496. */
  36497. isInFrustum(frustumPlanes: Plane[]): boolean;
  36498. /**
  36499. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36500. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36501. * @param frustumPlanes defines the frustum to test
  36502. * @returns true if the mesh is completely in the frustum planes
  36503. */
  36504. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36505. /**
  36506. * True if the mesh intersects another mesh or a SolidParticle object
  36507. * @param mesh defines a target mesh or SolidParticle to test
  36508. * @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)
  36509. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36510. * @returns true if there is an intersection
  36511. */
  36512. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36513. /**
  36514. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36515. * @param point defines the point to test
  36516. * @returns true if there is an intersection
  36517. */
  36518. intersectsPoint(point: Vector3): boolean;
  36519. /**
  36520. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36521. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36522. */
  36523. get checkCollisions(): boolean;
  36524. set checkCollisions(collisionEnabled: boolean);
  36525. /**
  36526. * Gets Collider object used to compute collisions (not physics)
  36527. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36528. */
  36529. get collider(): Nullable<Collider>;
  36530. /**
  36531. * Move the mesh using collision engine
  36532. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36533. * @param displacement defines the requested displacement vector
  36534. * @returns the current mesh
  36535. */
  36536. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36537. private _onCollisionPositionChange;
  36538. /** @hidden */
  36539. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36540. /** @hidden */
  36541. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36542. /** @hidden */
  36543. _checkCollision(collider: Collider): AbstractMesh;
  36544. /** @hidden */
  36545. _generatePointsArray(): boolean;
  36546. /**
  36547. * Checks if the passed Ray intersects with the mesh
  36548. * @param ray defines the ray to use
  36549. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36550. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36551. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36552. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36553. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36554. * @returns the picking info
  36555. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36556. */
  36557. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36558. /**
  36559. * Clones the current mesh
  36560. * @param name defines the mesh name
  36561. * @param newParent defines the new mesh parent
  36562. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36563. * @returns the new mesh
  36564. */
  36565. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36566. /**
  36567. * Disposes all the submeshes of the current meshnp
  36568. * @returns the current mesh
  36569. */
  36570. releaseSubMeshes(): AbstractMesh;
  36571. /**
  36572. * Releases resources associated with this abstract mesh.
  36573. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36574. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36575. */
  36576. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36577. /**
  36578. * Adds the passed mesh as a child to the current mesh
  36579. * @param mesh defines the child mesh
  36580. * @returns the current mesh
  36581. */
  36582. addChild(mesh: AbstractMesh): AbstractMesh;
  36583. /**
  36584. * Removes the passed mesh from the current mesh children list
  36585. * @param mesh defines the child mesh
  36586. * @returns the current mesh
  36587. */
  36588. removeChild(mesh: AbstractMesh): AbstractMesh;
  36589. /** @hidden */
  36590. private _initFacetData;
  36591. /**
  36592. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36593. * This method can be called within the render loop.
  36594. * 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
  36595. * @returns the current mesh
  36596. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36597. */
  36598. updateFacetData(): AbstractMesh;
  36599. /**
  36600. * Returns the facetLocalNormals array.
  36601. * The normals are expressed in the mesh local spac
  36602. * @returns an array of Vector3
  36603. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36604. */
  36605. getFacetLocalNormals(): Vector3[];
  36606. /**
  36607. * Returns the facetLocalPositions array.
  36608. * The facet positions are expressed in the mesh local space
  36609. * @returns an array of Vector3
  36610. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36611. */
  36612. getFacetLocalPositions(): Vector3[];
  36613. /**
  36614. * Returns the facetLocalPartioning array
  36615. * @returns an array of array of numbers
  36616. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36617. */
  36618. getFacetLocalPartitioning(): number[][];
  36619. /**
  36620. * Returns the i-th facet position in the world system.
  36621. * This method allocates a new Vector3 per call
  36622. * @param i defines the facet index
  36623. * @returns a new Vector3
  36624. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36625. */
  36626. getFacetPosition(i: number): Vector3;
  36627. /**
  36628. * Sets the reference Vector3 with the i-th facet position in the world system
  36629. * @param i defines the facet index
  36630. * @param ref defines the target vector
  36631. * @returns the current mesh
  36632. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36633. */
  36634. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36635. /**
  36636. * Returns the i-th facet normal in the world system.
  36637. * This method allocates a new Vector3 per call
  36638. * @param i defines the facet index
  36639. * @returns a new Vector3
  36640. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36641. */
  36642. getFacetNormal(i: number): Vector3;
  36643. /**
  36644. * Sets the reference Vector3 with the i-th facet normal in the world system
  36645. * @param i defines the facet index
  36646. * @param ref defines the target vector
  36647. * @returns the current mesh
  36648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36649. */
  36650. getFacetNormalToRef(i: number, ref: Vector3): this;
  36651. /**
  36652. * 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)
  36653. * @param x defines x coordinate
  36654. * @param y defines y coordinate
  36655. * @param z defines z coordinate
  36656. * @returns the array of facet indexes
  36657. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36658. */
  36659. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36660. /**
  36661. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36662. * @param projected sets as the (x,y,z) world projection on the facet
  36663. * @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
  36664. * @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
  36665. * @param x defines x coordinate
  36666. * @param y defines y coordinate
  36667. * @param z defines z coordinate
  36668. * @returns the face index if found (or null instead)
  36669. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36670. */
  36671. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36672. /**
  36673. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36674. * @param projected sets as the (x,y,z) local projection on the facet
  36675. * @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
  36676. * @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
  36677. * @param x defines x coordinate
  36678. * @param y defines y coordinate
  36679. * @param z defines z coordinate
  36680. * @returns the face index if found (or null instead)
  36681. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36682. */
  36683. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36684. /**
  36685. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36686. * @returns the parameters
  36687. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36688. */
  36689. getFacetDataParameters(): any;
  36690. /**
  36691. * Disables the feature FacetData and frees the related memory
  36692. * @returns the current mesh
  36693. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36694. */
  36695. disableFacetData(): AbstractMesh;
  36696. /**
  36697. * Updates the AbstractMesh indices array
  36698. * @param indices defines the data source
  36699. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36700. * @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)
  36701. * @returns the current mesh
  36702. */
  36703. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36704. /**
  36705. * Creates new normals data for the mesh
  36706. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36707. * @returns the current mesh
  36708. */
  36709. createNormals(updatable: boolean): AbstractMesh;
  36710. /**
  36711. * Align the mesh with a normal
  36712. * @param normal defines the normal to use
  36713. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36714. * @returns the current mesh
  36715. */
  36716. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36717. /** @hidden */
  36718. _checkOcclusionQuery(): boolean;
  36719. /**
  36720. * Disables the mesh edge rendering mode
  36721. * @returns the currentAbstractMesh
  36722. */
  36723. disableEdgesRendering(): AbstractMesh;
  36724. /**
  36725. * Enables the edge rendering mode on the mesh.
  36726. * This mode makes the mesh edges visible
  36727. * @param epsilon defines the maximal distance between two angles to detect a face
  36728. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36729. * @param options options to the edge renderer
  36730. * @returns the currentAbstractMesh
  36731. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36732. */
  36733. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36734. /**
  36735. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36736. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36737. */
  36738. getConnectedParticleSystems(): IParticleSystem[];
  36739. }
  36740. }
  36741. declare module BABYLON {
  36742. /**
  36743. * Interface used to define ActionEvent
  36744. */
  36745. export interface IActionEvent {
  36746. /** The mesh or sprite that triggered the action */
  36747. source: any;
  36748. /** The X mouse cursor position at the time of the event */
  36749. pointerX: number;
  36750. /** The Y mouse cursor position at the time of the event */
  36751. pointerY: number;
  36752. /** The mesh that is currently pointed at (can be null) */
  36753. meshUnderPointer: Nullable<AbstractMesh>;
  36754. /** the original (browser) event that triggered the ActionEvent */
  36755. sourceEvent?: any;
  36756. /** additional data for the event */
  36757. additionalData?: any;
  36758. }
  36759. /**
  36760. * ActionEvent is the event being sent when an action is triggered.
  36761. */
  36762. export class ActionEvent implements IActionEvent {
  36763. /** The mesh or sprite that triggered the action */
  36764. source: any;
  36765. /** The X mouse cursor position at the time of the event */
  36766. pointerX: number;
  36767. /** The Y mouse cursor position at the time of the event */
  36768. pointerY: number;
  36769. /** The mesh that is currently pointed at (can be null) */
  36770. meshUnderPointer: Nullable<AbstractMesh>;
  36771. /** the original (browser) event that triggered the ActionEvent */
  36772. sourceEvent?: any;
  36773. /** additional data for the event */
  36774. additionalData?: any;
  36775. /**
  36776. * Creates a new ActionEvent
  36777. * @param source The mesh or sprite that triggered the action
  36778. * @param pointerX The X mouse cursor position at the time of the event
  36779. * @param pointerY The Y mouse cursor position at the time of the event
  36780. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36781. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36782. * @param additionalData additional data for the event
  36783. */
  36784. constructor(
  36785. /** The mesh or sprite that triggered the action */
  36786. source: any,
  36787. /** The X mouse cursor position at the time of the event */
  36788. pointerX: number,
  36789. /** The Y mouse cursor position at the time of the event */
  36790. pointerY: number,
  36791. /** The mesh that is currently pointed at (can be null) */
  36792. meshUnderPointer: Nullable<AbstractMesh>,
  36793. /** the original (browser) event that triggered the ActionEvent */
  36794. sourceEvent?: any,
  36795. /** additional data for the event */
  36796. additionalData?: any);
  36797. /**
  36798. * Helper function to auto-create an ActionEvent from a source mesh.
  36799. * @param source The source mesh that triggered the event
  36800. * @param evt The original (browser) event
  36801. * @param additionalData additional data for the event
  36802. * @returns the new ActionEvent
  36803. */
  36804. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36805. /**
  36806. * Helper function to auto-create an ActionEvent from a source sprite
  36807. * @param source The source sprite that triggered the event
  36808. * @param scene Scene associated with the sprite
  36809. * @param evt The original (browser) event
  36810. * @param additionalData additional data for the event
  36811. * @returns the new ActionEvent
  36812. */
  36813. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36814. /**
  36815. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36816. * @param scene the scene where the event occurred
  36817. * @param evt The original (browser) event
  36818. * @returns the new ActionEvent
  36819. */
  36820. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36821. /**
  36822. * Helper function to auto-create an ActionEvent from a primitive
  36823. * @param prim defines the target primitive
  36824. * @param pointerPos defines the pointer position
  36825. * @param evt The original (browser) event
  36826. * @param additionalData additional data for the event
  36827. * @returns the new ActionEvent
  36828. */
  36829. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36830. }
  36831. }
  36832. declare module BABYLON {
  36833. /**
  36834. * Abstract class used to decouple action Manager from scene and meshes.
  36835. * Do not instantiate.
  36836. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36837. */
  36838. export abstract class AbstractActionManager implements IDisposable {
  36839. /** Gets the list of active triggers */
  36840. static Triggers: {
  36841. [key: string]: number;
  36842. };
  36843. /** Gets the cursor to use when hovering items */
  36844. hoverCursor: string;
  36845. /** Gets the list of actions */
  36846. actions: IAction[];
  36847. /**
  36848. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36849. */
  36850. isRecursive: boolean;
  36851. /**
  36852. * Releases all associated resources
  36853. */
  36854. abstract dispose(): void;
  36855. /**
  36856. * Does this action manager has pointer triggers
  36857. */
  36858. abstract get hasPointerTriggers(): boolean;
  36859. /**
  36860. * Does this action manager has pick triggers
  36861. */
  36862. abstract get hasPickTriggers(): boolean;
  36863. /**
  36864. * Process a specific trigger
  36865. * @param trigger defines the trigger to process
  36866. * @param evt defines the event details to be processed
  36867. */
  36868. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36869. /**
  36870. * Does this action manager handles actions of any of the given triggers
  36871. * @param triggers defines the triggers to be tested
  36872. * @return a boolean indicating whether one (or more) of the triggers is handled
  36873. */
  36874. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36875. /**
  36876. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36877. * speed.
  36878. * @param triggerA defines the trigger to be tested
  36879. * @param triggerB defines the trigger to be tested
  36880. * @return a boolean indicating whether one (or more) of the triggers is handled
  36881. */
  36882. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36883. /**
  36884. * Does this action manager handles actions of a given trigger
  36885. * @param trigger defines the trigger to be tested
  36886. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36887. * @return whether the trigger is handled
  36888. */
  36889. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36890. /**
  36891. * Serialize this manager to a JSON object
  36892. * @param name defines the property name to store this manager
  36893. * @returns a JSON representation of this manager
  36894. */
  36895. abstract serialize(name: string): any;
  36896. /**
  36897. * Registers an action to this action manager
  36898. * @param action defines the action to be registered
  36899. * @return the action amended (prepared) after registration
  36900. */
  36901. abstract registerAction(action: IAction): Nullable<IAction>;
  36902. /**
  36903. * Unregisters an action to this action manager
  36904. * @param action defines the action to be unregistered
  36905. * @return a boolean indicating whether the action has been unregistered
  36906. */
  36907. abstract unregisterAction(action: IAction): Boolean;
  36908. /**
  36909. * Does exist one action manager with at least one trigger
  36910. **/
  36911. static get HasTriggers(): boolean;
  36912. /**
  36913. * Does exist one action manager with at least one pick trigger
  36914. **/
  36915. static get HasPickTriggers(): boolean;
  36916. /**
  36917. * Does exist one action manager that handles actions of a given trigger
  36918. * @param trigger defines the trigger to be tested
  36919. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36920. **/
  36921. static HasSpecificTrigger(trigger: number): boolean;
  36922. }
  36923. }
  36924. declare module BABYLON {
  36925. /**
  36926. * Defines how a node can be built from a string name.
  36927. */
  36928. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36929. /**
  36930. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36931. */
  36932. export class Node implements IBehaviorAware<Node> {
  36933. /** @hidden */
  36934. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36935. private static _NodeConstructors;
  36936. /**
  36937. * Add a new node constructor
  36938. * @param type defines the type name of the node to construct
  36939. * @param constructorFunc defines the constructor function
  36940. */
  36941. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36942. /**
  36943. * Returns a node constructor based on type name
  36944. * @param type defines the type name
  36945. * @param name defines the new node name
  36946. * @param scene defines the hosting scene
  36947. * @param options defines optional options to transmit to constructors
  36948. * @returns the new constructor or null
  36949. */
  36950. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36951. /**
  36952. * Gets or sets the name of the node
  36953. */
  36954. name: string;
  36955. /**
  36956. * Gets or sets the id of the node
  36957. */
  36958. id: string;
  36959. /**
  36960. * Gets or sets the unique id of the node
  36961. */
  36962. uniqueId: number;
  36963. /**
  36964. * Gets or sets a string used to store user defined state for the node
  36965. */
  36966. state: string;
  36967. /**
  36968. * Gets or sets an object used to store user defined information for the node
  36969. */
  36970. metadata: any;
  36971. /**
  36972. * For internal use only. Please do not use.
  36973. */
  36974. reservedDataStore: any;
  36975. /**
  36976. * List of inspectable custom properties (used by the Inspector)
  36977. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36978. */
  36979. inspectableCustomProperties: IInspectable[];
  36980. private _doNotSerialize;
  36981. /**
  36982. * Gets or sets a boolean used to define if the node must be serialized
  36983. */
  36984. get doNotSerialize(): boolean;
  36985. set doNotSerialize(value: boolean);
  36986. /** @hidden */
  36987. _isDisposed: boolean;
  36988. /**
  36989. * Gets a list of Animations associated with the node
  36990. */
  36991. animations: Animation[];
  36992. protected _ranges: {
  36993. [name: string]: Nullable<AnimationRange>;
  36994. };
  36995. /**
  36996. * Callback raised when the node is ready to be used
  36997. */
  36998. onReady: Nullable<(node: Node) => void>;
  36999. private _isEnabled;
  37000. private _isParentEnabled;
  37001. private _isReady;
  37002. /** @hidden */
  37003. _currentRenderId: number;
  37004. private _parentUpdateId;
  37005. /** @hidden */
  37006. _childUpdateId: number;
  37007. /** @hidden */
  37008. _waitingParentId: Nullable<string>;
  37009. /** @hidden */
  37010. _scene: Scene;
  37011. /** @hidden */
  37012. _cache: any;
  37013. private _parentNode;
  37014. private _children;
  37015. /** @hidden */
  37016. _worldMatrix: Matrix;
  37017. /** @hidden */
  37018. _worldMatrixDeterminant: number;
  37019. /** @hidden */
  37020. _worldMatrixDeterminantIsDirty: boolean;
  37021. /** @hidden */
  37022. private _sceneRootNodesIndex;
  37023. /**
  37024. * Gets a boolean indicating if the node has been disposed
  37025. * @returns true if the node was disposed
  37026. */
  37027. isDisposed(): boolean;
  37028. /**
  37029. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37030. * @see https://doc.babylonjs.com/how_to/parenting
  37031. */
  37032. set parent(parent: Nullable<Node>);
  37033. get parent(): Nullable<Node>;
  37034. /** @hidden */
  37035. _addToSceneRootNodes(): void;
  37036. /** @hidden */
  37037. _removeFromSceneRootNodes(): void;
  37038. private _animationPropertiesOverride;
  37039. /**
  37040. * Gets or sets the animation properties override
  37041. */
  37042. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37043. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37044. /**
  37045. * Gets a string identifying the name of the class
  37046. * @returns "Node" string
  37047. */
  37048. getClassName(): string;
  37049. /** @hidden */
  37050. readonly _isNode: boolean;
  37051. /**
  37052. * An event triggered when the mesh is disposed
  37053. */
  37054. onDisposeObservable: Observable<Node>;
  37055. private _onDisposeObserver;
  37056. /**
  37057. * Sets a callback that will be raised when the node will be disposed
  37058. */
  37059. set onDispose(callback: () => void);
  37060. /**
  37061. * Creates a new Node
  37062. * @param name the name and id to be given to this node
  37063. * @param scene the scene this node will be added to
  37064. */
  37065. constructor(name: string, scene?: Nullable<Scene>);
  37066. /**
  37067. * Gets the scene of the node
  37068. * @returns a scene
  37069. */
  37070. getScene(): Scene;
  37071. /**
  37072. * Gets the engine of the node
  37073. * @returns a Engine
  37074. */
  37075. getEngine(): Engine;
  37076. private _behaviors;
  37077. /**
  37078. * Attach a behavior to the node
  37079. * @see https://doc.babylonjs.com/features/behaviour
  37080. * @param behavior defines the behavior to attach
  37081. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37082. * @returns the current Node
  37083. */
  37084. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37085. /**
  37086. * Remove an attached behavior
  37087. * @see https://doc.babylonjs.com/features/behaviour
  37088. * @param behavior defines the behavior to attach
  37089. * @returns the current Node
  37090. */
  37091. removeBehavior(behavior: Behavior<Node>): Node;
  37092. /**
  37093. * Gets the list of attached behaviors
  37094. * @see https://doc.babylonjs.com/features/behaviour
  37095. */
  37096. get behaviors(): Behavior<Node>[];
  37097. /**
  37098. * Gets an attached behavior by name
  37099. * @param name defines the name of the behavior to look for
  37100. * @see https://doc.babylonjs.com/features/behaviour
  37101. * @returns null if behavior was not found else the requested behavior
  37102. */
  37103. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37104. /**
  37105. * Returns the latest update of the World matrix
  37106. * @returns a Matrix
  37107. */
  37108. getWorldMatrix(): Matrix;
  37109. /** @hidden */
  37110. _getWorldMatrixDeterminant(): number;
  37111. /**
  37112. * Returns directly the latest state of the mesh World matrix.
  37113. * A Matrix is returned.
  37114. */
  37115. get worldMatrixFromCache(): Matrix;
  37116. /** @hidden */
  37117. _initCache(): void;
  37118. /** @hidden */
  37119. updateCache(force?: boolean): void;
  37120. /** @hidden */
  37121. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37122. /** @hidden */
  37123. _updateCache(ignoreParentClass?: boolean): void;
  37124. /** @hidden */
  37125. _isSynchronized(): boolean;
  37126. /** @hidden */
  37127. _markSyncedWithParent(): void;
  37128. /** @hidden */
  37129. isSynchronizedWithParent(): boolean;
  37130. /** @hidden */
  37131. isSynchronized(): boolean;
  37132. /**
  37133. * Is this node ready to be used/rendered
  37134. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37135. * @return true if the node is ready
  37136. */
  37137. isReady(completeCheck?: boolean): boolean;
  37138. /**
  37139. * Is this node enabled?
  37140. * 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
  37141. * @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
  37142. * @return whether this node (and its parent) is enabled
  37143. */
  37144. isEnabled(checkAncestors?: boolean): boolean;
  37145. /** @hidden */
  37146. protected _syncParentEnabledState(): void;
  37147. /**
  37148. * Set the enabled state of this node
  37149. * @param value defines the new enabled state
  37150. */
  37151. setEnabled(value: boolean): void;
  37152. /**
  37153. * Is this node a descendant of the given node?
  37154. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37155. * @param ancestor defines the parent node to inspect
  37156. * @returns a boolean indicating if this node is a descendant of the given node
  37157. */
  37158. isDescendantOf(ancestor: Node): boolean;
  37159. /** @hidden */
  37160. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37161. /**
  37162. * Will return all nodes that have this node as ascendant
  37163. * @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
  37164. * @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
  37165. * @return all children nodes of all types
  37166. */
  37167. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37168. /**
  37169. * Get all child-meshes of this node
  37170. * @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)
  37171. * @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
  37172. * @returns an array of AbstractMesh
  37173. */
  37174. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37175. /**
  37176. * Get all direct children of this node
  37177. * @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
  37178. * @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)
  37179. * @returns an array of Node
  37180. */
  37181. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37182. /** @hidden */
  37183. _setReady(state: boolean): void;
  37184. /**
  37185. * Get an animation by name
  37186. * @param name defines the name of the animation to look for
  37187. * @returns null if not found else the requested animation
  37188. */
  37189. getAnimationByName(name: string): Nullable<Animation>;
  37190. /**
  37191. * Creates an animation range for this node
  37192. * @param name defines the name of the range
  37193. * @param from defines the starting key
  37194. * @param to defines the end key
  37195. */
  37196. createAnimationRange(name: string, from: number, to: number): void;
  37197. /**
  37198. * Delete a specific animation range
  37199. * @param name defines the name of the range to delete
  37200. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37201. */
  37202. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37203. /**
  37204. * Get an animation range by name
  37205. * @param name defines the name of the animation range to look for
  37206. * @returns null if not found else the requested animation range
  37207. */
  37208. getAnimationRange(name: string): Nullable<AnimationRange>;
  37209. /**
  37210. * Gets the list of all animation ranges defined on this node
  37211. * @returns an array
  37212. */
  37213. getAnimationRanges(): Nullable<AnimationRange>[];
  37214. /**
  37215. * Will start the animation sequence
  37216. * @param name defines the range frames for animation sequence
  37217. * @param loop defines if the animation should loop (false by default)
  37218. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37219. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37220. * @returns the object created for this animation. If range does not exist, it will return null
  37221. */
  37222. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37223. /**
  37224. * Serialize animation ranges into a JSON compatible object
  37225. * @returns serialization object
  37226. */
  37227. serializeAnimationRanges(): any;
  37228. /**
  37229. * Computes the world matrix of the node
  37230. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37231. * @returns the world matrix
  37232. */
  37233. computeWorldMatrix(force?: boolean): Matrix;
  37234. /**
  37235. * Releases resources associated with this node.
  37236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37238. */
  37239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37240. /**
  37241. * Parse animation range data from a serialization object and store them into a given node
  37242. * @param node defines where to store the animation ranges
  37243. * @param parsedNode defines the serialization object to read data from
  37244. * @param scene defines the hosting scene
  37245. */
  37246. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37247. /**
  37248. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37249. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37250. * @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
  37251. * @returns the new bounding vectors
  37252. */
  37253. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37254. min: Vector3;
  37255. max: Vector3;
  37256. };
  37257. }
  37258. }
  37259. declare module BABYLON {
  37260. /**
  37261. * @hidden
  37262. */
  37263. export class _IAnimationState {
  37264. key: number;
  37265. repeatCount: number;
  37266. workValue?: any;
  37267. loopMode?: number;
  37268. offsetValue?: any;
  37269. highLimitValue?: any;
  37270. }
  37271. /**
  37272. * Class used to store any kind of animation
  37273. */
  37274. export class Animation {
  37275. /**Name of the animation */
  37276. name: string;
  37277. /**Property to animate */
  37278. targetProperty: string;
  37279. /**The frames per second of the animation */
  37280. framePerSecond: number;
  37281. /**The data type of the animation */
  37282. dataType: number;
  37283. /**The loop mode of the animation */
  37284. loopMode?: number | undefined;
  37285. /**Specifies if blending should be enabled */
  37286. enableBlending?: boolean | undefined;
  37287. /**
  37288. * Use matrix interpolation instead of using direct key value when animating matrices
  37289. */
  37290. static AllowMatricesInterpolation: boolean;
  37291. /**
  37292. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37293. */
  37294. static AllowMatrixDecomposeForInterpolation: boolean;
  37295. /** Define the Url to load snippets */
  37296. static SnippetUrl: string;
  37297. /** Snippet ID if the animation was created from the snippet server */
  37298. snippetId: string;
  37299. /**
  37300. * Stores the key frames of the animation
  37301. */
  37302. private _keys;
  37303. /**
  37304. * Stores the easing function of the animation
  37305. */
  37306. private _easingFunction;
  37307. /**
  37308. * @hidden Internal use only
  37309. */
  37310. _runtimeAnimations: RuntimeAnimation[];
  37311. /**
  37312. * The set of event that will be linked to this animation
  37313. */
  37314. private _events;
  37315. /**
  37316. * Stores an array of target property paths
  37317. */
  37318. targetPropertyPath: string[];
  37319. /**
  37320. * Stores the blending speed of the animation
  37321. */
  37322. blendingSpeed: number;
  37323. /**
  37324. * Stores the animation ranges for the animation
  37325. */
  37326. private _ranges;
  37327. /**
  37328. * @hidden Internal use
  37329. */
  37330. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37331. /**
  37332. * Sets up an animation
  37333. * @param property The property to animate
  37334. * @param animationType The animation type to apply
  37335. * @param framePerSecond The frames per second of the animation
  37336. * @param easingFunction The easing function used in the animation
  37337. * @returns The created animation
  37338. */
  37339. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37340. /**
  37341. * Create and start an animation on a node
  37342. * @param name defines the name of the global animation that will be run on all nodes
  37343. * @param node defines the root node where the animation will take place
  37344. * @param targetProperty defines property to animate
  37345. * @param framePerSecond defines the number of frame per second yo use
  37346. * @param totalFrame defines the number of frames in total
  37347. * @param from defines the initial value
  37348. * @param to defines the final value
  37349. * @param loopMode defines which loop mode you want to use (off by default)
  37350. * @param easingFunction defines the easing function to use (linear by default)
  37351. * @param onAnimationEnd defines the callback to call when animation end
  37352. * @returns the animatable created for this animation
  37353. */
  37354. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37355. /**
  37356. * Create and start an animation on a node and its descendants
  37357. * @param name defines the name of the global animation that will be run on all nodes
  37358. * @param node defines the root node where the animation will take place
  37359. * @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
  37360. * @param targetProperty defines property to animate
  37361. * @param framePerSecond defines the number of frame per second to use
  37362. * @param totalFrame defines the number of frames in total
  37363. * @param from defines the initial value
  37364. * @param to defines the final value
  37365. * @param loopMode defines which loop mode you want to use (off by default)
  37366. * @param easingFunction defines the easing function to use (linear by default)
  37367. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37368. * @returns the list of animatables created for all nodes
  37369. * @example https://www.babylonjs-playground.com/#MH0VLI
  37370. */
  37371. 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[]>;
  37372. /**
  37373. * Creates a new animation, merges it with the existing animations and starts it
  37374. * @param name Name of the animation
  37375. * @param node Node which contains the scene that begins the animations
  37376. * @param targetProperty Specifies which property to animate
  37377. * @param framePerSecond The frames per second of the animation
  37378. * @param totalFrame The total number of frames
  37379. * @param from The frame at the beginning of the animation
  37380. * @param to The frame at the end of the animation
  37381. * @param loopMode Specifies the loop mode of the animation
  37382. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37383. * @param onAnimationEnd Callback to run once the animation is complete
  37384. * @returns Nullable animation
  37385. */
  37386. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37387. /**
  37388. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37389. * @param sourceAnimation defines the Animation containing keyframes to convert
  37390. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37391. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37392. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37393. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37394. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37395. */
  37396. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37397. /**
  37398. * Transition property of an host to the target Value
  37399. * @param property The property to transition
  37400. * @param targetValue The target Value of the property
  37401. * @param host The object where the property to animate belongs
  37402. * @param scene Scene used to run the animation
  37403. * @param frameRate Framerate (in frame/s) to use
  37404. * @param transition The transition type we want to use
  37405. * @param duration The duration of the animation, in milliseconds
  37406. * @param onAnimationEnd Callback trigger at the end of the animation
  37407. * @returns Nullable animation
  37408. */
  37409. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37410. /**
  37411. * Return the array of runtime animations currently using this animation
  37412. */
  37413. get runtimeAnimations(): RuntimeAnimation[];
  37414. /**
  37415. * Specifies if any of the runtime animations are currently running
  37416. */
  37417. get hasRunningRuntimeAnimations(): boolean;
  37418. /**
  37419. * Initializes the animation
  37420. * @param name Name of the animation
  37421. * @param targetProperty Property to animate
  37422. * @param framePerSecond The frames per second of the animation
  37423. * @param dataType The data type of the animation
  37424. * @param loopMode The loop mode of the animation
  37425. * @param enableBlending Specifies if blending should be enabled
  37426. */
  37427. constructor(
  37428. /**Name of the animation */
  37429. name: string,
  37430. /**Property to animate */
  37431. targetProperty: string,
  37432. /**The frames per second of the animation */
  37433. framePerSecond: number,
  37434. /**The data type of the animation */
  37435. dataType: number,
  37436. /**The loop mode of the animation */
  37437. loopMode?: number | undefined,
  37438. /**Specifies if blending should be enabled */
  37439. enableBlending?: boolean | undefined);
  37440. /**
  37441. * Converts the animation to a string
  37442. * @param fullDetails support for multiple levels of logging within scene loading
  37443. * @returns String form of the animation
  37444. */
  37445. toString(fullDetails?: boolean): string;
  37446. /**
  37447. * Add an event to this animation
  37448. * @param event Event to add
  37449. */
  37450. addEvent(event: AnimationEvent): void;
  37451. /**
  37452. * Remove all events found at the given frame
  37453. * @param frame The frame to remove events from
  37454. */
  37455. removeEvents(frame: number): void;
  37456. /**
  37457. * Retrieves all the events from the animation
  37458. * @returns Events from the animation
  37459. */
  37460. getEvents(): AnimationEvent[];
  37461. /**
  37462. * Creates an animation range
  37463. * @param name Name of the animation range
  37464. * @param from Starting frame of the animation range
  37465. * @param to Ending frame of the animation
  37466. */
  37467. createRange(name: string, from: number, to: number): void;
  37468. /**
  37469. * Deletes an animation range by name
  37470. * @param name Name of the animation range to delete
  37471. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37472. */
  37473. deleteRange(name: string, deleteFrames?: boolean): void;
  37474. /**
  37475. * Gets the animation range by name, or null if not defined
  37476. * @param name Name of the animation range
  37477. * @returns Nullable animation range
  37478. */
  37479. getRange(name: string): Nullable<AnimationRange>;
  37480. /**
  37481. * Gets the key frames from the animation
  37482. * @returns The key frames of the animation
  37483. */
  37484. getKeys(): Array<IAnimationKey>;
  37485. /**
  37486. * Gets the highest frame rate of the animation
  37487. * @returns Highest frame rate of the animation
  37488. */
  37489. getHighestFrame(): number;
  37490. /**
  37491. * Gets the easing function of the animation
  37492. * @returns Easing function of the animation
  37493. */
  37494. getEasingFunction(): IEasingFunction;
  37495. /**
  37496. * Sets the easing function of the animation
  37497. * @param easingFunction A custom mathematical formula for animation
  37498. */
  37499. setEasingFunction(easingFunction: EasingFunction): void;
  37500. /**
  37501. * Interpolates a scalar linearly
  37502. * @param startValue Start value of the animation curve
  37503. * @param endValue End value of the animation curve
  37504. * @param gradient Scalar amount to interpolate
  37505. * @returns Interpolated scalar value
  37506. */
  37507. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37508. /**
  37509. * Interpolates a scalar cubically
  37510. * @param startValue Start value of the animation curve
  37511. * @param outTangent End tangent of the animation
  37512. * @param endValue End value of the animation curve
  37513. * @param inTangent Start tangent of the animation curve
  37514. * @param gradient Scalar amount to interpolate
  37515. * @returns Interpolated scalar value
  37516. */
  37517. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37518. /**
  37519. * Interpolates a quaternion using a spherical linear interpolation
  37520. * @param startValue Start value of the animation curve
  37521. * @param endValue End value of the animation curve
  37522. * @param gradient Scalar amount to interpolate
  37523. * @returns Interpolated quaternion value
  37524. */
  37525. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37526. /**
  37527. * Interpolates a quaternion cubically
  37528. * @param startValue Start value of the animation curve
  37529. * @param outTangent End tangent of the animation curve
  37530. * @param endValue End value of the animation curve
  37531. * @param inTangent Start tangent of the animation curve
  37532. * @param gradient Scalar amount to interpolate
  37533. * @returns Interpolated quaternion value
  37534. */
  37535. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37536. /**
  37537. * Interpolates a Vector3 linearl
  37538. * @param startValue Start value of the animation curve
  37539. * @param endValue End value of the animation curve
  37540. * @param gradient Scalar amount to interpolate
  37541. * @returns Interpolated scalar value
  37542. */
  37543. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37544. /**
  37545. * Interpolates a Vector3 cubically
  37546. * @param startValue Start value of the animation curve
  37547. * @param outTangent End tangent of the animation
  37548. * @param endValue End value of the animation curve
  37549. * @param inTangent Start tangent of the animation curve
  37550. * @param gradient Scalar amount to interpolate
  37551. * @returns InterpolatedVector3 value
  37552. */
  37553. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37554. /**
  37555. * Interpolates a Vector2 linearly
  37556. * @param startValue Start value of the animation curve
  37557. * @param endValue End value of the animation curve
  37558. * @param gradient Scalar amount to interpolate
  37559. * @returns Interpolated Vector2 value
  37560. */
  37561. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37562. /**
  37563. * Interpolates a Vector2 cubically
  37564. * @param startValue Start value of the animation curve
  37565. * @param outTangent End tangent of the animation
  37566. * @param endValue End value of the animation curve
  37567. * @param inTangent Start tangent of the animation curve
  37568. * @param gradient Scalar amount to interpolate
  37569. * @returns Interpolated Vector2 value
  37570. */
  37571. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37572. /**
  37573. * Interpolates a size linearly
  37574. * @param startValue Start value of the animation curve
  37575. * @param endValue End value of the animation curve
  37576. * @param gradient Scalar amount to interpolate
  37577. * @returns Interpolated Size value
  37578. */
  37579. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37580. /**
  37581. * Interpolates a Color3 linearly
  37582. * @param startValue Start value of the animation curve
  37583. * @param endValue End value of the animation curve
  37584. * @param gradient Scalar amount to interpolate
  37585. * @returns Interpolated Color3 value
  37586. */
  37587. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37588. /**
  37589. * Interpolates a Color4 linearly
  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 Color3 value
  37594. */
  37595. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37596. /**
  37597. * @hidden Internal use only
  37598. */
  37599. _getKeyValue(value: any): any;
  37600. /**
  37601. * @hidden Internal use only
  37602. */
  37603. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37604. /**
  37605. * Defines the function to use to interpolate matrices
  37606. * @param startValue defines the start matrix
  37607. * @param endValue defines the end matrix
  37608. * @param gradient defines the gradient between both matrices
  37609. * @param result defines an optional target matrix where to store the interpolation
  37610. * @returns the interpolated matrix
  37611. */
  37612. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37613. /**
  37614. * Makes a copy of the animation
  37615. * @returns Cloned animation
  37616. */
  37617. clone(): Animation;
  37618. /**
  37619. * Sets the key frames of the animation
  37620. * @param values The animation key frames to set
  37621. */
  37622. setKeys(values: Array<IAnimationKey>): void;
  37623. /**
  37624. * Serializes the animation to an object
  37625. * @returns Serialized object
  37626. */
  37627. serialize(): any;
  37628. /**
  37629. * Float animation type
  37630. */
  37631. static readonly ANIMATIONTYPE_FLOAT: number;
  37632. /**
  37633. * Vector3 animation type
  37634. */
  37635. static readonly ANIMATIONTYPE_VECTOR3: number;
  37636. /**
  37637. * Quaternion animation type
  37638. */
  37639. static readonly ANIMATIONTYPE_QUATERNION: number;
  37640. /**
  37641. * Matrix animation type
  37642. */
  37643. static readonly ANIMATIONTYPE_MATRIX: number;
  37644. /**
  37645. * Color3 animation type
  37646. */
  37647. static readonly ANIMATIONTYPE_COLOR3: number;
  37648. /**
  37649. * Color3 animation type
  37650. */
  37651. static readonly ANIMATIONTYPE_COLOR4: number;
  37652. /**
  37653. * Vector2 animation type
  37654. */
  37655. static readonly ANIMATIONTYPE_VECTOR2: number;
  37656. /**
  37657. * Size animation type
  37658. */
  37659. static readonly ANIMATIONTYPE_SIZE: number;
  37660. /**
  37661. * Relative Loop Mode
  37662. */
  37663. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37664. /**
  37665. * Cycle Loop Mode
  37666. */
  37667. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37668. /**
  37669. * Constant Loop Mode
  37670. */
  37671. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37672. /** @hidden */
  37673. static _UniversalLerp(left: any, right: any, amount: number): any;
  37674. /**
  37675. * Parses an animation object and creates an animation
  37676. * @param parsedAnimation Parsed animation object
  37677. * @returns Animation object
  37678. */
  37679. static Parse(parsedAnimation: any): Animation;
  37680. /**
  37681. * Appends the serialized animations from the source animations
  37682. * @param source Source containing the animations
  37683. * @param destination Target to store the animations
  37684. */
  37685. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37686. /**
  37687. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37688. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37689. * @param url defines the url to load from
  37690. * @returns a promise that will resolve to the new animation or an array of animations
  37691. */
  37692. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37693. /**
  37694. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37695. * @param snippetId defines the snippet to load
  37696. * @returns a promise that will resolve to the new animation or a new array of animations
  37697. */
  37698. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37699. }
  37700. }
  37701. declare module BABYLON {
  37702. /**
  37703. * Interface containing an array of animations
  37704. */
  37705. export interface IAnimatable {
  37706. /**
  37707. * Array of animations
  37708. */
  37709. animations: Nullable<Array<Animation>>;
  37710. }
  37711. }
  37712. declare module BABYLON {
  37713. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37714. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37715. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37716. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37717. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37718. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37719. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37720. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37721. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37722. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37723. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37724. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37725. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37726. /**
  37727. * Decorator used to define property that can be serialized as reference to a camera
  37728. * @param sourceName defines the name of the property to decorate
  37729. */
  37730. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37731. /**
  37732. * Class used to help serialization objects
  37733. */
  37734. export class SerializationHelper {
  37735. /** @hidden */
  37736. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37737. /** @hidden */
  37738. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37739. /** @hidden */
  37740. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37741. /** @hidden */
  37742. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37743. /**
  37744. * Appends the serialized animations from the source animations
  37745. * @param source Source containing the animations
  37746. * @param destination Target to store the animations
  37747. */
  37748. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37749. /**
  37750. * Static function used to serialized a specific entity
  37751. * @param entity defines the entity to serialize
  37752. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37753. * @returns a JSON compatible object representing the serialization of the entity
  37754. */
  37755. static Serialize<T>(entity: T, serializationObject?: any): any;
  37756. /**
  37757. * Creates a new entity from a serialization data object
  37758. * @param creationFunction defines a function used to instanciated the new entity
  37759. * @param source defines the source serialization data
  37760. * @param scene defines the hosting scene
  37761. * @param rootUrl defines the root url for resources
  37762. * @returns a new entity
  37763. */
  37764. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37765. /**
  37766. * Clones an object
  37767. * @param creationFunction defines the function used to instanciate the new object
  37768. * @param source defines the source object
  37769. * @returns the cloned object
  37770. */
  37771. static Clone<T>(creationFunction: () => T, source: T): T;
  37772. /**
  37773. * Instanciates a new object based on a source one (some data will be shared between both object)
  37774. * @param creationFunction defines the function used to instanciate the new object
  37775. * @param source defines the source object
  37776. * @returns the new object
  37777. */
  37778. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37779. }
  37780. }
  37781. declare module BABYLON {
  37782. /**
  37783. * This is the base class of all the camera used in the application.
  37784. * @see https://doc.babylonjs.com/features/cameras
  37785. */
  37786. export class Camera extends Node {
  37787. /** @hidden */
  37788. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37789. /**
  37790. * This is the default projection mode used by the cameras.
  37791. * It helps recreating a feeling of perspective and better appreciate depth.
  37792. * This is the best way to simulate real life cameras.
  37793. */
  37794. static readonly PERSPECTIVE_CAMERA: number;
  37795. /**
  37796. * This helps creating camera with an orthographic mode.
  37797. * 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.
  37798. */
  37799. static readonly ORTHOGRAPHIC_CAMERA: number;
  37800. /**
  37801. * This is the default FOV mode for perspective cameras.
  37802. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37803. */
  37804. static readonly FOVMODE_VERTICAL_FIXED: number;
  37805. /**
  37806. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37807. */
  37808. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37809. /**
  37810. * This specifies ther is no need for a camera rig.
  37811. * Basically only one eye is rendered corresponding to the camera.
  37812. */
  37813. static readonly RIG_MODE_NONE: number;
  37814. /**
  37815. * Simulates a camera Rig with one blue eye and one red eye.
  37816. * This can be use with 3d blue and red glasses.
  37817. */
  37818. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37819. /**
  37820. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37821. */
  37822. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37823. /**
  37824. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37825. */
  37826. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37827. /**
  37828. * Defines that both eyes of the camera will be rendered over under each other.
  37829. */
  37830. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37831. /**
  37832. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37833. */
  37834. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37835. /**
  37836. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37837. */
  37838. static readonly RIG_MODE_VR: number;
  37839. /**
  37840. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37841. */
  37842. static readonly RIG_MODE_WEBVR: number;
  37843. /**
  37844. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37845. */
  37846. static readonly RIG_MODE_CUSTOM: number;
  37847. /**
  37848. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37849. */
  37850. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37851. /**
  37852. * Define the input manager associated with the camera.
  37853. */
  37854. inputs: CameraInputsManager<Camera>;
  37855. /** @hidden */
  37856. _position: Vector3;
  37857. /**
  37858. * Define the current local position of the camera in the scene
  37859. */
  37860. get position(): Vector3;
  37861. set position(newPosition: Vector3);
  37862. protected _upVector: Vector3;
  37863. /**
  37864. * The vector the camera should consider as up.
  37865. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37866. */
  37867. set upVector(vec: Vector3);
  37868. get upVector(): Vector3;
  37869. /**
  37870. * Define the current limit on the left side for an orthographic camera
  37871. * In scene unit
  37872. */
  37873. orthoLeft: Nullable<number>;
  37874. /**
  37875. * Define the current limit on the right side for an orthographic camera
  37876. * In scene unit
  37877. */
  37878. orthoRight: Nullable<number>;
  37879. /**
  37880. * Define the current limit on the bottom side for an orthographic camera
  37881. * In scene unit
  37882. */
  37883. orthoBottom: Nullable<number>;
  37884. /**
  37885. * Define the current limit on the top side for an orthographic camera
  37886. * In scene unit
  37887. */
  37888. orthoTop: Nullable<number>;
  37889. /**
  37890. * Field Of View is set in Radians. (default is 0.8)
  37891. */
  37892. fov: number;
  37893. /**
  37894. * Define the minimum distance the camera can see from.
  37895. * This is important to note that the depth buffer are not infinite and the closer it starts
  37896. * the more your scene might encounter depth fighting issue.
  37897. */
  37898. minZ: number;
  37899. /**
  37900. * Define the maximum distance the camera can see to.
  37901. * This is important to note that the depth buffer are not infinite and the further it end
  37902. * the more your scene might encounter depth fighting issue.
  37903. */
  37904. maxZ: number;
  37905. /**
  37906. * Define the default inertia of the camera.
  37907. * This helps giving a smooth feeling to the camera movement.
  37908. */
  37909. inertia: number;
  37910. /**
  37911. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37912. */
  37913. mode: number;
  37914. /**
  37915. * Define whether the camera is intermediate.
  37916. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37917. */
  37918. isIntermediate: boolean;
  37919. /**
  37920. * Define the viewport of the camera.
  37921. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37922. */
  37923. viewport: Viewport;
  37924. /**
  37925. * Restricts the camera to viewing objects with the same layerMask.
  37926. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37927. */
  37928. layerMask: number;
  37929. /**
  37930. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37931. */
  37932. fovMode: number;
  37933. /**
  37934. * Rig mode of the camera.
  37935. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37936. * This is normally controlled byt the camera themselves as internal use.
  37937. */
  37938. cameraRigMode: number;
  37939. /**
  37940. * Defines the distance between both "eyes" in case of a RIG
  37941. */
  37942. interaxialDistance: number;
  37943. /**
  37944. * Defines if stereoscopic rendering is done side by side or over under.
  37945. */
  37946. isStereoscopicSideBySide: boolean;
  37947. /**
  37948. * 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
  37949. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37950. * else in the scene. (Eg. security camera)
  37951. *
  37952. * 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)
  37953. */
  37954. customRenderTargets: RenderTargetTexture[];
  37955. /**
  37956. * When set, the camera will render to this render target instead of the default canvas
  37957. *
  37958. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37959. */
  37960. outputRenderTarget: Nullable<RenderTargetTexture>;
  37961. /**
  37962. * Observable triggered when the camera view matrix has changed.
  37963. */
  37964. onViewMatrixChangedObservable: Observable<Camera>;
  37965. /**
  37966. * Observable triggered when the camera Projection matrix has changed.
  37967. */
  37968. onProjectionMatrixChangedObservable: Observable<Camera>;
  37969. /**
  37970. * Observable triggered when the inputs have been processed.
  37971. */
  37972. onAfterCheckInputsObservable: Observable<Camera>;
  37973. /**
  37974. * Observable triggered when reset has been called and applied to the camera.
  37975. */
  37976. onRestoreStateObservable: Observable<Camera>;
  37977. /**
  37978. * Is this camera a part of a rig system?
  37979. */
  37980. isRigCamera: boolean;
  37981. /**
  37982. * If isRigCamera set to true this will be set with the parent camera.
  37983. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37984. */
  37985. rigParent?: Camera;
  37986. /** @hidden */
  37987. _cameraRigParams: any;
  37988. /** @hidden */
  37989. _rigCameras: Camera[];
  37990. /** @hidden */
  37991. _rigPostProcess: Nullable<PostProcess>;
  37992. protected _webvrViewMatrix: Matrix;
  37993. /** @hidden */
  37994. _skipRendering: boolean;
  37995. /** @hidden */
  37996. _projectionMatrix: Matrix;
  37997. /** @hidden */
  37998. _postProcesses: Nullable<PostProcess>[];
  37999. /** @hidden */
  38000. _activeMeshes: SmartArray<AbstractMesh>;
  38001. protected _globalPosition: Vector3;
  38002. /** @hidden */
  38003. _computedViewMatrix: Matrix;
  38004. private _doNotComputeProjectionMatrix;
  38005. private _transformMatrix;
  38006. private _frustumPlanes;
  38007. private _refreshFrustumPlanes;
  38008. private _storedFov;
  38009. private _stateStored;
  38010. /**
  38011. * Instantiates a new camera object.
  38012. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38013. * @see https://doc.babylonjs.com/features/cameras
  38014. * @param name Defines the name of the camera in the scene
  38015. * @param position Defines the position of the camera
  38016. * @param scene Defines the scene the camera belongs too
  38017. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38018. */
  38019. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38020. /**
  38021. * Store current camera state (fov, position, etc..)
  38022. * @returns the camera
  38023. */
  38024. storeState(): Camera;
  38025. /**
  38026. * Restores the camera state values if it has been stored. You must call storeState() first
  38027. */
  38028. protected _restoreStateValues(): boolean;
  38029. /**
  38030. * Restored camera state. You must call storeState() first.
  38031. * @returns true if restored and false otherwise
  38032. */
  38033. restoreState(): boolean;
  38034. /**
  38035. * Gets the class name of the camera.
  38036. * @returns the class name
  38037. */
  38038. getClassName(): string;
  38039. /** @hidden */
  38040. readonly _isCamera: boolean;
  38041. /**
  38042. * Gets a string representation of the camera useful for debug purpose.
  38043. * @param fullDetails Defines that a more verboe level of logging is required
  38044. * @returns the string representation
  38045. */
  38046. toString(fullDetails?: boolean): string;
  38047. /**
  38048. * Gets the current world space position of the camera.
  38049. */
  38050. get globalPosition(): Vector3;
  38051. /**
  38052. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38053. * @returns the active meshe list
  38054. */
  38055. getActiveMeshes(): SmartArray<AbstractMesh>;
  38056. /**
  38057. * Check whether a mesh is part of the current active mesh list of the camera
  38058. * @param mesh Defines the mesh to check
  38059. * @returns true if active, false otherwise
  38060. */
  38061. isActiveMesh(mesh: Mesh): boolean;
  38062. /**
  38063. * Is this camera ready to be used/rendered
  38064. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38065. * @return true if the camera is ready
  38066. */
  38067. isReady(completeCheck?: boolean): boolean;
  38068. /** @hidden */
  38069. _initCache(): void;
  38070. /** @hidden */
  38071. _updateCache(ignoreParentClass?: boolean): void;
  38072. /** @hidden */
  38073. _isSynchronized(): boolean;
  38074. /** @hidden */
  38075. _isSynchronizedViewMatrix(): boolean;
  38076. /** @hidden */
  38077. _isSynchronizedProjectionMatrix(): boolean;
  38078. /**
  38079. * Attach the input controls to a specific dom element to get the input from.
  38080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38081. */
  38082. attachControl(noPreventDefault?: boolean): void;
  38083. /**
  38084. * Attach the input controls to a specific dom element to get the input from.
  38085. * @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
  38086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38087. * BACK COMPAT SIGNATURE ONLY.
  38088. */
  38089. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38090. /**
  38091. * Detach the current controls from the specified dom element.
  38092. */
  38093. detachControl(): void;
  38094. /**
  38095. * Detach the current controls from the specified dom element.
  38096. * @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
  38097. */
  38098. detachControl(ignored: any): void;
  38099. /**
  38100. * Update the camera state according to the different inputs gathered during the frame.
  38101. */
  38102. update(): void;
  38103. /** @hidden */
  38104. _checkInputs(): void;
  38105. /** @hidden */
  38106. get rigCameras(): Camera[];
  38107. /**
  38108. * Gets the post process used by the rig cameras
  38109. */
  38110. get rigPostProcess(): Nullable<PostProcess>;
  38111. /**
  38112. * Internal, gets the first post proces.
  38113. * @returns the first post process to be run on this camera.
  38114. */
  38115. _getFirstPostProcess(): Nullable<PostProcess>;
  38116. private _cascadePostProcessesToRigCams;
  38117. /**
  38118. * Attach a post process to the camera.
  38119. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38120. * @param postProcess The post process to attach to the camera
  38121. * @param insertAt The position of the post process in case several of them are in use in the scene
  38122. * @returns the position the post process has been inserted at
  38123. */
  38124. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38125. /**
  38126. * Detach a post process to the camera.
  38127. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38128. * @param postProcess The post process to detach from the camera
  38129. */
  38130. detachPostProcess(postProcess: PostProcess): void;
  38131. /**
  38132. * Gets the current world matrix of the camera
  38133. */
  38134. getWorldMatrix(): Matrix;
  38135. /** @hidden */
  38136. _getViewMatrix(): Matrix;
  38137. /**
  38138. * Gets the current view matrix of the camera.
  38139. * @param force forces the camera to recompute the matrix without looking at the cached state
  38140. * @returns the view matrix
  38141. */
  38142. getViewMatrix(force?: boolean): Matrix;
  38143. /**
  38144. * Freeze the projection matrix.
  38145. * It will prevent the cache check of the camera projection compute and can speed up perf
  38146. * if no parameter of the camera are meant to change
  38147. * @param projection Defines manually a projection if necessary
  38148. */
  38149. freezeProjectionMatrix(projection?: Matrix): void;
  38150. /**
  38151. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38152. */
  38153. unfreezeProjectionMatrix(): void;
  38154. /**
  38155. * Gets the current projection matrix of the camera.
  38156. * @param force forces the camera to recompute the matrix without looking at the cached state
  38157. * @returns the projection matrix
  38158. */
  38159. getProjectionMatrix(force?: boolean): Matrix;
  38160. /**
  38161. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38162. * @returns a Matrix
  38163. */
  38164. getTransformationMatrix(): Matrix;
  38165. private _updateFrustumPlanes;
  38166. /**
  38167. * Checks if a cullable object (mesh...) is in the camera frustum
  38168. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38169. * @param target The object to check
  38170. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38171. * @returns true if the object is in frustum otherwise false
  38172. */
  38173. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38174. /**
  38175. * Checks if a cullable object (mesh...) is in the camera frustum
  38176. * Unlike isInFrustum this cheks the full bounding box
  38177. * @param target The object to check
  38178. * @returns true if the object is in frustum otherwise false
  38179. */
  38180. isCompletelyInFrustum(target: ICullable): boolean;
  38181. /**
  38182. * Gets a ray in the forward direction from the camera.
  38183. * @param length Defines the length of the ray to create
  38184. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38185. * @param origin Defines the start point of the ray which defaults to the camera position
  38186. * @returns the forward ray
  38187. */
  38188. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38189. /**
  38190. * Gets a ray in the forward direction from the camera.
  38191. * @param refRay the ray to (re)use when setting the values
  38192. * @param length Defines the length of the ray to create
  38193. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38194. * @param origin Defines the start point of the ray which defaults to the camera position
  38195. * @returns the forward ray
  38196. */
  38197. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38198. /**
  38199. * Releases resources associated with this node.
  38200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38202. */
  38203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38204. /** @hidden */
  38205. _isLeftCamera: boolean;
  38206. /**
  38207. * Gets the left camera of a rig setup in case of Rigged Camera
  38208. */
  38209. get isLeftCamera(): boolean;
  38210. /** @hidden */
  38211. _isRightCamera: boolean;
  38212. /**
  38213. * Gets the right camera of a rig setup in case of Rigged Camera
  38214. */
  38215. get isRightCamera(): boolean;
  38216. /**
  38217. * Gets the left camera of a rig setup in case of Rigged Camera
  38218. */
  38219. get leftCamera(): Nullable<FreeCamera>;
  38220. /**
  38221. * Gets the right camera of a rig setup in case of Rigged Camera
  38222. */
  38223. get rightCamera(): Nullable<FreeCamera>;
  38224. /**
  38225. * Gets the left camera target of a rig setup in case of Rigged Camera
  38226. * @returns the target position
  38227. */
  38228. getLeftTarget(): Nullable<Vector3>;
  38229. /**
  38230. * Gets the right camera target of a rig setup in case of Rigged Camera
  38231. * @returns the target position
  38232. */
  38233. getRightTarget(): Nullable<Vector3>;
  38234. /**
  38235. * @hidden
  38236. */
  38237. setCameraRigMode(mode: number, rigParams: any): void;
  38238. /** @hidden */
  38239. static _setStereoscopicRigMode(camera: Camera): void;
  38240. /** @hidden */
  38241. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38242. /** @hidden */
  38243. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38244. /** @hidden */
  38245. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38246. /** @hidden */
  38247. _getVRProjectionMatrix(): Matrix;
  38248. protected _updateCameraRotationMatrix(): void;
  38249. protected _updateWebVRCameraRotationMatrix(): void;
  38250. /**
  38251. * This function MUST be overwritten by the different WebVR cameras available.
  38252. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38253. * @hidden
  38254. */
  38255. _getWebVRProjectionMatrix(): Matrix;
  38256. /**
  38257. * This function MUST be overwritten by the different WebVR cameras available.
  38258. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38259. * @hidden
  38260. */
  38261. _getWebVRViewMatrix(): Matrix;
  38262. /** @hidden */
  38263. setCameraRigParameter(name: string, value: any): void;
  38264. /**
  38265. * needs to be overridden by children so sub has required properties to be copied
  38266. * @hidden
  38267. */
  38268. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38269. /**
  38270. * May need to be overridden by children
  38271. * @hidden
  38272. */
  38273. _updateRigCameras(): void;
  38274. /** @hidden */
  38275. _setupInputs(): void;
  38276. /**
  38277. * Serialiaze the camera setup to a json represention
  38278. * @returns the JSON representation
  38279. */
  38280. serialize(): any;
  38281. /**
  38282. * Clones the current camera.
  38283. * @param name The cloned camera name
  38284. * @returns the cloned camera
  38285. */
  38286. clone(name: string): Camera;
  38287. /**
  38288. * Gets the direction of the camera relative to a given local axis.
  38289. * @param localAxis Defines the reference axis to provide a relative direction.
  38290. * @return the direction
  38291. */
  38292. getDirection(localAxis: Vector3): Vector3;
  38293. /**
  38294. * Returns the current camera absolute rotation
  38295. */
  38296. get absoluteRotation(): Quaternion;
  38297. /**
  38298. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38299. * @param localAxis Defines the reference axis to provide a relative direction.
  38300. * @param result Defines the vector to store the result in
  38301. */
  38302. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38303. /**
  38304. * Gets a camera constructor for a given camera type
  38305. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38306. * @param name The name of the camera the result will be able to instantiate
  38307. * @param scene The scene the result will construct the camera in
  38308. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38309. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38310. * @returns a factory method to construc the camera
  38311. */
  38312. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38313. /**
  38314. * Compute the world matrix of the camera.
  38315. * @returns the camera world matrix
  38316. */
  38317. computeWorldMatrix(): Matrix;
  38318. /**
  38319. * Parse a JSON and creates the camera from the parsed information
  38320. * @param parsedCamera The JSON to parse
  38321. * @param scene The scene to instantiate the camera in
  38322. * @returns the newly constructed camera
  38323. */
  38324. static Parse(parsedCamera: any, scene: Scene): Camera;
  38325. }
  38326. }
  38327. declare module BABYLON {
  38328. /**
  38329. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38330. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38331. */
  38332. export class PostProcessManager {
  38333. private _scene;
  38334. private _indexBuffer;
  38335. private _vertexBuffers;
  38336. /**
  38337. * Creates a new instance PostProcess
  38338. * @param scene The scene that the post process is associated with.
  38339. */
  38340. constructor(scene: Scene);
  38341. private _prepareBuffers;
  38342. private _buildIndexBuffer;
  38343. /**
  38344. * Rebuilds the vertex buffers of the manager.
  38345. * @hidden
  38346. */
  38347. _rebuild(): void;
  38348. /**
  38349. * Prepares a frame to be run through a post process.
  38350. * @param sourceTexture The input texture to the post procesess. (default: null)
  38351. * @param postProcesses An array of post processes to be run. (default: null)
  38352. * @returns True if the post processes were able to be run.
  38353. * @hidden
  38354. */
  38355. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38356. /**
  38357. * Manually render a set of post processes to a texture.
  38358. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38359. * @param postProcesses An array of post processes to be run.
  38360. * @param targetTexture The target texture to render to.
  38361. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38362. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38363. * @param lodLevel defines which lod of the texture to render to
  38364. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38365. */
  38366. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38367. /**
  38368. * Finalize the result of the output of the postprocesses.
  38369. * @param doNotPresent If true the result will not be displayed to the screen.
  38370. * @param targetTexture The target texture to render to.
  38371. * @param faceIndex The index of the face to bind the target texture to.
  38372. * @param postProcesses The array of post processes to render.
  38373. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38374. * @hidden
  38375. */
  38376. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38377. /**
  38378. * Disposes of the post process manager.
  38379. */
  38380. dispose(): void;
  38381. }
  38382. }
  38383. declare module BABYLON {
  38384. /**
  38385. * This Helps creating a texture that will be created from a camera in your scene.
  38386. * It is basically a dynamic texture that could be used to create special effects for instance.
  38387. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38388. */
  38389. export class RenderTargetTexture extends Texture {
  38390. /**
  38391. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38392. */
  38393. static readonly REFRESHRATE_RENDER_ONCE: number;
  38394. /**
  38395. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38396. */
  38397. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38398. /**
  38399. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38400. * the central point of your effect and can save a lot of performances.
  38401. */
  38402. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38403. /**
  38404. * Use this predicate to dynamically define the list of mesh you want to render.
  38405. * If set, the renderList property will be overwritten.
  38406. */
  38407. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38408. private _renderList;
  38409. /**
  38410. * Use this list to define the list of mesh you want to render.
  38411. */
  38412. get renderList(): Nullable<Array<AbstractMesh>>;
  38413. set renderList(value: Nullable<Array<AbstractMesh>>);
  38414. /**
  38415. * Use this function to overload the renderList array at rendering time.
  38416. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38417. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38418. * the cube (if the RTT is a cube, else layerOrFace=0).
  38419. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38420. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38421. * hold dummy elements!
  38422. */
  38423. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38424. private _hookArray;
  38425. /**
  38426. * Define if particles should be rendered in your texture.
  38427. */
  38428. renderParticles: boolean;
  38429. /**
  38430. * Define if sprites should be rendered in your texture.
  38431. */
  38432. renderSprites: boolean;
  38433. /**
  38434. * Define the camera used to render the texture.
  38435. */
  38436. activeCamera: Nullable<Camera>;
  38437. /**
  38438. * Override the mesh isReady function with your own one.
  38439. */
  38440. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38441. /**
  38442. * Override the render function of the texture with your own one.
  38443. */
  38444. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38445. /**
  38446. * Define if camera post processes should be use while rendering the texture.
  38447. */
  38448. useCameraPostProcesses: boolean;
  38449. /**
  38450. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38451. */
  38452. ignoreCameraViewport: boolean;
  38453. private _postProcessManager;
  38454. private _postProcesses;
  38455. private _resizeObserver;
  38456. /**
  38457. * An event triggered when the texture is unbind.
  38458. */
  38459. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38460. /**
  38461. * An event triggered when the texture is unbind.
  38462. */
  38463. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38464. private _onAfterUnbindObserver;
  38465. /**
  38466. * Set a after unbind callback in the texture.
  38467. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38468. */
  38469. set onAfterUnbind(callback: () => void);
  38470. /**
  38471. * An event triggered before rendering the texture
  38472. */
  38473. onBeforeRenderObservable: Observable<number>;
  38474. private _onBeforeRenderObserver;
  38475. /**
  38476. * Set a before render callback in the texture.
  38477. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38478. */
  38479. set onBeforeRender(callback: (faceIndex: number) => void);
  38480. /**
  38481. * An event triggered after rendering the texture
  38482. */
  38483. onAfterRenderObservable: Observable<number>;
  38484. private _onAfterRenderObserver;
  38485. /**
  38486. * Set a after render callback in the texture.
  38487. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38488. */
  38489. set onAfterRender(callback: (faceIndex: number) => void);
  38490. /**
  38491. * An event triggered after the texture clear
  38492. */
  38493. onClearObservable: Observable<Engine>;
  38494. private _onClearObserver;
  38495. /**
  38496. * Set a clear callback in the texture.
  38497. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38498. */
  38499. set onClear(callback: (Engine: Engine) => void);
  38500. /**
  38501. * An event triggered when the texture is resized.
  38502. */
  38503. onResizeObservable: Observable<RenderTargetTexture>;
  38504. /**
  38505. * Define the clear color of the Render Target if it should be different from the scene.
  38506. */
  38507. clearColor: Color4;
  38508. protected _size: number | {
  38509. width: number;
  38510. height: number;
  38511. layers?: number;
  38512. };
  38513. protected _initialSizeParameter: number | {
  38514. width: number;
  38515. height: number;
  38516. } | {
  38517. ratio: number;
  38518. };
  38519. protected _sizeRatio: Nullable<number>;
  38520. /** @hidden */
  38521. _generateMipMaps: boolean;
  38522. protected _renderingManager: RenderingManager;
  38523. /** @hidden */
  38524. _waitingRenderList?: string[];
  38525. protected _doNotChangeAspectRatio: boolean;
  38526. protected _currentRefreshId: number;
  38527. protected _refreshRate: number;
  38528. protected _textureMatrix: Matrix;
  38529. protected _samples: number;
  38530. protected _renderTargetOptions: RenderTargetCreationOptions;
  38531. /**
  38532. * Gets render target creation options that were used.
  38533. */
  38534. get renderTargetOptions(): RenderTargetCreationOptions;
  38535. protected _onRatioRescale(): void;
  38536. /**
  38537. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38538. * It must define where the camera used to render the texture is set
  38539. */
  38540. boundingBoxPosition: Vector3;
  38541. private _boundingBoxSize;
  38542. /**
  38543. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38544. * When defined, the cubemap will switch to local mode
  38545. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38546. * @example https://www.babylonjs-playground.com/#RNASML
  38547. */
  38548. set boundingBoxSize(value: Vector3);
  38549. get boundingBoxSize(): Vector3;
  38550. /**
  38551. * In case the RTT has been created with a depth texture, get the associated
  38552. * depth texture.
  38553. * Otherwise, return null.
  38554. */
  38555. get depthStencilTexture(): Nullable<InternalTexture>;
  38556. /**
  38557. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38558. * or used a shadow, depth texture...
  38559. * @param name The friendly name of the texture
  38560. * @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)
  38561. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38562. * @param generateMipMaps True if mip maps need to be generated after render.
  38563. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38564. * @param type The type of the buffer in the RTT (int, half float, float...)
  38565. * @param isCube True if a cube texture needs to be created
  38566. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38567. * @param generateDepthBuffer True to generate a depth buffer
  38568. * @param generateStencilBuffer True to generate a stencil buffer
  38569. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38570. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38571. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38572. * @param samples sample count to use when creating the RTT
  38573. */
  38574. constructor(name: string, size: number | {
  38575. width: number;
  38576. height: number;
  38577. layers?: number;
  38578. } | {
  38579. ratio: number;
  38580. }, 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);
  38581. /**
  38582. * Creates a depth stencil texture.
  38583. * This is only available in WebGL 2 or with the depth texture extension available.
  38584. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38585. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38586. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38587. * @param samples sample count of the depth/stencil texture
  38588. */
  38589. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38590. private _processSizeParameter;
  38591. /**
  38592. * Define the number of samples to use in case of MSAA.
  38593. * It defaults to one meaning no MSAA has been enabled.
  38594. */
  38595. get samples(): number;
  38596. set samples(value: number);
  38597. /**
  38598. * Resets the refresh counter of the texture and start bak from scratch.
  38599. * Could be useful to regenerate the texture if it is setup to render only once.
  38600. */
  38601. resetRefreshCounter(): void;
  38602. /**
  38603. * Define the refresh rate of the texture or the rendering frequency.
  38604. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38605. */
  38606. get refreshRate(): number;
  38607. set refreshRate(value: number);
  38608. /**
  38609. * Adds a post process to the render target rendering passes.
  38610. * @param postProcess define the post process to add
  38611. */
  38612. addPostProcess(postProcess: PostProcess): void;
  38613. /**
  38614. * Clear all the post processes attached to the render target
  38615. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38616. */
  38617. clearPostProcesses(dispose?: boolean): void;
  38618. /**
  38619. * Remove one of the post process from the list of attached post processes to the texture
  38620. * @param postProcess define the post process to remove from the list
  38621. */
  38622. removePostProcess(postProcess: PostProcess): void;
  38623. /** @hidden */
  38624. _shouldRender(): boolean;
  38625. /**
  38626. * Gets the actual render size of the texture.
  38627. * @returns the width of the render size
  38628. */
  38629. getRenderSize(): number;
  38630. /**
  38631. * Gets the actual render width of the texture.
  38632. * @returns the width of the render size
  38633. */
  38634. getRenderWidth(): number;
  38635. /**
  38636. * Gets the actual render height of the texture.
  38637. * @returns the height of the render size
  38638. */
  38639. getRenderHeight(): number;
  38640. /**
  38641. * Gets the actual number of layers of the texture.
  38642. * @returns the number of layers
  38643. */
  38644. getRenderLayers(): number;
  38645. /**
  38646. * Get if the texture can be rescaled or not.
  38647. */
  38648. get canRescale(): boolean;
  38649. /**
  38650. * Resize the texture using a ratio.
  38651. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38652. */
  38653. scale(ratio: number): void;
  38654. /**
  38655. * Get the texture reflection matrix used to rotate/transform the reflection.
  38656. * @returns the reflection matrix
  38657. */
  38658. getReflectionTextureMatrix(): Matrix;
  38659. /**
  38660. * Resize the texture to a new desired size.
  38661. * Be carrefull as it will recreate all the data in the new texture.
  38662. * @param size Define the new size. It can be:
  38663. * - a number for squared texture,
  38664. * - an object containing { width: number, height: number }
  38665. * - or an object containing a ratio { ratio: number }
  38666. */
  38667. resize(size: number | {
  38668. width: number;
  38669. height: number;
  38670. } | {
  38671. ratio: number;
  38672. }): void;
  38673. private _defaultRenderListPrepared;
  38674. /**
  38675. * Renders all the objects from the render list into the texture.
  38676. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38677. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38678. */
  38679. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38680. private _bestReflectionRenderTargetDimension;
  38681. private _prepareRenderingManager;
  38682. /**
  38683. * @hidden
  38684. * @param faceIndex face index to bind to if this is a cubetexture
  38685. * @param layer defines the index of the texture to bind in the array
  38686. */
  38687. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38688. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38689. private renderToTarget;
  38690. /**
  38691. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38692. * This allowed control for front to back rendering or reversly depending of the special needs.
  38693. *
  38694. * @param renderingGroupId The rendering group id corresponding to its index
  38695. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38696. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38697. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38698. */
  38699. 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;
  38700. /**
  38701. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38702. *
  38703. * @param renderingGroupId The rendering group id corresponding to its index
  38704. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38705. */
  38706. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38707. /**
  38708. * Clones the texture.
  38709. * @returns the cloned texture
  38710. */
  38711. clone(): RenderTargetTexture;
  38712. /**
  38713. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38714. * @returns The JSON representation of the texture
  38715. */
  38716. serialize(): any;
  38717. /**
  38718. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38719. */
  38720. disposeFramebufferObjects(): void;
  38721. /**
  38722. * Dispose the texture and release its associated resources.
  38723. */
  38724. dispose(): void;
  38725. /** @hidden */
  38726. _rebuild(): void;
  38727. /**
  38728. * Clear the info related to rendering groups preventing retention point in material dispose.
  38729. */
  38730. freeRenderingGroups(): void;
  38731. /**
  38732. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38733. * @returns the view count
  38734. */
  38735. getViewCount(): number;
  38736. }
  38737. }
  38738. declare module BABYLON {
  38739. /**
  38740. * Options to be used when creating an effect.
  38741. */
  38742. export interface IEffectCreationOptions {
  38743. /**
  38744. * Atrributes that will be used in the shader.
  38745. */
  38746. attributes: string[];
  38747. /**
  38748. * Uniform varible names that will be set in the shader.
  38749. */
  38750. uniformsNames: string[];
  38751. /**
  38752. * Uniform buffer variable names that will be set in the shader.
  38753. */
  38754. uniformBuffersNames: string[];
  38755. /**
  38756. * Sampler texture variable names that will be set in the shader.
  38757. */
  38758. samplers: string[];
  38759. /**
  38760. * Define statements that will be set in the shader.
  38761. */
  38762. defines: any;
  38763. /**
  38764. * Possible fallbacks for this effect to improve performance when needed.
  38765. */
  38766. fallbacks: Nullable<IEffectFallbacks>;
  38767. /**
  38768. * Callback that will be called when the shader is compiled.
  38769. */
  38770. onCompiled: Nullable<(effect: Effect) => void>;
  38771. /**
  38772. * Callback that will be called if an error occurs during shader compilation.
  38773. */
  38774. onError: Nullable<(effect: Effect, errors: string) => void>;
  38775. /**
  38776. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38777. */
  38778. indexParameters?: any;
  38779. /**
  38780. * Max number of lights that can be used in the shader.
  38781. */
  38782. maxSimultaneousLights?: number;
  38783. /**
  38784. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38785. */
  38786. transformFeedbackVaryings?: Nullable<string[]>;
  38787. /**
  38788. * 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
  38789. */
  38790. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38791. /**
  38792. * Is this effect rendering to several color attachments ?
  38793. */
  38794. multiTarget?: boolean;
  38795. }
  38796. /**
  38797. * Effect containing vertex and fragment shader that can be executed on an object.
  38798. */
  38799. export class Effect implements IDisposable {
  38800. /**
  38801. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38802. */
  38803. static ShadersRepository: string;
  38804. /**
  38805. * Enable logging of the shader code when a compilation error occurs
  38806. */
  38807. static LogShaderCodeOnCompilationError: boolean;
  38808. /**
  38809. * Name of the effect.
  38810. */
  38811. name: any;
  38812. /**
  38813. * String container all the define statements that should be set on the shader.
  38814. */
  38815. defines: string;
  38816. /**
  38817. * Callback that will be called when the shader is compiled.
  38818. */
  38819. onCompiled: Nullable<(effect: Effect) => void>;
  38820. /**
  38821. * Callback that will be called if an error occurs during shader compilation.
  38822. */
  38823. onError: Nullable<(effect: Effect, errors: string) => void>;
  38824. /**
  38825. * Callback that will be called when effect is bound.
  38826. */
  38827. onBind: Nullable<(effect: Effect) => void>;
  38828. /**
  38829. * Unique ID of the effect.
  38830. */
  38831. uniqueId: number;
  38832. /**
  38833. * Observable that will be called when the shader is compiled.
  38834. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38835. */
  38836. onCompileObservable: Observable<Effect>;
  38837. /**
  38838. * Observable that will be called if an error occurs during shader compilation.
  38839. */
  38840. onErrorObservable: Observable<Effect>;
  38841. /** @hidden */
  38842. _onBindObservable: Nullable<Observable<Effect>>;
  38843. /**
  38844. * @hidden
  38845. * Specifies if the effect was previously ready
  38846. */
  38847. _wasPreviouslyReady: boolean;
  38848. /**
  38849. * Observable that will be called when effect is bound.
  38850. */
  38851. get onBindObservable(): Observable<Effect>;
  38852. /** @hidden */
  38853. _bonesComputationForcedToCPU: boolean;
  38854. /** @hidden */
  38855. _uniformBuffersNames: {
  38856. [key: string]: number;
  38857. };
  38858. /** @hidden */
  38859. _samplerList: string[];
  38860. /** @hidden */
  38861. _multiTarget: boolean;
  38862. private static _uniqueIdSeed;
  38863. private _engine;
  38864. private _uniformBuffersNamesList;
  38865. private _uniformsNames;
  38866. private _samplers;
  38867. private _isReady;
  38868. private _compilationError;
  38869. private _allFallbacksProcessed;
  38870. private _attributesNames;
  38871. private _attributes;
  38872. private _attributeLocationByName;
  38873. private _uniforms;
  38874. /**
  38875. * Key for the effect.
  38876. * @hidden
  38877. */
  38878. _key: string;
  38879. private _indexParameters;
  38880. private _fallbacks;
  38881. private _vertexSourceCodeOverride;
  38882. private _fragmentSourceCodeOverride;
  38883. private _transformFeedbackVaryings;
  38884. /**
  38885. * Compiled shader to webGL program.
  38886. * @hidden
  38887. */
  38888. _pipelineContext: Nullable<IPipelineContext>;
  38889. /** @hidden */
  38890. _vertexSourceCode: string;
  38891. /** @hidden */
  38892. _fragmentSourceCode: string;
  38893. /** @hidden */
  38894. private _rawVertexSourceCode;
  38895. /** @hidden */
  38896. private _rawFragmentSourceCode;
  38897. private static _baseCache;
  38898. private _processingContext;
  38899. /**
  38900. * Instantiates an effect.
  38901. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38902. * @param baseName Name of the effect.
  38903. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38904. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38905. * @param samplers List of sampler variables that will be passed to the shader.
  38906. * @param engine Engine to be used to render the effect
  38907. * @param defines Define statements to be added to the shader.
  38908. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38909. * @param onCompiled Callback that will be called when the shader is compiled.
  38910. * @param onError Callback that will be called if an error occurs during shader compilation.
  38911. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38912. * @param key Effect Key identifying uniquely compiled shader variants
  38913. */
  38914. 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);
  38915. private _useFinalCode;
  38916. /**
  38917. * Unique key for this effect
  38918. */
  38919. get key(): string;
  38920. /**
  38921. * If the effect has been compiled and prepared.
  38922. * @returns if the effect is compiled and prepared.
  38923. */
  38924. isReady(): boolean;
  38925. private _isReadyInternal;
  38926. /**
  38927. * The engine the effect was initialized with.
  38928. * @returns the engine.
  38929. */
  38930. getEngine(): Engine;
  38931. /**
  38932. * The pipeline context for this effect
  38933. * @returns the associated pipeline context
  38934. */
  38935. getPipelineContext(): Nullable<IPipelineContext>;
  38936. /**
  38937. * The set of names of attribute variables for the shader.
  38938. * @returns An array of attribute names.
  38939. */
  38940. getAttributesNames(): string[];
  38941. /**
  38942. * Returns the attribute at the given index.
  38943. * @param index The index of the attribute.
  38944. * @returns The location of the attribute.
  38945. */
  38946. getAttributeLocation(index: number): number;
  38947. /**
  38948. * Returns the attribute based on the name of the variable.
  38949. * @param name of the attribute to look up.
  38950. * @returns the attribute location.
  38951. */
  38952. getAttributeLocationByName(name: string): number;
  38953. /**
  38954. * The number of attributes.
  38955. * @returns the numnber of attributes.
  38956. */
  38957. getAttributesCount(): number;
  38958. /**
  38959. * Gets the index of a uniform variable.
  38960. * @param uniformName of the uniform to look up.
  38961. * @returns the index.
  38962. */
  38963. getUniformIndex(uniformName: string): number;
  38964. /**
  38965. * Returns the attribute based on the name of the variable.
  38966. * @param uniformName of the uniform to look up.
  38967. * @returns the location of the uniform.
  38968. */
  38969. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38970. /**
  38971. * Returns an array of sampler variable names
  38972. * @returns The array of sampler variable names.
  38973. */
  38974. getSamplers(): string[];
  38975. /**
  38976. * Returns an array of uniform variable names
  38977. * @returns The array of uniform variable names.
  38978. */
  38979. getUniformNames(): string[];
  38980. /**
  38981. * Returns an array of uniform buffer variable names
  38982. * @returns The array of uniform buffer variable names.
  38983. */
  38984. getUniformBuffersNames(): string[];
  38985. /**
  38986. * Returns the index parameters used to create the effect
  38987. * @returns The index parameters object
  38988. */
  38989. getIndexParameters(): any;
  38990. /**
  38991. * The error from the last compilation.
  38992. * @returns the error string.
  38993. */
  38994. getCompilationError(): string;
  38995. /**
  38996. * Gets a boolean indicating that all fallbacks were used during compilation
  38997. * @returns true if all fallbacks were used
  38998. */
  38999. allFallbacksProcessed(): boolean;
  39000. /**
  39001. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39002. * @param func The callback to be used.
  39003. */
  39004. executeWhenCompiled(func: (effect: Effect) => void): void;
  39005. private _checkIsReady;
  39006. private _loadShader;
  39007. /**
  39008. * Gets the vertex shader source code of this effect
  39009. */
  39010. get vertexSourceCode(): string;
  39011. /**
  39012. * Gets the fragment shader source code of this effect
  39013. */
  39014. get fragmentSourceCode(): string;
  39015. /**
  39016. * Gets the vertex shader source code before it has been processed by the preprocessor
  39017. */
  39018. get rawVertexSourceCode(): string;
  39019. /**
  39020. * Gets the fragment shader source code before it has been processed by the preprocessor
  39021. */
  39022. get rawFragmentSourceCode(): string;
  39023. /**
  39024. * Recompiles the webGL program
  39025. * @param vertexSourceCode The source code for the vertex shader.
  39026. * @param fragmentSourceCode The source code for the fragment shader.
  39027. * @param onCompiled Callback called when completed.
  39028. * @param onError Callback called on error.
  39029. * @hidden
  39030. */
  39031. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39032. /**
  39033. * Prepares the effect
  39034. * @hidden
  39035. */
  39036. _prepareEffect(): void;
  39037. private _getShaderCodeAndErrorLine;
  39038. private _processCompilationErrors;
  39039. /**
  39040. * Checks if the effect is supported. (Must be called after compilation)
  39041. */
  39042. get isSupported(): boolean;
  39043. /**
  39044. * Binds a texture to the engine to be used as output of the shader.
  39045. * @param channel Name of the output variable.
  39046. * @param texture Texture to bind.
  39047. * @hidden
  39048. */
  39049. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39050. /**
  39051. * Sets a texture on the engine to be used in the shader.
  39052. * @param channel Name of the sampler variable.
  39053. * @param texture Texture to set.
  39054. */
  39055. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39056. /**
  39057. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39058. * @param channel Name of the sampler variable.
  39059. * @param texture Texture to set.
  39060. */
  39061. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39062. /**
  39063. * Sets an array of textures on the engine to be used in the shader.
  39064. * @param channel Name of the variable.
  39065. * @param textures Textures to set.
  39066. */
  39067. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39068. /**
  39069. * 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)
  39070. * @param channel Name of the sampler variable.
  39071. * @param postProcess Post process to get the input texture from.
  39072. */
  39073. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39074. /**
  39075. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39076. * 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)
  39077. * @param channel Name of the sampler variable.
  39078. * @param postProcess Post process to get the output texture from.
  39079. */
  39080. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39081. /**
  39082. * Binds a buffer to a uniform.
  39083. * @param buffer Buffer to bind.
  39084. * @param name Name of the uniform variable to bind to.
  39085. */
  39086. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39087. /**
  39088. * Binds block to a uniform.
  39089. * @param blockName Name of the block to bind.
  39090. * @param index Index to bind.
  39091. */
  39092. bindUniformBlock(blockName: string, index: number): void;
  39093. /**
  39094. * Sets an interger value on a uniform variable.
  39095. * @param uniformName Name of the variable.
  39096. * @param value Value to be set.
  39097. * @returns this effect.
  39098. */
  39099. setInt(uniformName: string, value: number): Effect;
  39100. /**
  39101. * Sets an int2 value on a uniform variable.
  39102. * @param uniformName Name of the variable.
  39103. * @param x First int in int2.
  39104. * @param y Second int in int2.
  39105. * @returns this effect.
  39106. */
  39107. setInt2(uniformName: string, x: number, y: number): Effect;
  39108. /**
  39109. * Sets an int3 value on a uniform variable.
  39110. * @param uniformName Name of the variable.
  39111. * @param x First int in int3.
  39112. * @param y Second int in int3.
  39113. * @param z Third int in int3.
  39114. * @returns this effect.
  39115. */
  39116. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39117. /**
  39118. * Sets an int4 value on a uniform variable.
  39119. * @param uniformName Name of the variable.
  39120. * @param x First int in int4.
  39121. * @param y Second int in int4.
  39122. * @param z Third int in int4.
  39123. * @param w Fourth int in int4.
  39124. * @returns this effect.
  39125. */
  39126. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39127. /**
  39128. * Sets an int array on a uniform variable.
  39129. * @param uniformName Name of the variable.
  39130. * @param array array to be set.
  39131. * @returns this effect.
  39132. */
  39133. setIntArray(uniformName: string, array: Int32Array): Effect;
  39134. /**
  39135. * 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)
  39136. * @param uniformName Name of the variable.
  39137. * @param array array to be set.
  39138. * @returns this effect.
  39139. */
  39140. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39141. /**
  39142. * 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)
  39143. * @param uniformName Name of the variable.
  39144. * @param array array to be set.
  39145. * @returns this effect.
  39146. */
  39147. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39148. /**
  39149. * 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)
  39150. * @param uniformName Name of the variable.
  39151. * @param array array to be set.
  39152. * @returns this effect.
  39153. */
  39154. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39155. /**
  39156. * Sets an float array on a uniform variable.
  39157. * @param uniformName Name of the variable.
  39158. * @param array array to be set.
  39159. * @returns this effect.
  39160. */
  39161. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39162. /**
  39163. * 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)
  39164. * @param uniformName Name of the variable.
  39165. * @param array array to be set.
  39166. * @returns this effect.
  39167. */
  39168. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39169. /**
  39170. * 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)
  39171. * @param uniformName Name of the variable.
  39172. * @param array array to be set.
  39173. * @returns this effect.
  39174. */
  39175. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39176. /**
  39177. * 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)
  39178. * @param uniformName Name of the variable.
  39179. * @param array array to be set.
  39180. * @returns this effect.
  39181. */
  39182. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39183. /**
  39184. * Sets an array on a uniform variable.
  39185. * @param uniformName Name of the variable.
  39186. * @param array array to be set.
  39187. * @returns this effect.
  39188. */
  39189. setArray(uniformName: string, array: number[]): Effect;
  39190. /**
  39191. * 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)
  39192. * @param uniformName Name of the variable.
  39193. * @param array array to be set.
  39194. * @returns this effect.
  39195. */
  39196. setArray2(uniformName: string, array: number[]): Effect;
  39197. /**
  39198. * 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)
  39199. * @param uniformName Name of the variable.
  39200. * @param array array to be set.
  39201. * @returns this effect.
  39202. */
  39203. setArray3(uniformName: string, array: number[]): Effect;
  39204. /**
  39205. * 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)
  39206. * @param uniformName Name of the variable.
  39207. * @param array array to be set.
  39208. * @returns this effect.
  39209. */
  39210. setArray4(uniformName: string, array: number[]): Effect;
  39211. /**
  39212. * Sets matrices on a uniform variable.
  39213. * @param uniformName Name of the variable.
  39214. * @param matrices matrices to be set.
  39215. * @returns this effect.
  39216. */
  39217. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39218. /**
  39219. * Sets matrix on a uniform variable.
  39220. * @param uniformName Name of the variable.
  39221. * @param matrix matrix to be set.
  39222. * @returns this effect.
  39223. */
  39224. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39225. /**
  39226. * 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)
  39227. * @param uniformName Name of the variable.
  39228. * @param matrix matrix to be set.
  39229. * @returns this effect.
  39230. */
  39231. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39232. /**
  39233. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39234. * @param uniformName Name of the variable.
  39235. * @param matrix matrix to be set.
  39236. * @returns this effect.
  39237. */
  39238. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39239. /**
  39240. * Sets a float on a uniform variable.
  39241. * @param uniformName Name of the variable.
  39242. * @param value value to be set.
  39243. * @returns this effect.
  39244. */
  39245. setFloat(uniformName: string, value: number): Effect;
  39246. /**
  39247. * Sets a boolean on a uniform variable.
  39248. * @param uniformName Name of the variable.
  39249. * @param bool value to be set.
  39250. * @returns this effect.
  39251. */
  39252. setBool(uniformName: string, bool: boolean): Effect;
  39253. /**
  39254. * Sets a Vector2 on a uniform variable.
  39255. * @param uniformName Name of the variable.
  39256. * @param vector2 vector2 to be set.
  39257. * @returns this effect.
  39258. */
  39259. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39260. /**
  39261. * Sets a float2 on a uniform variable.
  39262. * @param uniformName Name of the variable.
  39263. * @param x First float in float2.
  39264. * @param y Second float in float2.
  39265. * @returns this effect.
  39266. */
  39267. setFloat2(uniformName: string, x: number, y: number): Effect;
  39268. /**
  39269. * Sets a Vector3 on a uniform variable.
  39270. * @param uniformName Name of the variable.
  39271. * @param vector3 Value to be set.
  39272. * @returns this effect.
  39273. */
  39274. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39275. /**
  39276. * Sets a float3 on a uniform variable.
  39277. * @param uniformName Name of the variable.
  39278. * @param x First float in float3.
  39279. * @param y Second float in float3.
  39280. * @param z Third float in float3.
  39281. * @returns this effect.
  39282. */
  39283. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39284. /**
  39285. * Sets a Vector4 on a uniform variable.
  39286. * @param uniformName Name of the variable.
  39287. * @param vector4 Value to be set.
  39288. * @returns this effect.
  39289. */
  39290. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39291. /**
  39292. * Sets a float4 on a uniform variable.
  39293. * @param uniformName Name of the variable.
  39294. * @param x First float in float4.
  39295. * @param y Second float in float4.
  39296. * @param z Third float in float4.
  39297. * @param w Fourth float in float4.
  39298. * @returns this effect.
  39299. */
  39300. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39301. /**
  39302. * Sets a Color3 on a uniform variable.
  39303. * @param uniformName Name of the variable.
  39304. * @param color3 Value to be set.
  39305. * @returns this effect.
  39306. */
  39307. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39308. /**
  39309. * Sets a Color4 on a uniform variable.
  39310. * @param uniformName Name of the variable.
  39311. * @param color3 Value to be set.
  39312. * @param alpha Alpha value to be set.
  39313. * @returns this effect.
  39314. */
  39315. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39316. /**
  39317. * Sets a Color4 on a uniform variable
  39318. * @param uniformName defines the name of the variable
  39319. * @param color4 defines the value to be set
  39320. * @returns this effect.
  39321. */
  39322. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39323. /**
  39324. * Release all associated resources.
  39325. **/
  39326. dispose(): void;
  39327. /**
  39328. * This function will add a new shader to the shader store
  39329. * @param name the name of the shader
  39330. * @param pixelShader optional pixel shader content
  39331. * @param vertexShader optional vertex shader content
  39332. */
  39333. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39334. /**
  39335. * Store of each shader (The can be looked up using effect.key)
  39336. */
  39337. static ShadersStore: {
  39338. [key: string]: string;
  39339. };
  39340. /**
  39341. * Store of each included file for a shader (The can be looked up using effect.key)
  39342. */
  39343. static IncludesShadersStore: {
  39344. [key: string]: string;
  39345. };
  39346. /**
  39347. * Resets the cache of effects.
  39348. */
  39349. static ResetCache(): void;
  39350. }
  39351. }
  39352. declare module BABYLON {
  39353. /**
  39354. * Interface used to describe the capabilities of the engine relatively to the current browser
  39355. */
  39356. export interface EngineCapabilities {
  39357. /** Maximum textures units per fragment shader */
  39358. maxTexturesImageUnits: number;
  39359. /** Maximum texture units per vertex shader */
  39360. maxVertexTextureImageUnits: number;
  39361. /** Maximum textures units in the entire pipeline */
  39362. maxCombinedTexturesImageUnits: number;
  39363. /** Maximum texture size */
  39364. maxTextureSize: number;
  39365. /** Maximum texture samples */
  39366. maxSamples?: number;
  39367. /** Maximum cube texture size */
  39368. maxCubemapTextureSize: number;
  39369. /** Maximum render texture size */
  39370. maxRenderTextureSize: number;
  39371. /** Maximum number of vertex attributes */
  39372. maxVertexAttribs: number;
  39373. /** Maximum number of varyings */
  39374. maxVaryingVectors: number;
  39375. /** Maximum number of uniforms per vertex shader */
  39376. maxVertexUniformVectors: number;
  39377. /** Maximum number of uniforms per fragment shader */
  39378. maxFragmentUniformVectors: number;
  39379. /** Defines if standard derivates (dx/dy) are supported */
  39380. standardDerivatives: boolean;
  39381. /** Defines if s3tc texture compression is supported */
  39382. s3tc?: WEBGL_compressed_texture_s3tc;
  39383. /** Defines if pvrtc texture compression is supported */
  39384. pvrtc: any;
  39385. /** Defines if etc1 texture compression is supported */
  39386. etc1: any;
  39387. /** Defines if etc2 texture compression is supported */
  39388. etc2: any;
  39389. /** Defines if astc texture compression is supported */
  39390. astc: any;
  39391. /** Defines if bptc texture compression is supported */
  39392. bptc: any;
  39393. /** Defines if float textures are supported */
  39394. textureFloat: boolean;
  39395. /** Defines if vertex array objects are supported */
  39396. vertexArrayObject: boolean;
  39397. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39398. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39399. /** Gets the maximum level of anisotropy supported */
  39400. maxAnisotropy: number;
  39401. /** Defines if instancing is supported */
  39402. instancedArrays: boolean;
  39403. /** Defines if 32 bits indices are supported */
  39404. uintIndices: boolean;
  39405. /** Defines if high precision shaders are supported */
  39406. highPrecisionShaderSupported: boolean;
  39407. /** Defines if depth reading in the fragment shader is supported */
  39408. fragmentDepthSupported: boolean;
  39409. /** Defines if float texture linear filtering is supported*/
  39410. textureFloatLinearFiltering: boolean;
  39411. /** Defines if rendering to float textures is supported */
  39412. textureFloatRender: boolean;
  39413. /** Defines if half float textures are supported*/
  39414. textureHalfFloat: boolean;
  39415. /** Defines if half float texture linear filtering is supported*/
  39416. textureHalfFloatLinearFiltering: boolean;
  39417. /** Defines if rendering to half float textures is supported */
  39418. textureHalfFloatRender: boolean;
  39419. /** Defines if textureLOD shader command is supported */
  39420. textureLOD: boolean;
  39421. /** Defines if draw buffers extension is supported */
  39422. drawBuffersExtension: boolean;
  39423. /** Defines if depth textures are supported */
  39424. depthTextureExtension: boolean;
  39425. /** Defines if float color buffer are supported */
  39426. colorBufferFloat: boolean;
  39427. /** Gets disjoint timer query extension (null if not supported) */
  39428. timerQuery?: EXT_disjoint_timer_query;
  39429. /** Defines if timestamp can be used with timer query */
  39430. canUseTimestampForTimerQuery: boolean;
  39431. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39432. multiview?: any;
  39433. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39434. oculusMultiview?: any;
  39435. /** Function used to let the system compiles shaders in background */
  39436. parallelShaderCompile?: {
  39437. COMPLETION_STATUS_KHR: number;
  39438. };
  39439. /** Max number of texture samples for MSAA */
  39440. maxMSAASamples: number;
  39441. /** Defines if the blend min max extension is supported */
  39442. blendMinMax: boolean;
  39443. /** 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 */
  39444. canUseGLInstanceID: boolean;
  39445. }
  39446. }
  39447. declare module BABYLON {
  39448. /**
  39449. * @hidden
  39450. **/
  39451. export class DepthCullingState {
  39452. private _isDepthTestDirty;
  39453. private _isDepthMaskDirty;
  39454. private _isDepthFuncDirty;
  39455. private _isCullFaceDirty;
  39456. private _isCullDirty;
  39457. private _isZOffsetDirty;
  39458. private _isFrontFaceDirty;
  39459. private _depthTest;
  39460. private _depthMask;
  39461. private _depthFunc;
  39462. private _cull;
  39463. private _cullFace;
  39464. private _zOffset;
  39465. private _frontFace;
  39466. /**
  39467. * Initializes the state.
  39468. */
  39469. constructor();
  39470. get isDirty(): boolean;
  39471. get zOffset(): number;
  39472. set zOffset(value: number);
  39473. get cullFace(): Nullable<number>;
  39474. set cullFace(value: Nullable<number>);
  39475. get cull(): Nullable<boolean>;
  39476. set cull(value: Nullable<boolean>);
  39477. get depthFunc(): Nullable<number>;
  39478. set depthFunc(value: Nullable<number>);
  39479. get depthMask(): boolean;
  39480. set depthMask(value: boolean);
  39481. get depthTest(): boolean;
  39482. set depthTest(value: boolean);
  39483. get frontFace(): Nullable<number>;
  39484. set frontFace(value: Nullable<number>);
  39485. reset(): void;
  39486. apply(gl: WebGLRenderingContext): void;
  39487. }
  39488. }
  39489. declare module BABYLON {
  39490. /**
  39491. * @hidden
  39492. **/
  39493. export class StencilState {
  39494. /** 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 */
  39495. static readonly ALWAYS: number;
  39496. /** Passed to stencilOperation to specify that stencil value must be kept */
  39497. static readonly KEEP: number;
  39498. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39499. static readonly REPLACE: number;
  39500. private _isStencilTestDirty;
  39501. private _isStencilMaskDirty;
  39502. private _isStencilFuncDirty;
  39503. private _isStencilOpDirty;
  39504. private _stencilTest;
  39505. private _stencilMask;
  39506. private _stencilFunc;
  39507. private _stencilFuncRef;
  39508. private _stencilFuncMask;
  39509. private _stencilOpStencilFail;
  39510. private _stencilOpDepthFail;
  39511. private _stencilOpStencilDepthPass;
  39512. get isDirty(): boolean;
  39513. get stencilFunc(): number;
  39514. set stencilFunc(value: number);
  39515. get stencilFuncRef(): number;
  39516. set stencilFuncRef(value: number);
  39517. get stencilFuncMask(): number;
  39518. set stencilFuncMask(value: number);
  39519. get stencilOpStencilFail(): number;
  39520. set stencilOpStencilFail(value: number);
  39521. get stencilOpDepthFail(): number;
  39522. set stencilOpDepthFail(value: number);
  39523. get stencilOpStencilDepthPass(): number;
  39524. set stencilOpStencilDepthPass(value: number);
  39525. get stencilMask(): number;
  39526. set stencilMask(value: number);
  39527. get stencilTest(): boolean;
  39528. set stencilTest(value: boolean);
  39529. constructor();
  39530. reset(): void;
  39531. apply(gl: WebGLRenderingContext): void;
  39532. }
  39533. }
  39534. declare module BABYLON {
  39535. /**
  39536. * @hidden
  39537. **/
  39538. export class AlphaState {
  39539. _blendFunctionParameters: Nullable<number>[];
  39540. _blendEquationParameters: Nullable<number>[];
  39541. _blendConstants: Nullable<number>[];
  39542. _isBlendConstantsDirty: boolean;
  39543. private _alphaBlend;
  39544. private _isAlphaBlendDirty;
  39545. private _isBlendFunctionParametersDirty;
  39546. private _isBlendEquationParametersDirty;
  39547. /**
  39548. * Initializes the state.
  39549. */
  39550. constructor();
  39551. get isDirty(): boolean;
  39552. get alphaBlend(): boolean;
  39553. set alphaBlend(value: boolean);
  39554. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39555. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39556. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39557. reset(): void;
  39558. apply(gl: WebGLRenderingContext): void;
  39559. }
  39560. }
  39561. declare module BABYLON {
  39562. /** @hidden */
  39563. export class WebGLShaderProcessor implements IShaderProcessor {
  39564. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39565. }
  39566. }
  39567. declare module BABYLON {
  39568. /** @hidden */
  39569. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39570. attributeProcessor(attribute: string): string;
  39571. varyingProcessor(varying: string, isFragment: boolean): string;
  39572. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39573. }
  39574. }
  39575. declare module BABYLON {
  39576. /**
  39577. * Interface for attribute information associated with buffer instanciation
  39578. */
  39579. export interface InstancingAttributeInfo {
  39580. /**
  39581. * Name of the GLSL attribute
  39582. * if attribute index is not specified, this is used to retrieve the index from the effect
  39583. */
  39584. attributeName: string;
  39585. /**
  39586. * Index/offset of the attribute in the vertex shader
  39587. * if not specified, this will be computes from the name.
  39588. */
  39589. index?: number;
  39590. /**
  39591. * size of the attribute, 1, 2, 3 or 4
  39592. */
  39593. attributeSize: number;
  39594. /**
  39595. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39596. */
  39597. offset: number;
  39598. /**
  39599. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39600. * default to 1
  39601. */
  39602. divisor?: number;
  39603. /**
  39604. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39605. * default is FLOAT
  39606. */
  39607. attributeType?: number;
  39608. /**
  39609. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39610. */
  39611. normalized?: boolean;
  39612. }
  39613. }
  39614. declare module BABYLON {
  39615. /** @hidden */
  39616. export interface EngineFeatures {
  39617. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39618. forceBitmapOverHTMLImageElement: boolean;
  39619. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39620. supportRenderAndCopyToLodForFloatTextures: boolean;
  39621. /** Indicates that the engine support handling depth/stencil textures */
  39622. supportDepthStencilTexture: boolean;
  39623. /** Indicates that the engine support shadow samplers */
  39624. supportShadowSamplers: boolean;
  39625. /** 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 */
  39626. uniformBufferHardCheckMatrix: boolean;
  39627. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39628. allowTexturePrefiltering: boolean;
  39629. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39630. trackUbosInFrame: boolean;
  39631. /** Indicates that the Cascaded Shadow Map technic is supported */
  39632. supportCSM: boolean;
  39633. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39634. basisNeedsPOT: boolean;
  39635. /** Indicates that the engine supports 3D textures */
  39636. support3DTextures: boolean;
  39637. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39638. needTypeSuffixInShaderConstants: boolean;
  39639. /** Indicates that MSAA is supported */
  39640. supportMSAA: boolean;
  39641. /** Indicates that SSAO2 is supported */
  39642. supportSSAO2: boolean;
  39643. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39644. supportExtendedTextureFormats: boolean;
  39645. /** Indicates that the switch/case construct is supported in shaders */
  39646. supportSwitchCaseInShader: boolean;
  39647. /** @hidden */
  39648. _collectUbosUpdatedInFrame: boolean;
  39649. }
  39650. }
  39651. declare module BABYLON {
  39652. /** @hidden */
  39653. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39654. private _webGLTexture;
  39655. private _context;
  39656. get underlyingResource(): Nullable<WebGLTexture>;
  39657. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39658. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39659. set(hardwareTexture: WebGLTexture): void;
  39660. reset(): void;
  39661. release(): void;
  39662. }
  39663. }
  39664. declare module BABYLON {
  39665. interface ThinEngine {
  39666. /**
  39667. * Update a video texture
  39668. * @param texture defines the texture to update
  39669. * @param video defines the video element to use
  39670. * @param invertY defines if data must be stored with Y axis inverted
  39671. */
  39672. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39673. }
  39674. }
  39675. declare module BABYLON {
  39676. interface ThinEngine {
  39677. /**
  39678. * Creates a dynamic texture
  39679. * @param width defines the width of the texture
  39680. * @param height defines the height of the texture
  39681. * @param generateMipMaps defines if the engine should generate the mip levels
  39682. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39683. * @returns the dynamic texture inside an InternalTexture
  39684. */
  39685. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39686. /**
  39687. * Update the content of a dynamic texture
  39688. * @param texture defines the texture to update
  39689. * @param source defines the source containing the data
  39690. * @param invertY defines if data must be stored with Y axis inverted
  39691. * @param premulAlpha defines if alpha is stored as premultiplied
  39692. * @param format defines the format of the data
  39693. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39694. */
  39695. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39696. }
  39697. }
  39698. declare module BABYLON {
  39699. /**
  39700. * Settings for finer control over video usage
  39701. */
  39702. export interface VideoTextureSettings {
  39703. /**
  39704. * Applies `autoplay` to video, if specified
  39705. */
  39706. autoPlay?: boolean;
  39707. /**
  39708. * Applies `muted` to video, if specified
  39709. */
  39710. muted?: boolean;
  39711. /**
  39712. * Applies `loop` to video, if specified
  39713. */
  39714. loop?: boolean;
  39715. /**
  39716. * Automatically updates internal texture from video at every frame in the render loop
  39717. */
  39718. autoUpdateTexture: boolean;
  39719. /**
  39720. * Image src displayed during the video loading or until the user interacts with the video.
  39721. */
  39722. poster?: string;
  39723. }
  39724. /**
  39725. * If you want to display a video in your scene, this is the special texture for that.
  39726. * This special texture works similar to other textures, with the exception of a few parameters.
  39727. * @see https://doc.babylonjs.com/how_to/video_texture
  39728. */
  39729. export class VideoTexture extends Texture {
  39730. /**
  39731. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39732. */
  39733. readonly autoUpdateTexture: boolean;
  39734. /**
  39735. * The video instance used by the texture internally
  39736. */
  39737. readonly video: HTMLVideoElement;
  39738. private _onUserActionRequestedObservable;
  39739. /**
  39740. * Event triggerd when a dom action is required by the user to play the video.
  39741. * This happens due to recent changes in browser policies preventing video to auto start.
  39742. */
  39743. get onUserActionRequestedObservable(): Observable<Texture>;
  39744. private _generateMipMaps;
  39745. private _stillImageCaptured;
  39746. private _displayingPosterTexture;
  39747. private _settings;
  39748. private _createInternalTextureOnEvent;
  39749. private _frameId;
  39750. private _currentSrc;
  39751. /**
  39752. * Creates a video texture.
  39753. * If you want to display a video in your scene, this is the special texture for that.
  39754. * This special texture works similar to other textures, with the exception of a few parameters.
  39755. * @see https://doc.babylonjs.com/how_to/video_texture
  39756. * @param name optional name, will detect from video source, if not defined
  39757. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39758. * @param scene is obviously the current scene.
  39759. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39760. * @param invertY is false by default but can be used to invert video on Y axis
  39761. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39762. * @param settings allows finer control over video usage
  39763. */
  39764. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39765. private _getName;
  39766. private _getVideo;
  39767. private _createInternalTexture;
  39768. private reset;
  39769. /**
  39770. * @hidden Internal method to initiate `update`.
  39771. */
  39772. _rebuild(): void;
  39773. /**
  39774. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39775. */
  39776. update(): void;
  39777. /**
  39778. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39779. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39780. */
  39781. updateTexture(isVisible: boolean): void;
  39782. protected _updateInternalTexture: () => void;
  39783. /**
  39784. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39785. * @param url New url.
  39786. */
  39787. updateURL(url: string): void;
  39788. /**
  39789. * Clones the texture.
  39790. * @returns the cloned texture
  39791. */
  39792. clone(): VideoTexture;
  39793. /**
  39794. * Dispose the texture and release its associated resources.
  39795. */
  39796. dispose(): void;
  39797. /**
  39798. * Creates a video texture straight from a stream.
  39799. * @param scene Define the scene the texture should be created in
  39800. * @param stream Define the stream the texture should be created from
  39801. * @returns The created video texture as a promise
  39802. */
  39803. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39804. /**
  39805. * Creates a video texture straight from your WebCam video feed.
  39806. * @param scene Define the scene the texture should be created in
  39807. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39808. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39809. * @returns The created video texture as a promise
  39810. */
  39811. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39812. minWidth: number;
  39813. maxWidth: number;
  39814. minHeight: number;
  39815. maxHeight: number;
  39816. deviceId: string;
  39817. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39818. /**
  39819. * Creates a video texture straight from your WebCam video feed.
  39820. * @param scene Define the scene the texture should be created in
  39821. * @param onReady Define a callback to triggered once the texture will be ready
  39822. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39823. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39824. */
  39825. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39826. minWidth: number;
  39827. maxWidth: number;
  39828. minHeight: number;
  39829. maxHeight: number;
  39830. deviceId: string;
  39831. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39832. }
  39833. }
  39834. declare module BABYLON {
  39835. /**
  39836. * Defines the interface used by objects working like Scene
  39837. * @hidden
  39838. */
  39839. export interface ISceneLike {
  39840. _addPendingData(data: any): void;
  39841. _removePendingData(data: any): void;
  39842. offlineProvider: IOfflineProvider;
  39843. }
  39844. /**
  39845. * Information about the current host
  39846. */
  39847. export interface HostInformation {
  39848. /**
  39849. * Defines if the current host is a mobile
  39850. */
  39851. isMobile: boolean;
  39852. }
  39853. /** Interface defining initialization parameters for Engine class */
  39854. export interface EngineOptions extends WebGLContextAttributes {
  39855. /**
  39856. * Defines if the engine should no exceed a specified device ratio
  39857. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39858. */
  39859. limitDeviceRatio?: number;
  39860. /**
  39861. * Defines if webvr should be enabled automatically
  39862. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39863. */
  39864. autoEnableWebVR?: boolean;
  39865. /**
  39866. * Defines if webgl2 should be turned off even if supported
  39867. * @see https://doc.babylonjs.com/features/webgl2
  39868. */
  39869. disableWebGL2Support?: boolean;
  39870. /**
  39871. * Defines if webaudio should be initialized as well
  39872. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39873. */
  39874. audioEngine?: boolean;
  39875. /**
  39876. * Defines if animations should run using a deterministic lock step
  39877. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39878. */
  39879. deterministicLockstep?: boolean;
  39880. /** Defines the maximum steps to use with deterministic lock step mode */
  39881. lockstepMaxSteps?: number;
  39882. /** Defines the seconds between each deterministic lock step */
  39883. timeStep?: number;
  39884. /**
  39885. * Defines that engine should ignore context lost events
  39886. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39887. */
  39888. doNotHandleContextLost?: boolean;
  39889. /**
  39890. * Defines that engine should ignore modifying touch action attribute and style
  39891. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39892. */
  39893. doNotHandleTouchAction?: boolean;
  39894. /**
  39895. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39896. */
  39897. useHighPrecisionFloats?: boolean;
  39898. /**
  39899. * Make the canvas XR Compatible for XR sessions
  39900. */
  39901. xrCompatible?: boolean;
  39902. /**
  39903. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39904. */
  39905. useHighPrecisionMatrix?: boolean;
  39906. /**
  39907. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39908. */
  39909. failIfMajorPerformanceCaveat?: boolean;
  39910. /**
  39911. * Defines whether to adapt to the device's viewport characteristics (default: false)
  39912. */
  39913. adaptToDeviceRatio?: boolean;
  39914. }
  39915. /**
  39916. * The base engine class (root of all engines)
  39917. */
  39918. export class ThinEngine {
  39919. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39920. static ExceptionList: ({
  39921. key: string;
  39922. capture: string;
  39923. captureConstraint: number;
  39924. targets: string[];
  39925. } | {
  39926. key: string;
  39927. capture: null;
  39928. captureConstraint: null;
  39929. targets: string[];
  39930. })[];
  39931. /** @hidden */
  39932. static _TextureLoaders: IInternalTextureLoader[];
  39933. /**
  39934. * Returns the current npm package of the sdk
  39935. */
  39936. static get NpmPackage(): string;
  39937. /**
  39938. * Returns the current version of the framework
  39939. */
  39940. static get Version(): string;
  39941. /**
  39942. * Returns a string describing the current engine
  39943. */
  39944. get description(): string;
  39945. /**
  39946. * Returns the name of the engine
  39947. */
  39948. get name(): string;
  39949. /**
  39950. * Returns the version of the engine
  39951. */
  39952. get version(): number;
  39953. /**
  39954. * Gets or sets the epsilon value used by collision engine
  39955. */
  39956. static CollisionsEpsilon: number;
  39957. /**
  39958. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39959. */
  39960. static get ShadersRepository(): string;
  39961. static set ShadersRepository(value: string);
  39962. /** @hidden */
  39963. _shaderProcessor: Nullable<IShaderProcessor>;
  39964. /**
  39965. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39966. */
  39967. forcePOTTextures: boolean;
  39968. /**
  39969. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39970. */
  39971. isFullscreen: boolean;
  39972. /**
  39973. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39974. */
  39975. cullBackFaces: boolean;
  39976. /**
  39977. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39978. */
  39979. renderEvenInBackground: boolean;
  39980. /**
  39981. * Gets or sets a boolean indicating that cache can be kept between frames
  39982. */
  39983. preventCacheWipeBetweenFrames: boolean;
  39984. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39985. validateShaderPrograms: boolean;
  39986. /**
  39987. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39988. * This can provide greater z depth for distant objects.
  39989. */
  39990. useReverseDepthBuffer: boolean;
  39991. /**
  39992. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39993. */
  39994. disableUniformBuffers: boolean;
  39995. private _frameId;
  39996. /**
  39997. * Gets the current frame id
  39998. */
  39999. get frameId(): number;
  40000. /** @hidden */
  40001. _uniformBuffers: UniformBuffer[];
  40002. /**
  40003. * Gets a boolean indicating that the engine supports uniform buffers
  40004. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40005. */
  40006. get supportsUniformBuffers(): boolean;
  40007. /** @hidden */
  40008. _gl: WebGLRenderingContext;
  40009. /** @hidden */
  40010. _webGLVersion: number;
  40011. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40012. protected _windowIsBackground: boolean;
  40013. protected _creationOptions: EngineOptions;
  40014. protected _highPrecisionShadersAllowed: boolean;
  40015. /** @hidden */
  40016. get _shouldUseHighPrecisionShader(): boolean;
  40017. /**
  40018. * Gets a boolean indicating that only power of 2 textures are supported
  40019. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40020. */
  40021. get needPOTTextures(): boolean;
  40022. /** @hidden */
  40023. _badOS: boolean;
  40024. /** @hidden */
  40025. _badDesktopOS: boolean;
  40026. protected _hardwareScalingLevel: number;
  40027. /** @hidden */
  40028. _caps: EngineCapabilities;
  40029. /** @hidden */
  40030. _features: EngineFeatures;
  40031. protected _isStencilEnable: boolean;
  40032. private _glVersion;
  40033. private _glRenderer;
  40034. private _glVendor;
  40035. /** @hidden */
  40036. _videoTextureSupported: boolean;
  40037. protected _renderingQueueLaunched: boolean;
  40038. protected _activeRenderLoops: (() => void)[];
  40039. /**
  40040. * Observable signaled when a context lost event is raised
  40041. */
  40042. onContextLostObservable: Observable<ThinEngine>;
  40043. /**
  40044. * Observable signaled when a context restored event is raised
  40045. */
  40046. onContextRestoredObservable: Observable<ThinEngine>;
  40047. private _onContextLost;
  40048. private _onContextRestored;
  40049. protected _contextWasLost: boolean;
  40050. /** @hidden */
  40051. _doNotHandleContextLost: boolean;
  40052. /**
  40053. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40054. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40055. */
  40056. get doNotHandleContextLost(): boolean;
  40057. set doNotHandleContextLost(value: boolean);
  40058. /**
  40059. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40060. */
  40061. disableVertexArrayObjects: boolean;
  40062. /** @hidden */
  40063. protected _colorWrite: boolean;
  40064. /** @hidden */
  40065. protected _colorWriteChanged: boolean;
  40066. /** @hidden */
  40067. protected _depthCullingState: DepthCullingState;
  40068. /** @hidden */
  40069. protected _stencilState: StencilState;
  40070. /** @hidden */
  40071. _alphaState: AlphaState;
  40072. /** @hidden */
  40073. _alphaMode: number;
  40074. /** @hidden */
  40075. _alphaEquation: number;
  40076. /** @hidden */
  40077. _internalTexturesCache: InternalTexture[];
  40078. /** @hidden */
  40079. protected _activeChannel: number;
  40080. private _currentTextureChannel;
  40081. /** @hidden */
  40082. protected _boundTexturesCache: {
  40083. [key: string]: Nullable<InternalTexture>;
  40084. };
  40085. /** @hidden */
  40086. protected _currentEffect: Nullable<Effect>;
  40087. /** @hidden */
  40088. protected _currentProgram: Nullable<WebGLProgram>;
  40089. protected _compiledEffects: {
  40090. [key: string]: Effect;
  40091. };
  40092. private _vertexAttribArraysEnabled;
  40093. /** @hidden */
  40094. protected _cachedViewport: Nullable<IViewportLike>;
  40095. private _cachedVertexArrayObject;
  40096. /** @hidden */
  40097. protected _cachedVertexBuffers: any;
  40098. /** @hidden */
  40099. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40100. /** @hidden */
  40101. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40102. /** @hidden */
  40103. _currentRenderTarget: Nullable<InternalTexture>;
  40104. private _uintIndicesCurrentlySet;
  40105. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40106. /** @hidden */
  40107. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40108. /** @hidden */
  40109. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40110. private _currentBufferPointers;
  40111. private _currentInstanceLocations;
  40112. private _currentInstanceBuffers;
  40113. private _textureUnits;
  40114. /** @hidden */
  40115. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40116. /** @hidden */
  40117. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40118. /** @hidden */
  40119. _boundRenderFunction: any;
  40120. private _vaoRecordInProgress;
  40121. private _mustWipeVertexAttributes;
  40122. private _emptyTexture;
  40123. private _emptyCubeTexture;
  40124. private _emptyTexture3D;
  40125. private _emptyTexture2DArray;
  40126. /** @hidden */
  40127. _frameHandler: number;
  40128. private _nextFreeTextureSlots;
  40129. private _maxSimultaneousTextures;
  40130. private _activeRequests;
  40131. /** @hidden */
  40132. _transformTextureUrl: Nullable<(url: string) => string>;
  40133. /**
  40134. * Gets information about the current host
  40135. */
  40136. hostInformation: HostInformation;
  40137. protected get _supportsHardwareTextureRescaling(): boolean;
  40138. private _framebufferDimensionsObject;
  40139. /**
  40140. * sets the object from which width and height will be taken from when getting render width and height
  40141. * Will fallback to the gl object
  40142. * @param dimensions the framebuffer width and height that will be used.
  40143. */
  40144. set framebufferDimensionsObject(dimensions: Nullable<{
  40145. framebufferWidth: number;
  40146. framebufferHeight: number;
  40147. }>);
  40148. /**
  40149. * Gets the current viewport
  40150. */
  40151. get currentViewport(): Nullable<IViewportLike>;
  40152. /**
  40153. * Gets the default empty texture
  40154. */
  40155. get emptyTexture(): InternalTexture;
  40156. /**
  40157. * Gets the default empty 3D texture
  40158. */
  40159. get emptyTexture3D(): InternalTexture;
  40160. /**
  40161. * Gets the default empty 2D array texture
  40162. */
  40163. get emptyTexture2DArray(): InternalTexture;
  40164. /**
  40165. * Gets the default empty cube texture
  40166. */
  40167. get emptyCubeTexture(): InternalTexture;
  40168. /**
  40169. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40170. */
  40171. premultipliedAlpha: boolean;
  40172. /**
  40173. * Observable event triggered before each texture is initialized
  40174. */
  40175. onBeforeTextureInitObservable: Observable<Texture>;
  40176. /** @hidden */
  40177. protected _isWebGPU: boolean;
  40178. /**
  40179. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40180. */
  40181. get isWebGPU(): boolean;
  40182. /** @hidden */
  40183. protected _shaderPlatformName: string;
  40184. /**
  40185. * Gets the shader platfrom name used by the effects.
  40186. */
  40187. get shaderPlatformName(): string;
  40188. /**
  40189. * Creates a new engine
  40190. * @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
  40191. * @param antialias defines enable antialiasing (default: false)
  40192. * @param options defines further options to be sent to the getContext() function
  40193. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40194. */
  40195. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40196. /**
  40197. * @hidden
  40198. */
  40199. _debugPushGroup(groupName: string, targetObject?: number): void;
  40200. /**
  40201. * @hidden
  40202. */
  40203. _debugPopGroup(targetObject?: number): void;
  40204. /**
  40205. * @hidden
  40206. */
  40207. _debugInsertMarker(text: string, targetObject?: number): void;
  40208. /**
  40209. * Shared initialization across engines types.
  40210. * @param canvas The canvas associated with this instance of the engine.
  40211. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40212. * @param audioEngine Defines if an audio engine should be created by default
  40213. */
  40214. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40215. /**
  40216. * Gets a shader processor implementation fitting with the current engine type.
  40217. * @returns The shader processor implementation.
  40218. */
  40219. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40220. /** @hidden */
  40221. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40222. private _rebuildInternalTextures;
  40223. private _rebuildEffects;
  40224. /**
  40225. * Gets a boolean indicating if all created effects are ready
  40226. * @returns true if all effects are ready
  40227. */
  40228. areAllEffectsReady(): boolean;
  40229. protected _rebuildBuffers(): void;
  40230. protected _initGLContext(): void;
  40231. protected _initFeatures(): void;
  40232. /**
  40233. * Gets version of the current webGL context
  40234. * Keep it for back compat - use version instead
  40235. */
  40236. get webGLVersion(): number;
  40237. /**
  40238. * Gets a string identifying the name of the class
  40239. * @returns "Engine" string
  40240. */
  40241. getClassName(): string;
  40242. /**
  40243. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40244. */
  40245. get isStencilEnable(): boolean;
  40246. /** @hidden */
  40247. _prepareWorkingCanvas(): void;
  40248. /**
  40249. * Reset the texture cache to empty state
  40250. */
  40251. resetTextureCache(): void;
  40252. /**
  40253. * Gets an object containing information about the current webGL context
  40254. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40255. */
  40256. getGlInfo(): {
  40257. vendor: string;
  40258. renderer: string;
  40259. version: string;
  40260. };
  40261. /**
  40262. * Defines the hardware scaling level.
  40263. * By default the hardware scaling level is computed from the window device ratio.
  40264. * 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.
  40265. * @param level defines the level to use
  40266. */
  40267. setHardwareScalingLevel(level: number): void;
  40268. /**
  40269. * Gets the current hardware scaling level.
  40270. * By default the hardware scaling level is computed from the window device ratio.
  40271. * 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.
  40272. * @returns a number indicating the current hardware scaling level
  40273. */
  40274. getHardwareScalingLevel(): number;
  40275. /**
  40276. * Gets the list of loaded textures
  40277. * @returns an array containing all loaded textures
  40278. */
  40279. getLoadedTexturesCache(): InternalTexture[];
  40280. /**
  40281. * Gets the object containing all engine capabilities
  40282. * @returns the EngineCapabilities object
  40283. */
  40284. getCaps(): EngineCapabilities;
  40285. /**
  40286. * stop executing a render loop function and remove it from the execution array
  40287. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40288. */
  40289. stopRenderLoop(renderFunction?: () => void): void;
  40290. /** @hidden */
  40291. _renderLoop(): void;
  40292. /**
  40293. * Gets the HTML canvas attached with the current webGL context
  40294. * @returns a HTML canvas
  40295. */
  40296. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40297. /**
  40298. * Gets host window
  40299. * @returns the host window object
  40300. */
  40301. getHostWindow(): Nullable<Window>;
  40302. /**
  40303. * Gets the current render width
  40304. * @param useScreen defines if screen size must be used (or the current render target if any)
  40305. * @returns a number defining the current render width
  40306. */
  40307. getRenderWidth(useScreen?: boolean): number;
  40308. /**
  40309. * Gets the current render height
  40310. * @param useScreen defines if screen size must be used (or the current render target if any)
  40311. * @returns a number defining the current render height
  40312. */
  40313. getRenderHeight(useScreen?: boolean): number;
  40314. /**
  40315. * Can be used to override the current requestAnimationFrame requester.
  40316. * @hidden
  40317. */
  40318. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40319. /**
  40320. * Register and execute a render loop. The engine can have more than one render function
  40321. * @param renderFunction defines the function to continuously execute
  40322. */
  40323. runRenderLoop(renderFunction: () => void): void;
  40324. /**
  40325. * Clear the current render buffer or the current render target (if any is set up)
  40326. * @param color defines the color to use
  40327. * @param backBuffer defines if the back buffer must be cleared
  40328. * @param depth defines if the depth buffer must be cleared
  40329. * @param stencil defines if the stencil buffer must be cleared
  40330. */
  40331. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40332. protected _viewportCached: {
  40333. x: number;
  40334. y: number;
  40335. z: number;
  40336. w: number;
  40337. };
  40338. /** @hidden */
  40339. _viewport(x: number, y: number, width: number, height: number): void;
  40340. /**
  40341. * Set the WebGL's viewport
  40342. * @param viewport defines the viewport element to be used
  40343. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40344. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40345. */
  40346. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40347. /**
  40348. * Begin a new frame
  40349. */
  40350. beginFrame(): void;
  40351. /**
  40352. * Enf the current frame
  40353. */
  40354. endFrame(): void;
  40355. /**
  40356. * Resize the view according to the canvas' size
  40357. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40358. */
  40359. resize(forceSetSize?: boolean): void;
  40360. /**
  40361. * Force a specific size of the canvas
  40362. * @param width defines the new canvas' width
  40363. * @param height defines the new canvas' height
  40364. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40365. * @returns true if the size was changed
  40366. */
  40367. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40368. /**
  40369. * Binds the frame buffer to the specified texture.
  40370. * @param texture The texture to render to or null for the default canvas
  40371. * @param faceIndex The face of the texture to render to in case of cube texture
  40372. * @param requiredWidth The width of the target to render to
  40373. * @param requiredHeight The height of the target to render to
  40374. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40375. * @param lodLevel defines the lod level to bind to the frame buffer
  40376. * @param layer defines the 2d array index to bind to frame buffer to
  40377. */
  40378. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40379. /** @hidden */
  40380. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40381. /**
  40382. * Unbind the current render target texture from the webGL context
  40383. * @param texture defines the render target texture to unbind
  40384. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40385. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40386. */
  40387. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40388. /**
  40389. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40390. */
  40391. flushFramebuffer(): void;
  40392. /**
  40393. * Unbind the current render target and bind the default framebuffer
  40394. */
  40395. restoreDefaultFramebuffer(): void;
  40396. /** @hidden */
  40397. protected _resetVertexBufferBinding(): void;
  40398. /**
  40399. * Creates a vertex buffer
  40400. * @param data the data for the vertex buffer
  40401. * @returns the new WebGL static buffer
  40402. */
  40403. createVertexBuffer(data: DataArray): DataBuffer;
  40404. private _createVertexBuffer;
  40405. /**
  40406. * Creates a dynamic vertex buffer
  40407. * @param data the data for the dynamic vertex buffer
  40408. * @returns the new WebGL dynamic buffer
  40409. */
  40410. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40411. protected _resetIndexBufferBinding(): void;
  40412. /**
  40413. * Creates a new index buffer
  40414. * @param indices defines the content of the index buffer
  40415. * @param updatable defines if the index buffer must be updatable
  40416. * @returns a new webGL buffer
  40417. */
  40418. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40419. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40420. /**
  40421. * Bind a webGL buffer to the webGL context
  40422. * @param buffer defines the buffer to bind
  40423. */
  40424. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40425. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40426. private bindBuffer;
  40427. /**
  40428. * update the bound buffer with the given data
  40429. * @param data defines the data to update
  40430. */
  40431. updateArrayBuffer(data: Float32Array): void;
  40432. private _vertexAttribPointer;
  40433. /** @hidden */
  40434. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40435. private _bindVertexBuffersAttributes;
  40436. /**
  40437. * Records a vertex array object
  40438. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40439. * @param vertexBuffers defines the list of vertex buffers to store
  40440. * @param indexBuffer defines the index buffer to store
  40441. * @param effect defines the effect to store
  40442. * @returns the new vertex array object
  40443. */
  40444. recordVertexArrayObject(vertexBuffers: {
  40445. [key: string]: VertexBuffer;
  40446. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40447. /**
  40448. * Bind a specific vertex array object
  40449. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40450. * @param vertexArrayObject defines the vertex array object to bind
  40451. * @param indexBuffer defines the index buffer to bind
  40452. */
  40453. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40454. /**
  40455. * Bind webGl buffers directly to the webGL context
  40456. * @param vertexBuffer defines the vertex buffer to bind
  40457. * @param indexBuffer defines the index buffer to bind
  40458. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40459. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40460. * @param effect defines the effect associated with the vertex buffer
  40461. */
  40462. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40463. private _unbindVertexArrayObject;
  40464. /**
  40465. * Bind a list of vertex buffers to the webGL context
  40466. * @param vertexBuffers defines the list of vertex buffers to bind
  40467. * @param indexBuffer defines the index buffer to bind
  40468. * @param effect defines the effect associated with the vertex buffers
  40469. */
  40470. bindBuffers(vertexBuffers: {
  40471. [key: string]: Nullable<VertexBuffer>;
  40472. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40473. /**
  40474. * Unbind all instance attributes
  40475. */
  40476. unbindInstanceAttributes(): void;
  40477. /**
  40478. * Release and free the memory of a vertex array object
  40479. * @param vao defines the vertex array object to delete
  40480. */
  40481. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40482. /** @hidden */
  40483. _releaseBuffer(buffer: DataBuffer): boolean;
  40484. protected _deleteBuffer(buffer: DataBuffer): void;
  40485. /**
  40486. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40487. * @param instancesBuffer defines the webGL buffer to update and bind
  40488. * @param data defines the data to store in the buffer
  40489. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40490. */
  40491. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40492. /**
  40493. * Bind the content of a webGL buffer used with instantiation
  40494. * @param instancesBuffer defines the webGL buffer to bind
  40495. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40496. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40497. */
  40498. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40499. /**
  40500. * Disable the instance attribute corresponding to the name in parameter
  40501. * @param name defines the name of the attribute to disable
  40502. */
  40503. disableInstanceAttributeByName(name: string): void;
  40504. /**
  40505. * Disable the instance attribute corresponding to the location in parameter
  40506. * @param attributeLocation defines the attribute location of the attribute to disable
  40507. */
  40508. disableInstanceAttribute(attributeLocation: number): void;
  40509. /**
  40510. * Disable the attribute corresponding to the location in parameter
  40511. * @param attributeLocation defines the attribute location of the attribute to disable
  40512. */
  40513. disableAttributeByIndex(attributeLocation: number): void;
  40514. /**
  40515. * Send a draw order
  40516. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40517. * @param indexStart defines the starting index
  40518. * @param indexCount defines the number of index to draw
  40519. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40520. */
  40521. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40522. /**
  40523. * Draw a list of points
  40524. * @param verticesStart defines the index of first vertex to draw
  40525. * @param verticesCount defines the count of vertices to draw
  40526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40527. */
  40528. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40529. /**
  40530. * Draw a list of unindexed primitives
  40531. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40532. * @param verticesStart defines the index of first vertex to draw
  40533. * @param verticesCount defines the count of vertices to draw
  40534. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40535. */
  40536. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40537. /**
  40538. * Draw a list of indexed primitives
  40539. * @param fillMode defines the primitive to use
  40540. * @param indexStart defines the starting index
  40541. * @param indexCount defines the number of index to draw
  40542. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40543. */
  40544. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40545. /**
  40546. * Draw a list of unindexed primitives
  40547. * @param fillMode defines the primitive to use
  40548. * @param verticesStart defines the index of first vertex to draw
  40549. * @param verticesCount defines the count of vertices to draw
  40550. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40551. */
  40552. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40553. private _drawMode;
  40554. /** @hidden */
  40555. protected _reportDrawCall(): void;
  40556. /** @hidden */
  40557. _releaseEffect(effect: Effect): void;
  40558. /** @hidden */
  40559. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40560. /**
  40561. * Create a new effect (used to store vertex/fragment shaders)
  40562. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40563. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40564. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40565. * @param samplers defines an array of string used to represent textures
  40566. * @param defines defines the string containing the defines to use to compile the shaders
  40567. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40568. * @param onCompiled defines a function to call when the effect creation is successful
  40569. * @param onError defines a function to call when the effect creation has failed
  40570. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40571. * @returns the new Effect
  40572. */
  40573. 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;
  40574. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40575. private _compileShader;
  40576. private _compileRawShader;
  40577. /** @hidden */
  40578. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40579. /**
  40580. * Directly creates a webGL program
  40581. * @param pipelineContext defines the pipeline context to attach to
  40582. * @param vertexCode defines the vertex shader code to use
  40583. * @param fragmentCode defines the fragment shader code to use
  40584. * @param context defines the webGL context to use (if not set, the current one will be used)
  40585. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40586. * @returns the new webGL program
  40587. */
  40588. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40589. /**
  40590. * Creates a webGL program
  40591. * @param pipelineContext defines the pipeline context to attach to
  40592. * @param vertexCode defines the vertex shader code to use
  40593. * @param fragmentCode defines the fragment shader code to use
  40594. * @param defines defines the string containing the defines to use to compile the shaders
  40595. * @param context defines the webGL context to use (if not set, the current one will be used)
  40596. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40597. * @returns the new webGL program
  40598. */
  40599. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40600. /**
  40601. * Creates a new pipeline context
  40602. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40603. * @returns the new pipeline
  40604. */
  40605. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40606. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40607. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40608. /** @hidden */
  40609. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40610. /** @hidden */
  40611. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40612. /** @hidden */
  40613. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40614. /**
  40615. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40616. * @param pipelineContext defines the pipeline context to use
  40617. * @param uniformsNames defines the list of uniform names
  40618. * @returns an array of webGL uniform locations
  40619. */
  40620. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40621. /**
  40622. * Gets the list of active attributes for a given webGL program
  40623. * @param pipelineContext defines the pipeline context to use
  40624. * @param attributesNames defines the list of attribute names to get
  40625. * @returns an array of indices indicating the offset of each attribute
  40626. */
  40627. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40628. /**
  40629. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40630. * @param effect defines the effect to activate
  40631. */
  40632. enableEffect(effect: Nullable<Effect>): void;
  40633. /**
  40634. * Set the value of an uniform to a number (int)
  40635. * @param uniform defines the webGL uniform location where to store the value
  40636. * @param value defines the int number to store
  40637. * @returns true if the value was set
  40638. */
  40639. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40640. /**
  40641. * Set the value of an uniform to a int2
  40642. * @param uniform defines the webGL uniform location where to store the value
  40643. * @param x defines the 1st component of the value
  40644. * @param y defines the 2nd component of the value
  40645. * @returns true if the value was set
  40646. */
  40647. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40648. /**
  40649. * Set the value of an uniform to a int3
  40650. * @param uniform defines the webGL uniform location where to store the value
  40651. * @param x defines the 1st component of the value
  40652. * @param y defines the 2nd component of the value
  40653. * @param z defines the 3rd component of the value
  40654. * @returns true if the value was set
  40655. */
  40656. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40657. /**
  40658. * Set the value of an uniform to a int4
  40659. * @param uniform defines the webGL uniform location where to store the value
  40660. * @param x defines the 1st component of the value
  40661. * @param y defines the 2nd component of the value
  40662. * @param z defines the 3rd component of the value
  40663. * @param w defines the 4th component of the value
  40664. * @returns true if the value was set
  40665. */
  40666. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40667. /**
  40668. * Set the value of an uniform to an array of int32
  40669. * @param uniform defines the webGL uniform location where to store the value
  40670. * @param array defines the array of int32 to store
  40671. * @returns true if the value was set
  40672. */
  40673. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40674. /**
  40675. * Set the value of an uniform to an array of int32 (stored as vec2)
  40676. * @param uniform defines the webGL uniform location where to store the value
  40677. * @param array defines the array of int32 to store
  40678. * @returns true if the value was set
  40679. */
  40680. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40681. /**
  40682. * Set the value of an uniform to an array of int32 (stored as vec3)
  40683. * @param uniform defines the webGL uniform location where to store the value
  40684. * @param array defines the array of int32 to store
  40685. * @returns true if the value was set
  40686. */
  40687. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40688. /**
  40689. * Set the value of an uniform to an array of int32 (stored as vec4)
  40690. * @param uniform defines the webGL uniform location where to store the value
  40691. * @param array defines the array of int32 to store
  40692. * @returns true if the value was set
  40693. */
  40694. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40695. /**
  40696. * Set the value of an uniform to an array of number
  40697. * @param uniform defines the webGL uniform location where to store the value
  40698. * @param array defines the array of number to store
  40699. * @returns true if the value was set
  40700. */
  40701. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40702. /**
  40703. * Set the value of an uniform to an array of number (stored as vec2)
  40704. * @param uniform defines the webGL uniform location where to store the value
  40705. * @param array defines the array of number to store
  40706. * @returns true if the value was set
  40707. */
  40708. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40709. /**
  40710. * Set the value of an uniform to an array of number (stored as vec3)
  40711. * @param uniform defines the webGL uniform location where to store the value
  40712. * @param array defines the array of number to store
  40713. * @returns true if the value was set
  40714. */
  40715. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40716. /**
  40717. * Set the value of an uniform to an array of number (stored as vec4)
  40718. * @param uniform defines the webGL uniform location where to store the value
  40719. * @param array defines the array of number to store
  40720. * @returns true if the value was set
  40721. */
  40722. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40723. /**
  40724. * Set the value of an uniform to an array of float32 (stored as matrices)
  40725. * @param uniform defines the webGL uniform location where to store the value
  40726. * @param matrices defines the array of float32 to store
  40727. * @returns true if the value was set
  40728. */
  40729. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40730. /**
  40731. * Set the value of an uniform to a matrix (3x3)
  40732. * @param uniform defines the webGL uniform location where to store the value
  40733. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40734. * @returns true if the value was set
  40735. */
  40736. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40737. /**
  40738. * Set the value of an uniform to a matrix (2x2)
  40739. * @param uniform defines the webGL uniform location where to store the value
  40740. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40741. * @returns true if the value was set
  40742. */
  40743. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40744. /**
  40745. * Set the value of an uniform to a number (float)
  40746. * @param uniform defines the webGL uniform location where to store the value
  40747. * @param value defines the float number to store
  40748. * @returns true if the value was transfered
  40749. */
  40750. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40751. /**
  40752. * Set the value of an uniform to a vec2
  40753. * @param uniform defines the webGL uniform location where to store the value
  40754. * @param x defines the 1st component of the value
  40755. * @param y defines the 2nd component of the value
  40756. * @returns true if the value was set
  40757. */
  40758. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40759. /**
  40760. * Set the value of an uniform to a vec3
  40761. * @param uniform defines the webGL uniform location where to store the value
  40762. * @param x defines the 1st component of the value
  40763. * @param y defines the 2nd component of the value
  40764. * @param z defines the 3rd component of the value
  40765. * @returns true if the value was set
  40766. */
  40767. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40768. /**
  40769. * Set the value of an uniform to a vec4
  40770. * @param uniform defines the webGL uniform location where to store the value
  40771. * @param x defines the 1st component of the value
  40772. * @param y defines the 2nd component of the value
  40773. * @param z defines the 3rd component of the value
  40774. * @param w defines the 4th component of the value
  40775. * @returns true if the value was set
  40776. */
  40777. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40778. /**
  40779. * Apply all cached states (depth, culling, stencil and alpha)
  40780. */
  40781. applyStates(): void;
  40782. /**
  40783. * Enable or disable color writing
  40784. * @param enable defines the state to set
  40785. */
  40786. setColorWrite(enable: boolean): void;
  40787. /**
  40788. * Gets a boolean indicating if color writing is enabled
  40789. * @returns the current color writing state
  40790. */
  40791. getColorWrite(): boolean;
  40792. /**
  40793. * Gets the depth culling state manager
  40794. */
  40795. get depthCullingState(): DepthCullingState;
  40796. /**
  40797. * Gets the alpha state manager
  40798. */
  40799. get alphaState(): AlphaState;
  40800. /**
  40801. * Gets the stencil state manager
  40802. */
  40803. get stencilState(): StencilState;
  40804. /**
  40805. * Clears the list of texture accessible through engine.
  40806. * This can help preventing texture load conflict due to name collision.
  40807. */
  40808. clearInternalTexturesCache(): void;
  40809. /**
  40810. * Force the entire cache to be cleared
  40811. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40812. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40813. */
  40814. wipeCaches(bruteForce?: boolean): void;
  40815. /** @hidden */
  40816. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40817. min: number;
  40818. mag: number;
  40819. };
  40820. /** @hidden */
  40821. protected _createTexture(): WebGLTexture;
  40822. /** @hidden */
  40823. _createHardwareTexture(): HardwareTextureWrapper;
  40824. 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 | {
  40825. width: number;
  40826. height: number;
  40827. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40828. width: number;
  40829. height: number;
  40830. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40831. width: number;
  40832. height: number;
  40833. }, 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;
  40834. /**
  40835. * Usually called from Texture.ts.
  40836. * Passed information to create a WebGLTexture
  40837. * @param url defines a value which contains one of the following:
  40838. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40839. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40840. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40841. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40842. * @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)
  40843. * @param scene needed for loading to the correct scene
  40844. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40845. * @param onLoad optional callback to be called upon successful completion
  40846. * @param onError optional callback to be called upon failure
  40847. * @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
  40848. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40849. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40850. * @param forcedExtension defines the extension to use to pick the right loader
  40851. * @param mimeType defines an optional mime type
  40852. * @param loaderOptions options to be passed to the loader
  40853. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40854. */
  40855. 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;
  40856. /**
  40857. * Loads an image as an HTMLImageElement.
  40858. * @param input url string, ArrayBuffer, or Blob to load
  40859. * @param onLoad callback called when the image successfully loads
  40860. * @param onError callback called when the image fails to load
  40861. * @param offlineProvider offline provider for caching
  40862. * @param mimeType optional mime type
  40863. * @returns the HTMLImageElement of the loaded image
  40864. * @hidden
  40865. */
  40866. 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>;
  40867. /**
  40868. * @hidden
  40869. */
  40870. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40871. private _unpackFlipYCached;
  40872. /**
  40873. * In case you are sharing the context with other applications, it might
  40874. * be interested to not cache the unpack flip y state to ensure a consistent
  40875. * value would be set.
  40876. */
  40877. enableUnpackFlipYCached: boolean;
  40878. /** @hidden */
  40879. _unpackFlipY(value: boolean): void;
  40880. /** @hidden */
  40881. _getUnpackAlignement(): number;
  40882. private _getTextureTarget;
  40883. /**
  40884. * Update the sampling mode of a given texture
  40885. * @param samplingMode defines the required sampling mode
  40886. * @param texture defines the texture to update
  40887. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40888. */
  40889. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40890. /**
  40891. * Update the dimensions of a texture
  40892. * @param texture texture to update
  40893. * @param width new width of the texture
  40894. * @param height new height of the texture
  40895. * @param depth new depth of the texture
  40896. */
  40897. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40898. /**
  40899. * Update the sampling mode of a given texture
  40900. * @param texture defines the texture to update
  40901. * @param wrapU defines the texture wrap mode of the u coordinates
  40902. * @param wrapV defines the texture wrap mode of the v coordinates
  40903. * @param wrapR defines the texture wrap mode of the r coordinates
  40904. */
  40905. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40906. /** @hidden */
  40907. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40908. width: number;
  40909. height: number;
  40910. layers?: number;
  40911. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40912. /** @hidden */
  40913. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40914. /** @hidden */
  40915. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40916. /**
  40917. * Update a portion of an internal texture
  40918. * @param texture defines the texture to update
  40919. * @param imageData defines the data to store into the texture
  40920. * @param xOffset defines the x coordinates of the update rectangle
  40921. * @param yOffset defines the y coordinates of the update rectangle
  40922. * @param width defines the width of the update rectangle
  40923. * @param height defines the height of the update rectangle
  40924. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40925. * @param lod defines the lod level to update (0 by default)
  40926. */
  40927. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40928. /** @hidden */
  40929. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40930. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40931. private _prepareWebGLTexture;
  40932. /** @hidden */
  40933. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40934. private _getDepthStencilBuffer;
  40935. /** @hidden */
  40936. _releaseFramebufferObjects(texture: InternalTexture): void;
  40937. /** @hidden */
  40938. _releaseTexture(texture: InternalTexture): void;
  40939. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40940. protected _setProgram(program: WebGLProgram): void;
  40941. protected _boundUniforms: {
  40942. [key: number]: WebGLUniformLocation;
  40943. };
  40944. /**
  40945. * Binds an effect to the webGL context
  40946. * @param effect defines the effect to bind
  40947. */
  40948. bindSamplers(effect: Effect): void;
  40949. private _activateCurrentTexture;
  40950. /** @hidden */
  40951. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40952. /** @hidden */
  40953. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  40954. /**
  40955. * Unbind all textures from the webGL context
  40956. */
  40957. unbindAllTextures(): void;
  40958. /**
  40959. * Sets a texture to the according uniform.
  40960. * @param channel The texture channel
  40961. * @param uniform The uniform to set
  40962. * @param texture The texture to apply
  40963. * @param name The name of the uniform in the effect
  40964. */
  40965. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  40966. private _bindSamplerUniformToChannel;
  40967. private _getTextureWrapMode;
  40968. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  40969. /**
  40970. * Sets an array of texture to the webGL context
  40971. * @param channel defines the channel where the texture array must be set
  40972. * @param uniform defines the associated uniform location
  40973. * @param textures defines the array of textures to bind
  40974. * @param name name of the channel
  40975. */
  40976. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  40977. /** @hidden */
  40978. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40979. private _setTextureParameterFloat;
  40980. private _setTextureParameterInteger;
  40981. /**
  40982. * Unbind all vertex attributes from the webGL context
  40983. */
  40984. unbindAllAttributes(): void;
  40985. /**
  40986. * 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
  40987. */
  40988. releaseEffects(): void;
  40989. /**
  40990. * Dispose and release all associated resources
  40991. */
  40992. dispose(): void;
  40993. /**
  40994. * Attach a new callback raised when context lost event is fired
  40995. * @param callback defines the callback to call
  40996. */
  40997. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40998. /**
  40999. * Attach a new callback raised when context restored event is fired
  41000. * @param callback defines the callback to call
  41001. */
  41002. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41003. /**
  41004. * Get the current error code of the webGL context
  41005. * @returns the error code
  41006. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41007. */
  41008. getError(): number;
  41009. private _canRenderToFloatFramebuffer;
  41010. private _canRenderToHalfFloatFramebuffer;
  41011. private _canRenderToFramebuffer;
  41012. /** @hidden */
  41013. _getWebGLTextureType(type: number): number;
  41014. /** @hidden */
  41015. _getInternalFormat(format: number): number;
  41016. /** @hidden */
  41017. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41018. /** @hidden */
  41019. _getRGBAMultiSampleBufferFormat(type: number): number;
  41020. /** @hidden */
  41021. _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;
  41022. /**
  41023. * Loads a file from a url
  41024. * @param url url to load
  41025. * @param onSuccess callback called when the file successfully loads
  41026. * @param onProgress callback called while file is loading (if the server supports this mode)
  41027. * @param offlineProvider defines the offline provider for caching
  41028. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41029. * @param onError callback called when the file fails to load
  41030. * @returns a file request object
  41031. * @hidden
  41032. */
  41033. 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;
  41034. /**
  41035. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41036. * @param x defines the x coordinate of the rectangle where pixels must be read
  41037. * @param y defines the y coordinate of the rectangle where pixels must be read
  41038. * @param width defines the width of the rectangle where pixels must be read
  41039. * @param height defines the height of the rectangle where pixels must be read
  41040. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41041. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41042. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41043. */
  41044. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41045. private static _IsSupported;
  41046. private static _HasMajorPerformanceCaveat;
  41047. /**
  41048. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41049. */
  41050. static get IsSupported(): boolean;
  41051. /**
  41052. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41053. * @returns true if the engine can be created
  41054. * @ignorenaming
  41055. */
  41056. static isSupported(): boolean;
  41057. /**
  41058. * 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)
  41059. */
  41060. static get HasMajorPerformanceCaveat(): boolean;
  41061. /**
  41062. * Find the next highest power of two.
  41063. * @param x Number to start search from.
  41064. * @return Next highest power of two.
  41065. */
  41066. static CeilingPOT(x: number): number;
  41067. /**
  41068. * Find the next lowest power of two.
  41069. * @param x Number to start search from.
  41070. * @return Next lowest power of two.
  41071. */
  41072. static FloorPOT(x: number): number;
  41073. /**
  41074. * Find the nearest power of two.
  41075. * @param x Number to start search from.
  41076. * @return Next nearest power of two.
  41077. */
  41078. static NearestPOT(x: number): number;
  41079. /**
  41080. * Get the closest exponent of two
  41081. * @param value defines the value to approximate
  41082. * @param max defines the maximum value to return
  41083. * @param mode defines how to define the closest value
  41084. * @returns closest exponent of two of the given value
  41085. */
  41086. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41087. /**
  41088. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41089. * @param func - the function to be called
  41090. * @param requester - the object that will request the next frame. Falls back to window.
  41091. * @returns frame number
  41092. */
  41093. static QueueNewFrame(func: () => void, requester?: any): number;
  41094. /**
  41095. * Gets host document
  41096. * @returns the host document object
  41097. */
  41098. getHostDocument(): Nullable<Document>;
  41099. }
  41100. }
  41101. declare module BABYLON {
  41102. /**
  41103. * Defines the source of the internal texture
  41104. */
  41105. export enum InternalTextureSource {
  41106. /**
  41107. * The source of the texture data is unknown
  41108. */
  41109. Unknown = 0,
  41110. /**
  41111. * Texture data comes from an URL
  41112. */
  41113. Url = 1,
  41114. /**
  41115. * Texture data is only used for temporary storage
  41116. */
  41117. Temp = 2,
  41118. /**
  41119. * Texture data comes from raw data (ArrayBuffer)
  41120. */
  41121. Raw = 3,
  41122. /**
  41123. * Texture content is dynamic (video or dynamic texture)
  41124. */
  41125. Dynamic = 4,
  41126. /**
  41127. * Texture content is generated by rendering to it
  41128. */
  41129. RenderTarget = 5,
  41130. /**
  41131. * Texture content is part of a multi render target process
  41132. */
  41133. MultiRenderTarget = 6,
  41134. /**
  41135. * Texture data comes from a cube data file
  41136. */
  41137. Cube = 7,
  41138. /**
  41139. * Texture data comes from a raw cube data
  41140. */
  41141. CubeRaw = 8,
  41142. /**
  41143. * Texture data come from a prefiltered cube data file
  41144. */
  41145. CubePrefiltered = 9,
  41146. /**
  41147. * Texture content is raw 3D data
  41148. */
  41149. Raw3D = 10,
  41150. /**
  41151. * Texture content is raw 2D array data
  41152. */
  41153. Raw2DArray = 11,
  41154. /**
  41155. * Texture content is a depth texture
  41156. */
  41157. Depth = 12,
  41158. /**
  41159. * Texture data comes from a raw cube data encoded with RGBD
  41160. */
  41161. CubeRawRGBD = 13
  41162. }
  41163. /**
  41164. * Class used to store data associated with WebGL texture data for the engine
  41165. * This class should not be used directly
  41166. */
  41167. export class InternalTexture {
  41168. /** @hidden */
  41169. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41170. /**
  41171. * Defines if the texture is ready
  41172. */
  41173. isReady: boolean;
  41174. /**
  41175. * Defines if the texture is a cube texture
  41176. */
  41177. isCube: boolean;
  41178. /**
  41179. * Defines if the texture contains 3D data
  41180. */
  41181. is3D: boolean;
  41182. /**
  41183. * Defines if the texture contains 2D array data
  41184. */
  41185. is2DArray: boolean;
  41186. /**
  41187. * Defines if the texture contains multiview data
  41188. */
  41189. isMultiview: boolean;
  41190. /**
  41191. * Gets the URL used to load this texture
  41192. */
  41193. url: string;
  41194. /** @hidden */
  41195. _originalUrl: string;
  41196. /**
  41197. * Gets the sampling mode of the texture
  41198. */
  41199. samplingMode: number;
  41200. /**
  41201. * Gets a boolean indicating if the texture needs mipmaps generation
  41202. */
  41203. generateMipMaps: boolean;
  41204. /**
  41205. * Gets the number of samples used by the texture (WebGL2+ only)
  41206. */
  41207. samples: number;
  41208. /**
  41209. * Gets the type of the texture (int, float...)
  41210. */
  41211. type: number;
  41212. /**
  41213. * Gets the format of the texture (RGB, RGBA...)
  41214. */
  41215. format: number;
  41216. /**
  41217. * Observable called when the texture is loaded
  41218. */
  41219. onLoadedObservable: Observable<InternalTexture>;
  41220. /**
  41221. * Gets the width of the texture
  41222. */
  41223. width: number;
  41224. /**
  41225. * Gets the height of the texture
  41226. */
  41227. height: number;
  41228. /**
  41229. * Gets the depth of the texture
  41230. */
  41231. depth: number;
  41232. /**
  41233. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41234. */
  41235. baseWidth: number;
  41236. /**
  41237. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41238. */
  41239. baseHeight: number;
  41240. /**
  41241. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41242. */
  41243. baseDepth: number;
  41244. /**
  41245. * Gets a boolean indicating if the texture is inverted on Y axis
  41246. */
  41247. invertY: boolean;
  41248. /** @hidden */
  41249. _invertVScale: boolean;
  41250. /** @hidden */
  41251. _associatedChannel: number;
  41252. /** @hidden */
  41253. _source: InternalTextureSource;
  41254. /** @hidden */
  41255. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41256. /** @hidden */
  41257. _bufferView: Nullable<ArrayBufferView>;
  41258. /** @hidden */
  41259. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41260. /** @hidden */
  41261. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41262. /** @hidden */
  41263. _size: number;
  41264. /** @hidden */
  41265. _extension: string;
  41266. /** @hidden */
  41267. _files: Nullable<string[]>;
  41268. /** @hidden */
  41269. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41270. /** @hidden */
  41271. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41272. /** @hidden */
  41273. _framebuffer: Nullable<WebGLFramebuffer>;
  41274. /** @hidden */
  41275. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41276. /** @hidden */
  41277. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41278. /** @hidden */
  41279. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41280. /** @hidden */
  41281. _attachments: Nullable<number[]>;
  41282. /** @hidden */
  41283. _textureArray: Nullable<InternalTexture[]>;
  41284. /** @hidden */
  41285. _cachedCoordinatesMode: Nullable<number>;
  41286. /** @hidden */
  41287. _cachedWrapU: Nullable<number>;
  41288. /** @hidden */
  41289. _cachedWrapV: Nullable<number>;
  41290. /** @hidden */
  41291. _cachedWrapR: Nullable<number>;
  41292. /** @hidden */
  41293. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41294. /** @hidden */
  41295. _isDisabled: boolean;
  41296. /** @hidden */
  41297. _compression: Nullable<string>;
  41298. /** @hidden */
  41299. _generateStencilBuffer: boolean;
  41300. /** @hidden */
  41301. _generateDepthBuffer: boolean;
  41302. /** @hidden */
  41303. _comparisonFunction: number;
  41304. /** @hidden */
  41305. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41306. /** @hidden */
  41307. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41308. /** @hidden */
  41309. _sphericalPolynomialComputed: boolean;
  41310. /** @hidden */
  41311. _lodGenerationScale: number;
  41312. /** @hidden */
  41313. _lodGenerationOffset: number;
  41314. /** @hidden */
  41315. _depthStencilTexture: Nullable<InternalTexture>;
  41316. /** @hidden */
  41317. _colorTextureArray: Nullable<WebGLTexture>;
  41318. /** @hidden */
  41319. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41320. /** @hidden */
  41321. _lodTextureHigh: Nullable<BaseTexture>;
  41322. /** @hidden */
  41323. _lodTextureMid: Nullable<BaseTexture>;
  41324. /** @hidden */
  41325. _lodTextureLow: Nullable<BaseTexture>;
  41326. /** @hidden */
  41327. _isRGBD: boolean;
  41328. /** @hidden */
  41329. _linearSpecularLOD: boolean;
  41330. /** @hidden */
  41331. _irradianceTexture: Nullable<BaseTexture>;
  41332. /** @hidden */
  41333. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41334. /** @hidden */
  41335. _references: number;
  41336. /** @hidden */
  41337. _gammaSpace: Nullable<boolean>;
  41338. private _engine;
  41339. private _uniqueId;
  41340. private static _Counter;
  41341. /** Gets the unique id of the internal texture */
  41342. get uniqueId(): number;
  41343. /**
  41344. * Gets the Engine the texture belongs to.
  41345. * @returns The babylon engine
  41346. */
  41347. getEngine(): ThinEngine;
  41348. /**
  41349. * Gets the data source type of the texture
  41350. */
  41351. get source(): InternalTextureSource;
  41352. /**
  41353. * Creates a new InternalTexture
  41354. * @param engine defines the engine to use
  41355. * @param source defines the type of data that will be used
  41356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41357. */
  41358. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41359. /**
  41360. * Increments the number of references (ie. the number of Texture that point to it)
  41361. */
  41362. incrementReferences(): void;
  41363. /**
  41364. * Change the size of the texture (not the size of the content)
  41365. * @param width defines the new width
  41366. * @param height defines the new height
  41367. * @param depth defines the new depth (1 by default)
  41368. */
  41369. updateSize(width: int, height: int, depth?: int): void;
  41370. /** @hidden */
  41371. _rebuild(): void;
  41372. /** @hidden */
  41373. _swapAndDie(target: InternalTexture): void;
  41374. /**
  41375. * Dispose the current allocated resources
  41376. */
  41377. dispose(): void;
  41378. }
  41379. }
  41380. declare module BABYLON {
  41381. /**
  41382. * Interface used to present a loading screen while loading a scene
  41383. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41384. */
  41385. export interface ILoadingScreen {
  41386. /**
  41387. * Function called to display the loading screen
  41388. */
  41389. displayLoadingUI: () => void;
  41390. /**
  41391. * Function called to hide the loading screen
  41392. */
  41393. hideLoadingUI: () => void;
  41394. /**
  41395. * Gets or sets the color to use for the background
  41396. */
  41397. loadingUIBackgroundColor: string;
  41398. /**
  41399. * Gets or sets the text to display while loading
  41400. */
  41401. loadingUIText: string;
  41402. }
  41403. /**
  41404. * Class used for the default loading screen
  41405. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41406. */
  41407. export class DefaultLoadingScreen implements ILoadingScreen {
  41408. private _renderingCanvas;
  41409. private _loadingText;
  41410. private _loadingDivBackgroundColor;
  41411. private _loadingDiv;
  41412. private _loadingTextDiv;
  41413. /** Gets or sets the logo url to use for the default loading screen */
  41414. static DefaultLogoUrl: string;
  41415. /** Gets or sets the spinner url to use for the default loading screen */
  41416. static DefaultSpinnerUrl: string;
  41417. /**
  41418. * Creates a new default loading screen
  41419. * @param _renderingCanvas defines the canvas used to render the scene
  41420. * @param _loadingText defines the default text to display
  41421. * @param _loadingDivBackgroundColor defines the default background color
  41422. */
  41423. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41424. /**
  41425. * Function called to display the loading screen
  41426. */
  41427. displayLoadingUI(): void;
  41428. /**
  41429. * Function called to hide the loading screen
  41430. */
  41431. hideLoadingUI(): void;
  41432. /**
  41433. * Gets or sets the text to display while loading
  41434. */
  41435. set loadingUIText(text: string);
  41436. get loadingUIText(): string;
  41437. /**
  41438. * Gets or sets the color to use for the background
  41439. */
  41440. get loadingUIBackgroundColor(): string;
  41441. set loadingUIBackgroundColor(color: string);
  41442. private _resizeLoadingUI;
  41443. }
  41444. }
  41445. declare module BABYLON {
  41446. /**
  41447. * Interface for any object that can request an animation frame
  41448. */
  41449. export interface ICustomAnimationFrameRequester {
  41450. /**
  41451. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41452. */
  41453. renderFunction?: Function;
  41454. /**
  41455. * Called to request the next frame to render to
  41456. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41457. */
  41458. requestAnimationFrame: Function;
  41459. /**
  41460. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41461. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41462. */
  41463. requestID?: number;
  41464. }
  41465. }
  41466. declare module BABYLON {
  41467. /**
  41468. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41469. */
  41470. export class PerformanceMonitor {
  41471. private _enabled;
  41472. private _rollingFrameTime;
  41473. private _lastFrameTimeMs;
  41474. /**
  41475. * constructor
  41476. * @param frameSampleSize The number of samples required to saturate the sliding window
  41477. */
  41478. constructor(frameSampleSize?: number);
  41479. /**
  41480. * Samples current frame
  41481. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41482. */
  41483. sampleFrame(timeMs?: number): void;
  41484. /**
  41485. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41486. */
  41487. get averageFrameTime(): number;
  41488. /**
  41489. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41490. */
  41491. get averageFrameTimeVariance(): number;
  41492. /**
  41493. * Returns the frame time of the most recent frame
  41494. */
  41495. get instantaneousFrameTime(): number;
  41496. /**
  41497. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41498. */
  41499. get averageFPS(): number;
  41500. /**
  41501. * Returns the average framerate in frames per second using the most recent frame time
  41502. */
  41503. get instantaneousFPS(): number;
  41504. /**
  41505. * Returns true if enough samples have been taken to completely fill the sliding window
  41506. */
  41507. get isSaturated(): boolean;
  41508. /**
  41509. * Enables contributions to the sliding window sample set
  41510. */
  41511. enable(): void;
  41512. /**
  41513. * Disables contributions to the sliding window sample set
  41514. * Samples will not be interpolated over the disabled period
  41515. */
  41516. disable(): void;
  41517. /**
  41518. * Returns true if sampling is enabled
  41519. */
  41520. get isEnabled(): boolean;
  41521. /**
  41522. * Resets performance monitor
  41523. */
  41524. reset(): void;
  41525. }
  41526. /**
  41527. * RollingAverage
  41528. *
  41529. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41530. */
  41531. export class RollingAverage {
  41532. /**
  41533. * Current average
  41534. */
  41535. average: number;
  41536. /**
  41537. * Current variance
  41538. */
  41539. variance: number;
  41540. protected _samples: Array<number>;
  41541. protected _sampleCount: number;
  41542. protected _pos: number;
  41543. protected _m2: number;
  41544. /**
  41545. * constructor
  41546. * @param length The number of samples required to saturate the sliding window
  41547. */
  41548. constructor(length: number);
  41549. /**
  41550. * Adds a sample to the sample set
  41551. * @param v The sample value
  41552. */
  41553. add(v: number): void;
  41554. /**
  41555. * Returns previously added values or null if outside of history or outside the sliding window domain
  41556. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41557. * @return Value previously recorded with add() or null if outside of range
  41558. */
  41559. history(i: number): number;
  41560. /**
  41561. * Returns true if enough samples have been taken to completely fill the sliding window
  41562. * @return true if sample-set saturated
  41563. */
  41564. isSaturated(): boolean;
  41565. /**
  41566. * Resets the rolling average (equivalent to 0 samples taken so far)
  41567. */
  41568. reset(): void;
  41569. /**
  41570. * Wraps a value around the sample range boundaries
  41571. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41572. * @return Wrapped position in sample range
  41573. */
  41574. protected _wrapPosition(i: number): number;
  41575. }
  41576. }
  41577. declare module BABYLON {
  41578. /**
  41579. * This class is used to track a performance counter which is number based.
  41580. * The user has access to many properties which give statistics of different nature.
  41581. *
  41582. * The implementer can track two kinds of Performance Counter: time and count.
  41583. * 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.
  41584. * 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.
  41585. */
  41586. export class PerfCounter {
  41587. /**
  41588. * Gets or sets a global boolean to turn on and off all the counters
  41589. */
  41590. static Enabled: boolean;
  41591. /**
  41592. * Returns the smallest value ever
  41593. */
  41594. get min(): number;
  41595. /**
  41596. * Returns the biggest value ever
  41597. */
  41598. get max(): number;
  41599. /**
  41600. * Returns the average value since the performance counter is running
  41601. */
  41602. get average(): number;
  41603. /**
  41604. * Returns the average value of the last second the counter was monitored
  41605. */
  41606. get lastSecAverage(): number;
  41607. /**
  41608. * Returns the current value
  41609. */
  41610. get current(): number;
  41611. /**
  41612. * Gets the accumulated total
  41613. */
  41614. get total(): number;
  41615. /**
  41616. * Gets the total value count
  41617. */
  41618. get count(): number;
  41619. /**
  41620. * Creates a new counter
  41621. */
  41622. constructor();
  41623. /**
  41624. * Call this method to start monitoring a new frame.
  41625. * 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.
  41626. */
  41627. fetchNewFrame(): void;
  41628. /**
  41629. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41630. * @param newCount the count value to add to the monitored count
  41631. * @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.
  41632. */
  41633. addCount(newCount: number, fetchResult: boolean): void;
  41634. /**
  41635. * Start monitoring this performance counter
  41636. */
  41637. beginMonitoring(): void;
  41638. /**
  41639. * Compute the time lapsed since the previous beginMonitoring() call.
  41640. * @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
  41641. */
  41642. endMonitoring(newFrame?: boolean): void;
  41643. private _fetchResult;
  41644. private _startMonitoringTime;
  41645. private _min;
  41646. private _max;
  41647. private _average;
  41648. private _current;
  41649. private _totalValueCount;
  41650. private _totalAccumulated;
  41651. private _lastSecAverage;
  41652. private _lastSecAccumulated;
  41653. private _lastSecTime;
  41654. private _lastSecValueCount;
  41655. }
  41656. }
  41657. declare module BABYLON {
  41658. interface ThinEngine {
  41659. /** @hidden */
  41660. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41661. }
  41662. }
  41663. declare module BABYLON {
  41664. /**
  41665. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41666. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41667. */
  41668. export class Analyser {
  41669. /**
  41670. * Gets or sets the smoothing
  41671. * @ignorenaming
  41672. */
  41673. SMOOTHING: number;
  41674. /**
  41675. * Gets or sets the FFT table size
  41676. * @ignorenaming
  41677. */
  41678. FFT_SIZE: number;
  41679. /**
  41680. * Gets or sets the bar graph amplitude
  41681. * @ignorenaming
  41682. */
  41683. BARGRAPHAMPLITUDE: number;
  41684. /**
  41685. * Gets or sets the position of the debug canvas
  41686. * @ignorenaming
  41687. */
  41688. DEBUGCANVASPOS: {
  41689. x: number;
  41690. y: number;
  41691. };
  41692. /**
  41693. * Gets or sets the debug canvas size
  41694. * @ignorenaming
  41695. */
  41696. DEBUGCANVASSIZE: {
  41697. width: number;
  41698. height: number;
  41699. };
  41700. private _byteFreqs;
  41701. private _byteTime;
  41702. private _floatFreqs;
  41703. private _webAudioAnalyser;
  41704. private _debugCanvas;
  41705. private _debugCanvasContext;
  41706. private _scene;
  41707. private _registerFunc;
  41708. private _audioEngine;
  41709. /**
  41710. * Creates a new analyser
  41711. * @param scene defines hosting scene
  41712. */
  41713. constructor(scene: Scene);
  41714. /**
  41715. * Get the number of data values you will have to play with for the visualization
  41716. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41717. * @returns a number
  41718. */
  41719. getFrequencyBinCount(): number;
  41720. /**
  41721. * Gets the current frequency data as a byte array
  41722. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41723. * @returns a Uint8Array
  41724. */
  41725. getByteFrequencyData(): Uint8Array;
  41726. /**
  41727. * Gets the current waveform as a byte array
  41728. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41729. * @returns a Uint8Array
  41730. */
  41731. getByteTimeDomainData(): Uint8Array;
  41732. /**
  41733. * Gets the current frequency data as a float array
  41734. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41735. * @returns a Float32Array
  41736. */
  41737. getFloatFrequencyData(): Float32Array;
  41738. /**
  41739. * Renders the debug canvas
  41740. */
  41741. drawDebugCanvas(): void;
  41742. /**
  41743. * Stops rendering the debug canvas and removes it
  41744. */
  41745. stopDebugCanvas(): void;
  41746. /**
  41747. * Connects two audio nodes
  41748. * @param inputAudioNode defines first node to connect
  41749. * @param outputAudioNode defines second node to connect
  41750. */
  41751. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41752. /**
  41753. * Releases all associated resources
  41754. */
  41755. dispose(): void;
  41756. }
  41757. }
  41758. declare module BABYLON {
  41759. /**
  41760. * This represents an audio engine and it is responsible
  41761. * to play, synchronize and analyse sounds throughout the application.
  41762. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41763. */
  41764. export interface IAudioEngine extends IDisposable {
  41765. /**
  41766. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41767. */
  41768. readonly canUseWebAudio: boolean;
  41769. /**
  41770. * Gets the current AudioContext if available.
  41771. */
  41772. readonly audioContext: Nullable<AudioContext>;
  41773. /**
  41774. * The master gain node defines the global audio volume of your audio engine.
  41775. */
  41776. readonly masterGain: GainNode;
  41777. /**
  41778. * Gets whether or not mp3 are supported by your browser.
  41779. */
  41780. readonly isMP3supported: boolean;
  41781. /**
  41782. * Gets whether or not ogg are supported by your browser.
  41783. */
  41784. readonly isOGGsupported: boolean;
  41785. /**
  41786. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41787. * @ignoreNaming
  41788. */
  41789. WarnedWebAudioUnsupported: boolean;
  41790. /**
  41791. * Defines if the audio engine relies on a custom unlocked button.
  41792. * In this case, the embedded button will not be displayed.
  41793. */
  41794. useCustomUnlockedButton: boolean;
  41795. /**
  41796. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41797. */
  41798. readonly unlocked: boolean;
  41799. /**
  41800. * Event raised when audio has been unlocked on the browser.
  41801. */
  41802. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41803. /**
  41804. * Event raised when audio has been locked on the browser.
  41805. */
  41806. onAudioLockedObservable: Observable<IAudioEngine>;
  41807. /**
  41808. * Flags the audio engine in Locked state.
  41809. * This happens due to new browser policies preventing audio to autoplay.
  41810. */
  41811. lock(): void;
  41812. /**
  41813. * Unlocks the audio engine once a user action has been done on the dom.
  41814. * This is helpful to resume play once browser policies have been satisfied.
  41815. */
  41816. unlock(): void;
  41817. /**
  41818. * Gets the global volume sets on the master gain.
  41819. * @returns the global volume if set or -1 otherwise
  41820. */
  41821. getGlobalVolume(): number;
  41822. /**
  41823. * Sets the global volume of your experience (sets on the master gain).
  41824. * @param newVolume Defines the new global volume of the application
  41825. */
  41826. setGlobalVolume(newVolume: number): void;
  41827. /**
  41828. * Connect the audio engine to an audio analyser allowing some amazing
  41829. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41830. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41831. * @param analyser The analyser to connect to the engine
  41832. */
  41833. connectToAnalyser(analyser: Analyser): void;
  41834. }
  41835. }
  41836. declare module BABYLON {
  41837. /**
  41838. * Defines the interface used by display changed events
  41839. */
  41840. export interface IDisplayChangedEventArgs {
  41841. /** Gets the vrDisplay object (if any) */
  41842. vrDisplay: Nullable<any>;
  41843. /** Gets a boolean indicating if webVR is supported */
  41844. vrSupported: boolean;
  41845. }
  41846. /**
  41847. * Defines the interface used by objects containing a viewport (like a camera)
  41848. */
  41849. interface IViewportOwnerLike {
  41850. /**
  41851. * Gets or sets the viewport
  41852. */
  41853. viewport: IViewportLike;
  41854. }
  41855. /**
  41856. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41857. */
  41858. export class Engine extends ThinEngine {
  41859. /** Defines that alpha blending is disabled */
  41860. static readonly ALPHA_DISABLE: number;
  41861. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41862. static readonly ALPHA_ADD: number;
  41863. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41864. static readonly ALPHA_COMBINE: number;
  41865. /** Defines that alpha blending to DEST - SRC * DEST */
  41866. static readonly ALPHA_SUBTRACT: number;
  41867. /** Defines that alpha blending to SRC * DEST */
  41868. static readonly ALPHA_MULTIPLY: number;
  41869. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41870. static readonly ALPHA_MAXIMIZED: number;
  41871. /** Defines that alpha blending to SRC + DEST */
  41872. static readonly ALPHA_ONEONE: number;
  41873. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41874. static readonly ALPHA_PREMULTIPLIED: number;
  41875. /**
  41876. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41877. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41878. */
  41879. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41880. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41881. static readonly ALPHA_INTERPOLATE: number;
  41882. /**
  41883. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41884. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41885. */
  41886. static readonly ALPHA_SCREENMODE: number;
  41887. /** Defines that the ressource is not delayed*/
  41888. static readonly DELAYLOADSTATE_NONE: number;
  41889. /** Defines that the ressource was successfully delay loaded */
  41890. static readonly DELAYLOADSTATE_LOADED: number;
  41891. /** Defines that the ressource is currently delay loading */
  41892. static readonly DELAYLOADSTATE_LOADING: number;
  41893. /** Defines that the ressource is delayed and has not started loading */
  41894. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41895. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41896. static readonly NEVER: number;
  41897. /** 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 */
  41898. static readonly ALWAYS: number;
  41899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41900. static readonly LESS: number;
  41901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41902. static readonly EQUAL: number;
  41903. /** 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 */
  41904. static readonly LEQUAL: number;
  41905. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41906. static readonly GREATER: number;
  41907. /** 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 */
  41908. static readonly GEQUAL: number;
  41909. /** 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 */
  41910. static readonly NOTEQUAL: number;
  41911. /** Passed to stencilOperation to specify that stencil value must be kept */
  41912. static readonly KEEP: number;
  41913. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41914. static readonly REPLACE: number;
  41915. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41916. static readonly INCR: number;
  41917. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41918. static readonly DECR: number;
  41919. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41920. static readonly INVERT: number;
  41921. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41922. static readonly INCR_WRAP: number;
  41923. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41924. static readonly DECR_WRAP: number;
  41925. /** Texture is not repeating outside of 0..1 UVs */
  41926. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41927. /** Texture is repeating outside of 0..1 UVs */
  41928. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41929. /** Texture is repeating and mirrored */
  41930. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41931. /** ALPHA */
  41932. static readonly TEXTUREFORMAT_ALPHA: number;
  41933. /** LUMINANCE */
  41934. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41935. /** LUMINANCE_ALPHA */
  41936. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41937. /** RGB */
  41938. static readonly TEXTUREFORMAT_RGB: number;
  41939. /** RGBA */
  41940. static readonly TEXTUREFORMAT_RGBA: number;
  41941. /** RED */
  41942. static readonly TEXTUREFORMAT_RED: number;
  41943. /** RED (2nd reference) */
  41944. static readonly TEXTUREFORMAT_R: number;
  41945. /** RG */
  41946. static readonly TEXTUREFORMAT_RG: number;
  41947. /** RED_INTEGER */
  41948. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41949. /** RED_INTEGER (2nd reference) */
  41950. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41951. /** RG_INTEGER */
  41952. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41953. /** RGB_INTEGER */
  41954. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41955. /** RGBA_INTEGER */
  41956. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41957. /** UNSIGNED_BYTE */
  41958. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41959. /** UNSIGNED_BYTE (2nd reference) */
  41960. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41961. /** FLOAT */
  41962. static readonly TEXTURETYPE_FLOAT: number;
  41963. /** HALF_FLOAT */
  41964. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41965. /** BYTE */
  41966. static readonly TEXTURETYPE_BYTE: number;
  41967. /** SHORT */
  41968. static readonly TEXTURETYPE_SHORT: number;
  41969. /** UNSIGNED_SHORT */
  41970. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41971. /** INT */
  41972. static readonly TEXTURETYPE_INT: number;
  41973. /** UNSIGNED_INT */
  41974. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41975. /** UNSIGNED_SHORT_4_4_4_4 */
  41976. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41977. /** UNSIGNED_SHORT_5_5_5_1 */
  41978. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41979. /** UNSIGNED_SHORT_5_6_5 */
  41980. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41981. /** UNSIGNED_INT_2_10_10_10_REV */
  41982. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41983. /** UNSIGNED_INT_24_8 */
  41984. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41985. /** UNSIGNED_INT_10F_11F_11F_REV */
  41986. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41987. /** UNSIGNED_INT_5_9_9_9_REV */
  41988. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41989. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41990. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41991. /** nearest is mag = nearest and min = nearest and mip = none */
  41992. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41993. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41994. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41995. /** Trilinear is mag = linear and min = linear and mip = linear */
  41996. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41997. /** nearest is mag = nearest and min = nearest and mip = linear */
  41998. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41999. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42000. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42001. /** Trilinear is mag = linear and min = linear and mip = linear */
  42002. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42003. /** mag = nearest and min = nearest and mip = nearest */
  42004. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42005. /** mag = nearest and min = linear and mip = nearest */
  42006. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42007. /** mag = nearest and min = linear and mip = linear */
  42008. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42009. /** mag = nearest and min = linear and mip = none */
  42010. static readonly TEXTURE_NEAREST_LINEAR: number;
  42011. /** mag = nearest and min = nearest and mip = none */
  42012. static readonly TEXTURE_NEAREST_NEAREST: number;
  42013. /** mag = linear and min = nearest and mip = nearest */
  42014. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42015. /** mag = linear and min = nearest and mip = linear */
  42016. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42017. /** mag = linear and min = linear and mip = none */
  42018. static readonly TEXTURE_LINEAR_LINEAR: number;
  42019. /** mag = linear and min = nearest and mip = none */
  42020. static readonly TEXTURE_LINEAR_NEAREST: number;
  42021. /** Explicit coordinates mode */
  42022. static readonly TEXTURE_EXPLICIT_MODE: number;
  42023. /** Spherical coordinates mode */
  42024. static readonly TEXTURE_SPHERICAL_MODE: number;
  42025. /** Planar coordinates mode */
  42026. static readonly TEXTURE_PLANAR_MODE: number;
  42027. /** Cubic coordinates mode */
  42028. static readonly TEXTURE_CUBIC_MODE: number;
  42029. /** Projection coordinates mode */
  42030. static readonly TEXTURE_PROJECTION_MODE: number;
  42031. /** Skybox coordinates mode */
  42032. static readonly TEXTURE_SKYBOX_MODE: number;
  42033. /** Inverse Cubic coordinates mode */
  42034. static readonly TEXTURE_INVCUBIC_MODE: number;
  42035. /** Equirectangular coordinates mode */
  42036. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42037. /** Equirectangular Fixed coordinates mode */
  42038. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42039. /** Equirectangular Fixed Mirrored coordinates mode */
  42040. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42041. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42042. static readonly SCALEMODE_FLOOR: number;
  42043. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42044. static readonly SCALEMODE_NEAREST: number;
  42045. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42046. static readonly SCALEMODE_CEILING: number;
  42047. /**
  42048. * Returns the current npm package of the sdk
  42049. */
  42050. static get NpmPackage(): string;
  42051. /**
  42052. * Returns the current version of the framework
  42053. */
  42054. static get Version(): string;
  42055. /** Gets the list of created engines */
  42056. static get Instances(): Engine[];
  42057. /**
  42058. * Gets the latest created engine
  42059. */
  42060. static get LastCreatedEngine(): Nullable<Engine>;
  42061. /**
  42062. * Gets the latest created scene
  42063. */
  42064. static get LastCreatedScene(): Nullable<Scene>;
  42065. /**
  42066. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42067. * @param flag defines which part of the materials must be marked as dirty
  42068. * @param predicate defines a predicate used to filter which materials should be affected
  42069. */
  42070. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42071. /**
  42072. * Method called to create the default loading screen.
  42073. * This can be overriden in your own app.
  42074. * @param canvas The rendering canvas element
  42075. * @returns The loading screen
  42076. */
  42077. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42078. /**
  42079. * Method called to create the default rescale post process on each engine.
  42080. */
  42081. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42082. /**
  42083. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42084. **/
  42085. enableOfflineSupport: boolean;
  42086. /**
  42087. * 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)
  42088. **/
  42089. disableManifestCheck: boolean;
  42090. /**
  42091. * Gets the list of created scenes
  42092. */
  42093. scenes: Scene[];
  42094. /**
  42095. * Event raised when a new scene is created
  42096. */
  42097. onNewSceneAddedObservable: Observable<Scene>;
  42098. /**
  42099. * Gets the list of created postprocesses
  42100. */
  42101. postProcesses: PostProcess[];
  42102. /**
  42103. * Gets a boolean indicating if the pointer is currently locked
  42104. */
  42105. isPointerLock: boolean;
  42106. /**
  42107. * Observable event triggered each time the rendering canvas is resized
  42108. */
  42109. onResizeObservable: Observable<Engine>;
  42110. /**
  42111. * Observable event triggered each time the canvas loses focus
  42112. */
  42113. onCanvasBlurObservable: Observable<Engine>;
  42114. /**
  42115. * Observable event triggered each time the canvas gains focus
  42116. */
  42117. onCanvasFocusObservable: Observable<Engine>;
  42118. /**
  42119. * Observable event triggered each time the canvas receives pointerout event
  42120. */
  42121. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42122. /**
  42123. * Observable raised when the engine begins a new frame
  42124. */
  42125. onBeginFrameObservable: Observable<Engine>;
  42126. /**
  42127. * If set, will be used to request the next animation frame for the render loop
  42128. */
  42129. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42130. /**
  42131. * Observable raised when the engine ends the current frame
  42132. */
  42133. onEndFrameObservable: Observable<Engine>;
  42134. /**
  42135. * Observable raised when the engine is about to compile a shader
  42136. */
  42137. onBeforeShaderCompilationObservable: Observable<Engine>;
  42138. /**
  42139. * Observable raised when the engine has jsut compiled a shader
  42140. */
  42141. onAfterShaderCompilationObservable: Observable<Engine>;
  42142. /**
  42143. * Gets the audio engine
  42144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42145. * @ignorenaming
  42146. */
  42147. static audioEngine: IAudioEngine;
  42148. /**
  42149. * Default AudioEngine factory responsible of creating the Audio Engine.
  42150. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42151. */
  42152. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42153. /**
  42154. * Default offline support factory responsible of creating a tool used to store data locally.
  42155. * By default, this will create a Database object if the workload has been embedded.
  42156. */
  42157. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42158. private _loadingScreen;
  42159. private _pointerLockRequested;
  42160. private _rescalePostProcess;
  42161. protected _deterministicLockstep: boolean;
  42162. protected _lockstepMaxSteps: number;
  42163. protected _timeStep: number;
  42164. protected get _supportsHardwareTextureRescaling(): boolean;
  42165. private _fps;
  42166. private _deltaTime;
  42167. /** @hidden */
  42168. _drawCalls: PerfCounter;
  42169. /** 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 */
  42170. canvasTabIndex: number;
  42171. /**
  42172. * Turn this value on if you want to pause FPS computation when in background
  42173. */
  42174. disablePerformanceMonitorInBackground: boolean;
  42175. private _performanceMonitor;
  42176. /**
  42177. * Gets the performance monitor attached to this engine
  42178. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42179. */
  42180. get performanceMonitor(): PerformanceMonitor;
  42181. private _onFocus;
  42182. private _onBlur;
  42183. private _onCanvasPointerOut;
  42184. private _onCanvasBlur;
  42185. private _onCanvasFocus;
  42186. private _onFullscreenChange;
  42187. private _onPointerLockChange;
  42188. /**
  42189. * Gets the HTML element used to attach event listeners
  42190. * @returns a HTML element
  42191. */
  42192. getInputElement(): Nullable<HTMLElement>;
  42193. /**
  42194. * Creates a new engine
  42195. * @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
  42196. * @param antialias defines enable antialiasing (default: false)
  42197. * @param options defines further options to be sent to the getContext() function
  42198. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42199. */
  42200. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42201. /**
  42202. * Shared initialization across engines types.
  42203. * @param canvas The canvas associated with this instance of the engine.
  42204. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42205. * @param audioEngine Defines if an audio engine should be created by default
  42206. */
  42207. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42208. /**
  42209. * Gets current aspect ratio
  42210. * @param viewportOwner defines the camera to use to get the aspect ratio
  42211. * @param useScreen defines if screen size must be used (or the current render target if any)
  42212. * @returns a number defining the aspect ratio
  42213. */
  42214. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42215. /**
  42216. * Gets current screen aspect ratio
  42217. * @returns a number defining the aspect ratio
  42218. */
  42219. getScreenAspectRatio(): number;
  42220. /**
  42221. * Gets the client rect of the HTML canvas attached with the current webGL context
  42222. * @returns a client rectanglee
  42223. */
  42224. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42225. /**
  42226. * Gets the client rect of the HTML element used for events
  42227. * @returns a client rectanglee
  42228. */
  42229. getInputElementClientRect(): Nullable<ClientRect>;
  42230. /**
  42231. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42232. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42233. * @returns true if engine is in deterministic lock step mode
  42234. */
  42235. isDeterministicLockStep(): boolean;
  42236. /**
  42237. * Gets the max steps when engine is running in deterministic lock step
  42238. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42239. * @returns the max steps
  42240. */
  42241. getLockstepMaxSteps(): number;
  42242. /**
  42243. * Returns the time in ms between steps when using deterministic lock step.
  42244. * @returns time step in (ms)
  42245. */
  42246. getTimeStep(): number;
  42247. /**
  42248. * Force the mipmap generation for the given render target texture
  42249. * @param texture defines the render target texture to use
  42250. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42251. */
  42252. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42253. /** States */
  42254. /**
  42255. * Set various states to the webGL context
  42256. * @param culling defines backface culling state
  42257. * @param zOffset defines the value to apply to zOffset (0 by default)
  42258. * @param force defines if states must be applied even if cache is up to date
  42259. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42260. */
  42261. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42262. /**
  42263. * Set the z offset to apply to current rendering
  42264. * @param value defines the offset to apply
  42265. */
  42266. setZOffset(value: number): void;
  42267. /**
  42268. * Gets the current value of the zOffset
  42269. * @returns the current zOffset state
  42270. */
  42271. getZOffset(): number;
  42272. /**
  42273. * Gets a boolean indicating if depth testing is enabled
  42274. * @returns the current state
  42275. */
  42276. getDepthBuffer(): boolean;
  42277. /**
  42278. * Enable or disable depth buffering
  42279. * @param enable defines the state to set
  42280. */
  42281. setDepthBuffer(enable: boolean): void;
  42282. /**
  42283. * Gets a boolean indicating if depth writing is enabled
  42284. * @returns the current depth writing state
  42285. */
  42286. getDepthWrite(): boolean;
  42287. /**
  42288. * Enable or disable depth writing
  42289. * @param enable defines the state to set
  42290. */
  42291. setDepthWrite(enable: boolean): void;
  42292. /**
  42293. * Gets a boolean indicating if stencil buffer is enabled
  42294. * @returns the current stencil buffer state
  42295. */
  42296. getStencilBuffer(): boolean;
  42297. /**
  42298. * Enable or disable the stencil buffer
  42299. * @param enable defines if the stencil buffer must be enabled or disabled
  42300. */
  42301. setStencilBuffer(enable: boolean): void;
  42302. /**
  42303. * Gets the current stencil mask
  42304. * @returns a number defining the new stencil mask to use
  42305. */
  42306. getStencilMask(): number;
  42307. /**
  42308. * Sets the current stencil mask
  42309. * @param mask defines the new stencil mask to use
  42310. */
  42311. setStencilMask(mask: number): void;
  42312. /**
  42313. * Gets the current stencil function
  42314. * @returns a number defining the stencil function to use
  42315. */
  42316. getStencilFunction(): number;
  42317. /**
  42318. * Gets the current stencil reference value
  42319. * @returns a number defining the stencil reference value to use
  42320. */
  42321. getStencilFunctionReference(): number;
  42322. /**
  42323. * Gets the current stencil mask
  42324. * @returns a number defining the stencil mask to use
  42325. */
  42326. getStencilFunctionMask(): number;
  42327. /**
  42328. * Sets the current stencil function
  42329. * @param stencilFunc defines the new stencil function to use
  42330. */
  42331. setStencilFunction(stencilFunc: number): void;
  42332. /**
  42333. * Sets the current stencil reference
  42334. * @param reference defines the new stencil reference to use
  42335. */
  42336. setStencilFunctionReference(reference: number): void;
  42337. /**
  42338. * Sets the current stencil mask
  42339. * @param mask defines the new stencil mask to use
  42340. */
  42341. setStencilFunctionMask(mask: number): void;
  42342. /**
  42343. * Gets the current stencil operation when stencil fails
  42344. * @returns a number defining stencil operation to use when stencil fails
  42345. */
  42346. getStencilOperationFail(): number;
  42347. /**
  42348. * Gets the current stencil operation when depth fails
  42349. * @returns a number defining stencil operation to use when depth fails
  42350. */
  42351. getStencilOperationDepthFail(): number;
  42352. /**
  42353. * Gets the current stencil operation when stencil passes
  42354. * @returns a number defining stencil operation to use when stencil passes
  42355. */
  42356. getStencilOperationPass(): number;
  42357. /**
  42358. * Sets the stencil operation to use when stencil fails
  42359. * @param operation defines the stencil operation to use when stencil fails
  42360. */
  42361. setStencilOperationFail(operation: number): void;
  42362. /**
  42363. * Sets the stencil operation to use when depth fails
  42364. * @param operation defines the stencil operation to use when depth fails
  42365. */
  42366. setStencilOperationDepthFail(operation: number): void;
  42367. /**
  42368. * Sets the stencil operation to use when stencil passes
  42369. * @param operation defines the stencil operation to use when stencil passes
  42370. */
  42371. setStencilOperationPass(operation: number): void;
  42372. /**
  42373. * Sets a boolean indicating if the dithering state is enabled or disabled
  42374. * @param value defines the dithering state
  42375. */
  42376. setDitheringState(value: boolean): void;
  42377. /**
  42378. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42379. * @param value defines the rasterizer state
  42380. */
  42381. setRasterizerState(value: boolean): void;
  42382. /**
  42383. * Gets the current depth function
  42384. * @returns a number defining the depth function
  42385. */
  42386. getDepthFunction(): Nullable<number>;
  42387. /**
  42388. * Sets the current depth function
  42389. * @param depthFunc defines the function to use
  42390. */
  42391. setDepthFunction(depthFunc: number): void;
  42392. /**
  42393. * Sets the current depth function to GREATER
  42394. */
  42395. setDepthFunctionToGreater(): void;
  42396. /**
  42397. * Sets the current depth function to GEQUAL
  42398. */
  42399. setDepthFunctionToGreaterOrEqual(): void;
  42400. /**
  42401. * Sets the current depth function to LESS
  42402. */
  42403. setDepthFunctionToLess(): void;
  42404. /**
  42405. * Sets the current depth function to LEQUAL
  42406. */
  42407. setDepthFunctionToLessOrEqual(): void;
  42408. private _cachedStencilBuffer;
  42409. private _cachedStencilFunction;
  42410. private _cachedStencilMask;
  42411. private _cachedStencilOperationPass;
  42412. private _cachedStencilOperationFail;
  42413. private _cachedStencilOperationDepthFail;
  42414. private _cachedStencilReference;
  42415. /**
  42416. * Caches the the state of the stencil buffer
  42417. */
  42418. cacheStencilState(): void;
  42419. /**
  42420. * Restores the state of the stencil buffer
  42421. */
  42422. restoreStencilState(): void;
  42423. /**
  42424. * Directly set the WebGL Viewport
  42425. * @param x defines the x coordinate of the viewport (in screen space)
  42426. * @param y defines the y coordinate of the viewport (in screen space)
  42427. * @param width defines the width of the viewport (in screen space)
  42428. * @param height defines the height of the viewport (in screen space)
  42429. * @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
  42430. */
  42431. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42432. /**
  42433. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42434. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42435. * @param y defines the y-coordinate of the corner of the clear rectangle
  42436. * @param width defines the width of the clear rectangle
  42437. * @param height defines the height of the clear rectangle
  42438. * @param clearColor defines the clear color
  42439. */
  42440. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42441. /**
  42442. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42443. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42444. * @param y defines the y-coordinate of the corner of the clear rectangle
  42445. * @param width defines the width of the clear rectangle
  42446. * @param height defines the height of the clear rectangle
  42447. */
  42448. enableScissor(x: number, y: number, width: number, height: number): void;
  42449. /**
  42450. * Disable previously set scissor test rectangle
  42451. */
  42452. disableScissor(): void;
  42453. protected _reportDrawCall(): void;
  42454. /**
  42455. * Initializes a webVR display and starts listening to display change events
  42456. * The onVRDisplayChangedObservable will be notified upon these changes
  42457. * @returns The onVRDisplayChangedObservable
  42458. */
  42459. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42460. /** @hidden */
  42461. _prepareVRComponent(): void;
  42462. /** @hidden */
  42463. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42464. /** @hidden */
  42465. _submitVRFrame(): void;
  42466. /**
  42467. * Call this function to leave webVR mode
  42468. * Will do nothing if webVR is not supported or if there is no webVR device
  42469. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42470. */
  42471. disableVR(): void;
  42472. /**
  42473. * Gets a boolean indicating that the system is in VR mode and is presenting
  42474. * @returns true if VR mode is engaged
  42475. */
  42476. isVRPresenting(): boolean;
  42477. /** @hidden */
  42478. _requestVRFrame(): void;
  42479. /** @hidden */
  42480. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42481. /**
  42482. * Gets the source code of the vertex shader associated with a specific webGL program
  42483. * @param program defines the program to use
  42484. * @returns a string containing the source code of the vertex shader associated with the program
  42485. */
  42486. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42487. /**
  42488. * Gets the source code of the fragment shader associated with a specific webGL program
  42489. * @param program defines the program to use
  42490. * @returns a string containing the source code of the fragment shader associated with the program
  42491. */
  42492. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42493. /**
  42494. * Sets a depth stencil texture from a render target to the according uniform.
  42495. * @param channel The texture channel
  42496. * @param uniform The uniform to set
  42497. * @param texture The render target texture containing the depth stencil texture to apply
  42498. * @param name The texture name
  42499. */
  42500. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42501. /**
  42502. * Sets a texture to the webGL context from a postprocess
  42503. * @param channel defines the channel to use
  42504. * @param postProcess defines the source postprocess
  42505. * @param name name of the channel
  42506. */
  42507. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42508. /**
  42509. * Binds the output of the passed in post process to the texture channel specified
  42510. * @param channel The channel the texture should be bound to
  42511. * @param postProcess The post process which's output should be bound
  42512. * @param name name of the channel
  42513. */
  42514. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42515. protected _rebuildBuffers(): void;
  42516. /** @hidden */
  42517. _renderFrame(): void;
  42518. _renderLoop(): void;
  42519. /** @hidden */
  42520. _renderViews(): boolean;
  42521. /**
  42522. * Toggle full screen mode
  42523. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42524. */
  42525. switchFullscreen(requestPointerLock: boolean): void;
  42526. /**
  42527. * Enters full screen mode
  42528. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42529. */
  42530. enterFullscreen(requestPointerLock: boolean): void;
  42531. /**
  42532. * Exits full screen mode
  42533. */
  42534. exitFullscreen(): void;
  42535. /**
  42536. * Enters Pointerlock mode
  42537. */
  42538. enterPointerlock(): void;
  42539. /**
  42540. * Exits Pointerlock mode
  42541. */
  42542. exitPointerlock(): void;
  42543. /**
  42544. * Begin a new frame
  42545. */
  42546. beginFrame(): void;
  42547. /**
  42548. * End the current frame
  42549. */
  42550. endFrame(): void;
  42551. /**
  42552. * Resize the view according to the canvas' size
  42553. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42554. */
  42555. resize(forceSetSize?: boolean): void;
  42556. /**
  42557. * Force a specific size of the canvas
  42558. * @param width defines the new canvas' width
  42559. * @param height defines the new canvas' height
  42560. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42561. * @returns true if the size was changed
  42562. */
  42563. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42564. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42565. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42566. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42567. _releaseTexture(texture: InternalTexture): void;
  42568. /**
  42569. * @hidden
  42570. * Rescales a texture
  42571. * @param source input texutre
  42572. * @param destination destination texture
  42573. * @param scene scene to use to render the resize
  42574. * @param internalFormat format to use when resizing
  42575. * @param onComplete callback to be called when resize has completed
  42576. */
  42577. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42578. /**
  42579. * Gets the current framerate
  42580. * @returns a number representing the framerate
  42581. */
  42582. getFps(): number;
  42583. /**
  42584. * Gets the time spent between current and previous frame
  42585. * @returns a number representing the delta time in ms
  42586. */
  42587. getDeltaTime(): number;
  42588. private _measureFps;
  42589. /** @hidden */
  42590. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42591. /**
  42592. * Updates the sample count of a render target texture
  42593. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42594. * @param texture defines the texture to update
  42595. * @param samples defines the sample count to set
  42596. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42597. */
  42598. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42599. /**
  42600. * Updates a depth texture Comparison Mode and Function.
  42601. * If the comparison Function is equal to 0, the mode will be set to none.
  42602. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42603. * @param texture The texture to set the comparison function for
  42604. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42605. */
  42606. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42607. /**
  42608. * Creates a webGL buffer to use with instanciation
  42609. * @param capacity defines the size of the buffer
  42610. * @returns the webGL buffer
  42611. */
  42612. createInstancesBuffer(capacity: number): DataBuffer;
  42613. /**
  42614. * Delete a webGL buffer used with instanciation
  42615. * @param buffer defines the webGL buffer to delete
  42616. */
  42617. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42618. private _clientWaitAsync;
  42619. /** @hidden */
  42620. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42621. dispose(): void;
  42622. private _disableTouchAction;
  42623. /**
  42624. * Display the loading screen
  42625. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42626. */
  42627. displayLoadingUI(): void;
  42628. /**
  42629. * Hide the loading screen
  42630. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42631. */
  42632. hideLoadingUI(): void;
  42633. /**
  42634. * Gets the current loading screen object
  42635. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42636. */
  42637. get loadingScreen(): ILoadingScreen;
  42638. /**
  42639. * Sets the current loading screen object
  42640. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42641. */
  42642. set loadingScreen(loadingScreen: ILoadingScreen);
  42643. /**
  42644. * Sets the current loading screen text
  42645. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42646. */
  42647. set loadingUIText(text: string);
  42648. /**
  42649. * Sets the current loading screen background color
  42650. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42651. */
  42652. set loadingUIBackgroundColor(color: string);
  42653. /** Pointerlock and fullscreen */
  42654. /**
  42655. * Ask the browser to promote the current element to pointerlock mode
  42656. * @param element defines the DOM element to promote
  42657. */
  42658. static _RequestPointerlock(element: HTMLElement): void;
  42659. /**
  42660. * Asks the browser to exit pointerlock mode
  42661. */
  42662. static _ExitPointerlock(): void;
  42663. /**
  42664. * Ask the browser to promote the current element to fullscreen rendering mode
  42665. * @param element defines the DOM element to promote
  42666. */
  42667. static _RequestFullscreen(element: HTMLElement): void;
  42668. /**
  42669. * Asks the browser to exit fullscreen mode
  42670. */
  42671. static _ExitFullscreen(): void;
  42672. }
  42673. }
  42674. declare module BABYLON {
  42675. /**
  42676. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42677. * during the life time of the application.
  42678. */
  42679. export class EngineStore {
  42680. /** Gets the list of created engines */
  42681. static Instances: Engine[];
  42682. /** @hidden */
  42683. static _LastCreatedScene: Nullable<Scene>;
  42684. /**
  42685. * Gets the latest created engine
  42686. */
  42687. static get LastCreatedEngine(): Nullable<Engine>;
  42688. /**
  42689. * Gets the latest created scene
  42690. */
  42691. static get LastCreatedScene(): Nullable<Scene>;
  42692. /**
  42693. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42694. * @ignorenaming
  42695. */
  42696. static UseFallbackTexture: boolean;
  42697. /**
  42698. * Texture content used if a texture cannot loaded
  42699. * @ignorenaming
  42700. */
  42701. static FallbackTexture: string;
  42702. }
  42703. }
  42704. declare module BABYLON {
  42705. /**
  42706. * Helper class that provides a small promise polyfill
  42707. */
  42708. export class PromisePolyfill {
  42709. /**
  42710. * Static function used to check if the polyfill is required
  42711. * If this is the case then the function will inject the polyfill to window.Promise
  42712. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42713. */
  42714. static Apply(force?: boolean): void;
  42715. }
  42716. }
  42717. declare module BABYLON {
  42718. /**
  42719. * Interface for screenshot methods with describe argument called `size` as object with options
  42720. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42721. */
  42722. export interface IScreenshotSize {
  42723. /**
  42724. * number in pixels for canvas height
  42725. */
  42726. height?: number;
  42727. /**
  42728. * multiplier allowing render at a higher or lower resolution
  42729. * If value is defined then height and width will be ignored and taken from camera
  42730. */
  42731. precision?: number;
  42732. /**
  42733. * number in pixels for canvas width
  42734. */
  42735. width?: number;
  42736. }
  42737. }
  42738. declare module BABYLON {
  42739. interface IColor4Like {
  42740. r: float;
  42741. g: float;
  42742. b: float;
  42743. a: float;
  42744. }
  42745. /**
  42746. * Class containing a set of static utilities functions
  42747. */
  42748. export class Tools {
  42749. /**
  42750. * Gets or sets the base URL to use to load assets
  42751. */
  42752. static get BaseUrl(): string;
  42753. static set BaseUrl(value: string);
  42754. /**
  42755. * Enable/Disable Custom HTTP Request Headers globally.
  42756. * default = false
  42757. * @see CustomRequestHeaders
  42758. */
  42759. static UseCustomRequestHeaders: boolean;
  42760. /**
  42761. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42762. * i.e. when loading files, where the server/service expects an Authorization header
  42763. */
  42764. static CustomRequestHeaders: {
  42765. [key: string]: string;
  42766. };
  42767. /**
  42768. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42769. */
  42770. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42771. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42772. /**
  42773. * Default behaviour for cors in the application.
  42774. * It can be a string if the expected behavior is identical in the entire app.
  42775. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42776. */
  42777. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42778. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42779. /**
  42780. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42781. * @ignorenaming
  42782. */
  42783. static get UseFallbackTexture(): boolean;
  42784. static set UseFallbackTexture(value: boolean);
  42785. /**
  42786. * Use this object to register external classes like custom textures or material
  42787. * to allow the laoders to instantiate them
  42788. */
  42789. static get RegisteredExternalClasses(): {
  42790. [key: string]: Object;
  42791. };
  42792. static set RegisteredExternalClasses(classes: {
  42793. [key: string]: Object;
  42794. });
  42795. /**
  42796. * Texture content used if a texture cannot loaded
  42797. * @ignorenaming
  42798. */
  42799. static get fallbackTexture(): string;
  42800. static set fallbackTexture(value: string);
  42801. /**
  42802. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42803. * @param u defines the coordinate on X axis
  42804. * @param v defines the coordinate on Y axis
  42805. * @param width defines the width of the source data
  42806. * @param height defines the height of the source data
  42807. * @param pixels defines the source byte array
  42808. * @param color defines the output color
  42809. */
  42810. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42811. /**
  42812. * Interpolates between a and b via alpha
  42813. * @param a The lower value (returned when alpha = 0)
  42814. * @param b The upper value (returned when alpha = 1)
  42815. * @param alpha The interpolation-factor
  42816. * @return The mixed value
  42817. */
  42818. static Mix(a: number, b: number, alpha: number): number;
  42819. /**
  42820. * Tries to instantiate a new object from a given class name
  42821. * @param className defines the class name to instantiate
  42822. * @returns the new object or null if the system was not able to do the instantiation
  42823. */
  42824. static Instantiate(className: string): any;
  42825. /**
  42826. * Provides a slice function that will work even on IE
  42827. * @param data defines the array to slice
  42828. * @param start defines the start of the data (optional)
  42829. * @param end defines the end of the data (optional)
  42830. * @returns the new sliced array
  42831. */
  42832. static Slice<T>(data: T, start?: number, end?: number): T;
  42833. /**
  42834. * Provides a slice function that will work even on IE
  42835. * The difference between this and Slice is that this will force-convert to array
  42836. * @param data defines the array to slice
  42837. * @param start defines the start of the data (optional)
  42838. * @param end defines the end of the data (optional)
  42839. * @returns the new sliced array
  42840. */
  42841. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42842. /**
  42843. * Polyfill for setImmediate
  42844. * @param action defines the action to execute after the current execution block
  42845. */
  42846. static SetImmediate(action: () => void): void;
  42847. /**
  42848. * Function indicating if a number is an exponent of 2
  42849. * @param value defines the value to test
  42850. * @returns true if the value is an exponent of 2
  42851. */
  42852. static IsExponentOfTwo(value: number): boolean;
  42853. private static _tmpFloatArray;
  42854. /**
  42855. * Returns the nearest 32-bit single precision float representation of a Number
  42856. * @param value A Number. If the parameter is of a different type, it will get converted
  42857. * to a number or to NaN if it cannot be converted
  42858. * @returns number
  42859. */
  42860. static FloatRound(value: number): number;
  42861. /**
  42862. * Extracts the filename from a path
  42863. * @param path defines the path to use
  42864. * @returns the filename
  42865. */
  42866. static GetFilename(path: string): string;
  42867. /**
  42868. * Extracts the "folder" part of a path (everything before the filename).
  42869. * @param uri The URI to extract the info from
  42870. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42871. * @returns The "folder" part of the path
  42872. */
  42873. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42874. /**
  42875. * Extracts text content from a DOM element hierarchy
  42876. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42877. */
  42878. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42879. /**
  42880. * Convert an angle in radians to degrees
  42881. * @param angle defines the angle to convert
  42882. * @returns the angle in degrees
  42883. */
  42884. static ToDegrees(angle: number): number;
  42885. /**
  42886. * Convert an angle in degrees to radians
  42887. * @param angle defines the angle to convert
  42888. * @returns the angle in radians
  42889. */
  42890. static ToRadians(angle: number): number;
  42891. /**
  42892. * Returns an array if obj is not an array
  42893. * @param obj defines the object to evaluate as an array
  42894. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42895. * @returns either obj directly if obj is an array or a new array containing obj
  42896. */
  42897. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42898. /**
  42899. * Gets the pointer prefix to use
  42900. * @param engine defines the engine we are finding the prefix for
  42901. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42902. */
  42903. static GetPointerPrefix(engine: Engine): string;
  42904. /**
  42905. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42906. * @param url define the url we are trying
  42907. * @param element define the dom element where to configure the cors policy
  42908. */
  42909. static SetCorsBehavior(url: string | string[], element: {
  42910. crossOrigin: string | null;
  42911. }): void;
  42912. /**
  42913. * Removes unwanted characters from an url
  42914. * @param url defines the url to clean
  42915. * @returns the cleaned url
  42916. */
  42917. static CleanUrl(url: string): string;
  42918. /**
  42919. * Gets or sets a function used to pre-process url before using them to load assets
  42920. */
  42921. static get PreprocessUrl(): (url: string) => string;
  42922. static set PreprocessUrl(processor: (url: string) => string);
  42923. /**
  42924. * Loads an image as an HTMLImageElement.
  42925. * @param input url string, ArrayBuffer, or Blob to load
  42926. * @param onLoad callback called when the image successfully loads
  42927. * @param onError callback called when the image fails to load
  42928. * @param offlineProvider offline provider for caching
  42929. * @param mimeType optional mime type
  42930. * @returns the HTMLImageElement of the loaded image
  42931. */
  42932. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42933. /**
  42934. * Loads a file from a url
  42935. * @param url url string, ArrayBuffer, or Blob to load
  42936. * @param onSuccess callback called when the file successfully loads
  42937. * @param onProgress callback called while file is loading (if the server supports this mode)
  42938. * @param offlineProvider defines the offline provider for caching
  42939. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42940. * @param onError callback called when the file fails to load
  42941. * @returns a file request object
  42942. */
  42943. 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;
  42944. /**
  42945. * Loads a file from a url
  42946. * @param url the file url to load
  42947. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42948. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42949. */
  42950. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42951. /**
  42952. * Load a script (identified by an url). When the url returns, the
  42953. * content of this file is added into a new script element, attached to the DOM (body element)
  42954. * @param scriptUrl defines the url of the script to laod
  42955. * @param onSuccess defines the callback called when the script is loaded
  42956. * @param onError defines the callback to call if an error occurs
  42957. * @param scriptId defines the id of the script element
  42958. */
  42959. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42960. /**
  42961. * Load an asynchronous script (identified by an url). When the url returns, the
  42962. * content of this file is added into a new script element, attached to the DOM (body element)
  42963. * @param scriptUrl defines the url of the script to laod
  42964. * @param scriptId defines the id of the script element
  42965. * @returns a promise request object
  42966. */
  42967. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42968. /**
  42969. * Loads a file from a blob
  42970. * @param fileToLoad defines the blob to use
  42971. * @param callback defines the callback to call when data is loaded
  42972. * @param progressCallback defines the callback to call during loading process
  42973. * @returns a file request object
  42974. */
  42975. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42976. /**
  42977. * Reads a file from a File object
  42978. * @param file defines the file to load
  42979. * @param onSuccess defines the callback to call when data is loaded
  42980. * @param onProgress defines the callback to call during loading process
  42981. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42982. * @param onError defines the callback to call when an error occurs
  42983. * @returns a file request object
  42984. */
  42985. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42986. /**
  42987. * Creates a data url from a given string content
  42988. * @param content defines the content to convert
  42989. * @returns the new data url link
  42990. */
  42991. static FileAsURL(content: string): string;
  42992. /**
  42993. * Format the given number to a specific decimal format
  42994. * @param value defines the number to format
  42995. * @param decimals defines the number of decimals to use
  42996. * @returns the formatted string
  42997. */
  42998. static Format(value: number, decimals?: number): string;
  42999. /**
  43000. * Tries to copy an object by duplicating every property
  43001. * @param source defines the source object
  43002. * @param destination defines the target object
  43003. * @param doNotCopyList defines a list of properties to avoid
  43004. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43005. */
  43006. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43007. /**
  43008. * Gets a boolean indicating if the given object has no own property
  43009. * @param obj defines the object to test
  43010. * @returns true if object has no own property
  43011. */
  43012. static IsEmpty(obj: any): boolean;
  43013. /**
  43014. * Function used to register events at window level
  43015. * @param windowElement defines the Window object to use
  43016. * @param events defines the events to register
  43017. */
  43018. static RegisterTopRootEvents(windowElement: Window, events: {
  43019. name: string;
  43020. handler: Nullable<(e: FocusEvent) => any>;
  43021. }[]): void;
  43022. /**
  43023. * Function used to unregister events from window level
  43024. * @param windowElement defines the Window object to use
  43025. * @param events defines the events to unregister
  43026. */
  43027. static UnregisterTopRootEvents(windowElement: Window, events: {
  43028. name: string;
  43029. handler: Nullable<(e: FocusEvent) => any>;
  43030. }[]): void;
  43031. /**
  43032. * @ignore
  43033. */
  43034. static _ScreenshotCanvas: HTMLCanvasElement;
  43035. /**
  43036. * Dumps the current bound framebuffer
  43037. * @param width defines the rendering width
  43038. * @param height defines the rendering height
  43039. * @param engine defines the hosting engine
  43040. * @param successCallback defines the callback triggered once the data are available
  43041. * @param mimeType defines the mime type of the result
  43042. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43043. * @return a void promise
  43044. */
  43045. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43046. /**
  43047. * Dumps an array buffer
  43048. * @param width defines the rendering width
  43049. * @param height defines the rendering height
  43050. * @param data the data array
  43051. * @param successCallback defines the callback triggered once the data are available
  43052. * @param mimeType defines the mime type of the result
  43053. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43054. * @param invertY true to invert the picture in the Y dimension
  43055. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43056. */
  43057. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43058. /**
  43059. * Dumps an array buffer
  43060. * @param width defines the rendering width
  43061. * @param height defines the rendering height
  43062. * @param data the data array
  43063. * @param successCallback defines the callback triggered once the data are available
  43064. * @param mimeType defines the mime type of the result
  43065. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43066. * @param invertY true to invert the picture in the Y dimension
  43067. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43068. * @return a promise that resolve to the final data
  43069. */
  43070. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43071. /**
  43072. * Converts the canvas data to blob.
  43073. * This acts as a polyfill for browsers not supporting the to blob function.
  43074. * @param canvas Defines the canvas to extract the data from
  43075. * @param successCallback Defines the callback triggered once the data are available
  43076. * @param mimeType Defines the mime type of the result
  43077. */
  43078. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43079. /**
  43080. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43081. * @param successCallback defines the callback triggered once the data are available
  43082. * @param mimeType defines the mime type of the result
  43083. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43084. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43085. */
  43086. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43087. /**
  43088. * Downloads a blob in the browser
  43089. * @param blob defines the blob to download
  43090. * @param fileName defines the name of the downloaded file
  43091. */
  43092. static Download(blob: Blob, fileName: string): void;
  43093. /**
  43094. * Will return the right value of the noPreventDefault variable
  43095. * Needed to keep backwards compatibility to the old API.
  43096. *
  43097. * @param args arguments passed to the attachControl function
  43098. * @returns the correct value for noPreventDefault
  43099. */
  43100. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43101. /**
  43102. * Captures a screenshot of the current rendering
  43103. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43104. * @param engine defines the rendering engine
  43105. * @param camera defines the source camera
  43106. * @param size This parameter can be set to a single number or to an object with the
  43107. * following (optional) properties: precision, width, height. If a single number is passed,
  43108. * it will be used for both width and height. If an object is passed, the screenshot size
  43109. * will be derived from the parameters. The precision property is a multiplier allowing
  43110. * rendering at a higher or lower resolution
  43111. * @param successCallback defines the callback receives a single parameter which contains the
  43112. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43113. * src parameter of an <img> to display it
  43114. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43115. * Check your browser for supported MIME types
  43116. */
  43117. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43118. /**
  43119. * Captures a screenshot of the current rendering
  43120. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43121. * @param engine defines the rendering engine
  43122. * @param camera defines the source camera
  43123. * @param size This parameter can be set to a single number or to an object with the
  43124. * following (optional) properties: precision, width, height. If a single number is passed,
  43125. * it will be used for both width and height. If an object is passed, the screenshot size
  43126. * will be derived from the parameters. The precision property is a multiplier allowing
  43127. * rendering at a higher or lower resolution
  43128. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43129. * Check your browser for supported MIME types
  43130. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43131. * to the src parameter of an <img> to display it
  43132. */
  43133. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43134. /**
  43135. * Generates an image screenshot from the specified camera.
  43136. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43137. * @param engine The engine to use for rendering
  43138. * @param camera The camera to use for rendering
  43139. * @param size This parameter can be set to a single number or to an object with the
  43140. * following (optional) properties: precision, width, height. If a single number is passed,
  43141. * it will be used for both width and height. If an object is passed, the screenshot size
  43142. * will be derived from the parameters. The precision property is a multiplier allowing
  43143. * rendering at a higher or lower resolution
  43144. * @param successCallback The callback receives a single parameter which contains the
  43145. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43146. * src parameter of an <img> to display it
  43147. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43148. * Check your browser for supported MIME types
  43149. * @param samples Texture samples (default: 1)
  43150. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43151. * @param fileName A name for for the downloaded file.
  43152. */
  43153. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43154. /**
  43155. * Generates an image screenshot from the specified camera.
  43156. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43157. * @param engine The engine to use for rendering
  43158. * @param camera The camera to use for rendering
  43159. * @param size This parameter can be set to a single number or to an object with the
  43160. * following (optional) properties: precision, width, height. If a single number is passed,
  43161. * it will be used for both width and height. If an object is passed, the screenshot size
  43162. * will be derived from the parameters. The precision property is a multiplier allowing
  43163. * rendering at a higher or lower resolution
  43164. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43165. * Check your browser for supported MIME types
  43166. * @param samples Texture samples (default: 1)
  43167. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43168. * @param fileName A name for for the downloaded file.
  43169. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43170. * to the src parameter of an <img> to display it
  43171. */
  43172. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43173. /**
  43174. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43175. * Be aware Math.random() could cause collisions, but:
  43176. * "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"
  43177. * @returns a pseudo random id
  43178. */
  43179. static RandomId(): string;
  43180. /**
  43181. * Test if the given uri is a base64 string
  43182. * @param uri The uri to test
  43183. * @return True if the uri is a base64 string or false otherwise
  43184. */
  43185. static IsBase64(uri: string): boolean;
  43186. /**
  43187. * Decode the given base64 uri.
  43188. * @param uri The uri to decode
  43189. * @return The decoded base64 data.
  43190. */
  43191. static DecodeBase64(uri: string): ArrayBuffer;
  43192. /**
  43193. * Gets the absolute url.
  43194. * @param url the input url
  43195. * @return the absolute url
  43196. */
  43197. static GetAbsoluteUrl(url: string): string;
  43198. /**
  43199. * No log
  43200. */
  43201. static readonly NoneLogLevel: number;
  43202. /**
  43203. * Only message logs
  43204. */
  43205. static readonly MessageLogLevel: number;
  43206. /**
  43207. * Only warning logs
  43208. */
  43209. static readonly WarningLogLevel: number;
  43210. /**
  43211. * Only error logs
  43212. */
  43213. static readonly ErrorLogLevel: number;
  43214. /**
  43215. * All logs
  43216. */
  43217. static readonly AllLogLevel: number;
  43218. /**
  43219. * Gets a value indicating the number of loading errors
  43220. * @ignorenaming
  43221. */
  43222. static get errorsCount(): number;
  43223. /**
  43224. * Callback called when a new log is added
  43225. */
  43226. static OnNewCacheEntry: (entry: string) => void;
  43227. /**
  43228. * Log a message to the console
  43229. * @param message defines the message to log
  43230. */
  43231. static Log(message: string): void;
  43232. /**
  43233. * Write a warning message to the console
  43234. * @param message defines the message to log
  43235. */
  43236. static Warn(message: string): void;
  43237. /**
  43238. * Write an error message to the console
  43239. * @param message defines the message to log
  43240. */
  43241. static Error(message: string): void;
  43242. /**
  43243. * Gets current log cache (list of logs)
  43244. */
  43245. static get LogCache(): string;
  43246. /**
  43247. * Clears the log cache
  43248. */
  43249. static ClearLogCache(): void;
  43250. /**
  43251. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43252. */
  43253. static set LogLevels(level: number);
  43254. /**
  43255. * Checks if the window object exists
  43256. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43257. */
  43258. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43259. /**
  43260. * No performance log
  43261. */
  43262. static readonly PerformanceNoneLogLevel: number;
  43263. /**
  43264. * Use user marks to log performance
  43265. */
  43266. static readonly PerformanceUserMarkLogLevel: number;
  43267. /**
  43268. * Log performance to the console
  43269. */
  43270. static readonly PerformanceConsoleLogLevel: number;
  43271. private static _performance;
  43272. /**
  43273. * Sets the current performance log level
  43274. */
  43275. static set PerformanceLogLevel(level: number);
  43276. private static _StartPerformanceCounterDisabled;
  43277. private static _EndPerformanceCounterDisabled;
  43278. private static _StartUserMark;
  43279. private static _EndUserMark;
  43280. private static _StartPerformanceConsole;
  43281. private static _EndPerformanceConsole;
  43282. /**
  43283. * Starts a performance counter
  43284. */
  43285. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43286. /**
  43287. * Ends a specific performance coutner
  43288. */
  43289. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43290. /**
  43291. * Gets either window.performance.now() if supported or Date.now() else
  43292. */
  43293. static get Now(): number;
  43294. /**
  43295. * This method will return the name of the class used to create the instance of the given object.
  43296. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43297. * @param object the object to get the class name from
  43298. * @param isType defines if the object is actually a type
  43299. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43300. */
  43301. static GetClassName(object: any, isType?: boolean): string;
  43302. /**
  43303. * Gets the first element of an array satisfying a given predicate
  43304. * @param array defines the array to browse
  43305. * @param predicate defines the predicate to use
  43306. * @returns null if not found or the element
  43307. */
  43308. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43309. /**
  43310. * This method will return the name of the full name of the class, including its owning module (if any).
  43311. * 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).
  43312. * @param object the object to get the class name from
  43313. * @param isType defines if the object is actually a type
  43314. * @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.
  43315. * @ignorenaming
  43316. */
  43317. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43318. /**
  43319. * Returns a promise that resolves after the given amount of time.
  43320. * @param delay Number of milliseconds to delay
  43321. * @returns Promise that resolves after the given amount of time
  43322. */
  43323. static DelayAsync(delay: number): Promise<void>;
  43324. /**
  43325. * Utility function to detect if the current user agent is Safari
  43326. * @returns whether or not the current user agent is safari
  43327. */
  43328. static IsSafari(): boolean;
  43329. }
  43330. /**
  43331. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43332. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43333. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43334. * @param name The name of the class, case should be preserved
  43335. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43336. */
  43337. export function className(name: string, module?: string): (target: Object) => void;
  43338. /**
  43339. * An implementation of a loop for asynchronous functions.
  43340. */
  43341. export class AsyncLoop {
  43342. /**
  43343. * Defines the number of iterations for the loop
  43344. */
  43345. iterations: number;
  43346. /**
  43347. * Defines the current index of the loop.
  43348. */
  43349. index: number;
  43350. private _done;
  43351. private _fn;
  43352. private _successCallback;
  43353. /**
  43354. * Constructor.
  43355. * @param iterations the number of iterations.
  43356. * @param func the function to run each iteration
  43357. * @param successCallback the callback that will be called upon succesful execution
  43358. * @param offset starting offset.
  43359. */
  43360. constructor(
  43361. /**
  43362. * Defines the number of iterations for the loop
  43363. */
  43364. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43365. /**
  43366. * Execute the next iteration. Must be called after the last iteration was finished.
  43367. */
  43368. executeNext(): void;
  43369. /**
  43370. * Break the loop and run the success callback.
  43371. */
  43372. breakLoop(): void;
  43373. /**
  43374. * Create and run an async loop.
  43375. * @param iterations the number of iterations.
  43376. * @param fn the function to run each iteration
  43377. * @param successCallback the callback that will be called upon succesful execution
  43378. * @param offset starting offset.
  43379. * @returns the created async loop object
  43380. */
  43381. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43382. /**
  43383. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43384. * @param iterations total number of iterations
  43385. * @param syncedIterations number of synchronous iterations in each async iteration.
  43386. * @param fn the function to call each iteration.
  43387. * @param callback a success call back that will be called when iterating stops.
  43388. * @param breakFunction a break condition (optional)
  43389. * @param timeout timeout settings for the setTimeout function. default - 0.
  43390. * @returns the created async loop object
  43391. */
  43392. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43393. }
  43394. }
  43395. declare module BABYLON {
  43396. /**
  43397. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43398. * The underlying implementation relies on an associative array to ensure the best performances.
  43399. * The value can be anything including 'null' but except 'undefined'
  43400. */
  43401. export class StringDictionary<T> {
  43402. /**
  43403. * This will clear this dictionary and copy the content from the 'source' one.
  43404. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43405. * @param source the dictionary to take the content from and copy to this dictionary
  43406. */
  43407. copyFrom(source: StringDictionary<T>): void;
  43408. /**
  43409. * Get a value based from its key
  43410. * @param key the given key to get the matching value from
  43411. * @return the value if found, otherwise undefined is returned
  43412. */
  43413. get(key: string): T | undefined;
  43414. /**
  43415. * Get a value from its key or add it if it doesn't exist.
  43416. * This method will ensure you that a given key/data will be present in the dictionary.
  43417. * @param key the given key to get the matching value from
  43418. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43419. * The factory will only be invoked if there's no data for the given key.
  43420. * @return the value corresponding to the key.
  43421. */
  43422. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43423. /**
  43424. * Get a value from its key if present in the dictionary otherwise add it
  43425. * @param key the key to get the value from
  43426. * @param val if there's no such key/value pair in the dictionary add it with this value
  43427. * @return the value corresponding to the key
  43428. */
  43429. getOrAdd(key: string, val: T): T;
  43430. /**
  43431. * Check if there's a given key in the dictionary
  43432. * @param key the key to check for
  43433. * @return true if the key is present, false otherwise
  43434. */
  43435. contains(key: string): boolean;
  43436. /**
  43437. * Add a new key and its corresponding value
  43438. * @param key the key to add
  43439. * @param value the value corresponding to the key
  43440. * @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
  43441. */
  43442. add(key: string, value: T): boolean;
  43443. /**
  43444. * Update a specific value associated to a key
  43445. * @param key defines the key to use
  43446. * @param value defines the value to store
  43447. * @returns true if the value was updated (or false if the key was not found)
  43448. */
  43449. set(key: string, value: T): boolean;
  43450. /**
  43451. * Get the element of the given key and remove it from the dictionary
  43452. * @param key defines the key to search
  43453. * @returns the value associated with the key or null if not found
  43454. */
  43455. getAndRemove(key: string): Nullable<T>;
  43456. /**
  43457. * Remove a key/value from the dictionary.
  43458. * @param key the key to remove
  43459. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43460. */
  43461. remove(key: string): boolean;
  43462. /**
  43463. * Clear the whole content of the dictionary
  43464. */
  43465. clear(): void;
  43466. /**
  43467. * Gets the current count
  43468. */
  43469. get count(): number;
  43470. /**
  43471. * Execute a callback on each key/val of the dictionary.
  43472. * Note that you can remove any element in this dictionary in the callback implementation
  43473. * @param callback the callback to execute on a given key/value pair
  43474. */
  43475. forEach(callback: (key: string, val: T) => void): void;
  43476. /**
  43477. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43478. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43479. * Note that you can remove any element in this dictionary in the callback implementation
  43480. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43481. * @returns the first item
  43482. */
  43483. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43484. private _count;
  43485. private _data;
  43486. }
  43487. }
  43488. declare module BABYLON {
  43489. /** @hidden */
  43490. export interface ICollisionCoordinator {
  43491. createCollider(): Collider;
  43492. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43493. init(scene: Scene): void;
  43494. }
  43495. /** @hidden */
  43496. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43497. private _scene;
  43498. private _scaledPosition;
  43499. private _scaledVelocity;
  43500. private _finalPosition;
  43501. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43502. createCollider(): Collider;
  43503. init(scene: Scene): void;
  43504. private _collideWithWorld;
  43505. }
  43506. }
  43507. declare module BABYLON {
  43508. /**
  43509. * Class used to manage all inputs for the scene.
  43510. */
  43511. export class InputManager {
  43512. /** The distance in pixel that you have to move to prevent some events */
  43513. static DragMovementThreshold: number;
  43514. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43515. static LongPressDelay: number;
  43516. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43517. static DoubleClickDelay: number;
  43518. /** If you need to check double click without raising a single click at first click, enable this flag */
  43519. static ExclusiveDoubleClickMode: boolean;
  43520. /** 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. */
  43521. private _alreadyAttached;
  43522. private _alreadyAttachedTo;
  43523. private _wheelEventName;
  43524. private _onPointerMove;
  43525. private _onPointerDown;
  43526. private _onPointerUp;
  43527. private _initClickEvent;
  43528. private _initActionManager;
  43529. private _delayedSimpleClick;
  43530. private _delayedSimpleClickTimeout;
  43531. private _previousDelayedSimpleClickTimeout;
  43532. private _meshPickProceed;
  43533. private _previousButtonPressed;
  43534. private _currentPickResult;
  43535. private _previousPickResult;
  43536. private _totalPointersPressed;
  43537. private _doubleClickOccured;
  43538. private _pointerOverMesh;
  43539. private _pickedDownMesh;
  43540. private _pickedUpMesh;
  43541. private _pointerX;
  43542. private _pointerY;
  43543. private _unTranslatedPointerX;
  43544. private _unTranslatedPointerY;
  43545. private _startingPointerPosition;
  43546. private _previousStartingPointerPosition;
  43547. private _startingPointerTime;
  43548. private _previousStartingPointerTime;
  43549. private _pointerCaptures;
  43550. private _meshUnderPointerId;
  43551. private _onKeyDown;
  43552. private _onKeyUp;
  43553. private _keyboardIsAttached;
  43554. private _onCanvasFocusObserver;
  43555. private _onCanvasBlurObserver;
  43556. private _scene;
  43557. /**
  43558. * Creates a new InputManager
  43559. * @param scene defines the hosting scene
  43560. */
  43561. constructor(scene: Scene);
  43562. /**
  43563. * Gets the mesh that is currently under the pointer
  43564. */
  43565. get meshUnderPointer(): Nullable<AbstractMesh>;
  43566. /**
  43567. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43568. * @param pointerId the pointer id to use
  43569. * @returns The mesh under this pointer id or null if not found
  43570. */
  43571. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43572. /**
  43573. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43574. */
  43575. get unTranslatedPointer(): Vector2;
  43576. /**
  43577. * Gets or sets the current on-screen X position of the pointer
  43578. */
  43579. get pointerX(): number;
  43580. set pointerX(value: number);
  43581. /**
  43582. * Gets or sets the current on-screen Y position of the pointer
  43583. */
  43584. get pointerY(): number;
  43585. set pointerY(value: number);
  43586. private _updatePointerPosition;
  43587. private _processPointerMove;
  43588. private _setRayOnPointerInfo;
  43589. private _checkPrePointerObservable;
  43590. /**
  43591. * Use this method to simulate a pointer move on a mesh
  43592. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43593. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43594. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43595. */
  43596. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43597. /**
  43598. * Use this method to simulate a pointer down on a mesh
  43599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43602. */
  43603. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43604. private _processPointerDown;
  43605. /** @hidden */
  43606. _isPointerSwiping(): boolean;
  43607. /**
  43608. * Use this method to simulate a pointer up on a mesh
  43609. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43610. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43611. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43612. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43613. */
  43614. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43615. private _processPointerUp;
  43616. /**
  43617. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43618. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43619. * @returns true if the pointer was captured
  43620. */
  43621. isPointerCaptured(pointerId?: number): boolean;
  43622. /**
  43623. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43624. * @param attachUp defines if you want to attach events to pointerup
  43625. * @param attachDown defines if you want to attach events to pointerdown
  43626. * @param attachMove defines if you want to attach events to pointermove
  43627. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43628. */
  43629. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43630. /**
  43631. * Detaches all event handlers
  43632. */
  43633. detachControl(): void;
  43634. /**
  43635. * Force the value of meshUnderPointer
  43636. * @param mesh defines the mesh to use
  43637. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43638. */
  43639. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43640. /**
  43641. * Gets the mesh under the pointer
  43642. * @returns a Mesh or null if no mesh is under the pointer
  43643. */
  43644. getPointerOverMesh(): Nullable<AbstractMesh>;
  43645. }
  43646. }
  43647. declare module BABYLON {
  43648. /**
  43649. * This class defines the direct association between an animation and a target
  43650. */
  43651. export class TargetedAnimation {
  43652. /**
  43653. * Animation to perform
  43654. */
  43655. animation: Animation;
  43656. /**
  43657. * Target to animate
  43658. */
  43659. target: any;
  43660. /**
  43661. * Returns the string "TargetedAnimation"
  43662. * @returns "TargetedAnimation"
  43663. */
  43664. getClassName(): string;
  43665. /**
  43666. * Serialize the object
  43667. * @returns the JSON object representing the current entity
  43668. */
  43669. serialize(): any;
  43670. }
  43671. /**
  43672. * Use this class to create coordinated animations on multiple targets
  43673. */
  43674. export class AnimationGroup implements IDisposable {
  43675. /** The name of the animation group */
  43676. name: string;
  43677. private _scene;
  43678. private _targetedAnimations;
  43679. private _animatables;
  43680. private _from;
  43681. private _to;
  43682. private _isStarted;
  43683. private _isPaused;
  43684. private _speedRatio;
  43685. private _loopAnimation;
  43686. private _isAdditive;
  43687. /**
  43688. * Gets or sets the unique id of the node
  43689. */
  43690. uniqueId: number;
  43691. /**
  43692. * This observable will notify when one animation have ended
  43693. */
  43694. onAnimationEndObservable: Observable<TargetedAnimation>;
  43695. /**
  43696. * Observer raised when one animation loops
  43697. */
  43698. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43699. /**
  43700. * Observer raised when all animations have looped
  43701. */
  43702. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43703. /**
  43704. * This observable will notify when all animations have ended.
  43705. */
  43706. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43707. /**
  43708. * This observable will notify when all animations have paused.
  43709. */
  43710. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43711. /**
  43712. * This observable will notify when all animations are playing.
  43713. */
  43714. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43715. /**
  43716. * Gets the first frame
  43717. */
  43718. get from(): number;
  43719. /**
  43720. * Gets the last frame
  43721. */
  43722. get to(): number;
  43723. /**
  43724. * Define if the animations are started
  43725. */
  43726. get isStarted(): boolean;
  43727. /**
  43728. * Gets a value indicating that the current group is playing
  43729. */
  43730. get isPlaying(): boolean;
  43731. /**
  43732. * Gets or sets the speed ratio to use for all animations
  43733. */
  43734. get speedRatio(): number;
  43735. /**
  43736. * Gets or sets the speed ratio to use for all animations
  43737. */
  43738. set speedRatio(value: number);
  43739. /**
  43740. * Gets or sets if all animations should loop or not
  43741. */
  43742. get loopAnimation(): boolean;
  43743. set loopAnimation(value: boolean);
  43744. /**
  43745. * Gets or sets if all animations should be evaluated additively
  43746. */
  43747. get isAdditive(): boolean;
  43748. set isAdditive(value: boolean);
  43749. /**
  43750. * Gets the targeted animations for this animation group
  43751. */
  43752. get targetedAnimations(): Array<TargetedAnimation>;
  43753. /**
  43754. * returning the list of animatables controlled by this animation group.
  43755. */
  43756. get animatables(): Array<Animatable>;
  43757. /**
  43758. * Gets the list of target animations
  43759. */
  43760. get children(): TargetedAnimation[];
  43761. /**
  43762. * Instantiates a new Animation Group.
  43763. * This helps managing several animations at once.
  43764. * @see https://doc.babylonjs.com/how_to/group
  43765. * @param name Defines the name of the group
  43766. * @param scene Defines the scene the group belongs to
  43767. */
  43768. constructor(
  43769. /** The name of the animation group */
  43770. name: string, scene?: Nullable<Scene>);
  43771. /**
  43772. * Add an animation (with its target) in the group
  43773. * @param animation defines the animation we want to add
  43774. * @param target defines the target of the animation
  43775. * @returns the TargetedAnimation object
  43776. */
  43777. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43778. /**
  43779. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43780. * It can add constant keys at begin or end
  43781. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43782. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43783. * @returns the animation group
  43784. */
  43785. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43786. private _animationLoopCount;
  43787. private _animationLoopFlags;
  43788. private _processLoop;
  43789. /**
  43790. * Start all animations on given targets
  43791. * @param loop defines if animations must loop
  43792. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43793. * @param from defines the from key (optional)
  43794. * @param to defines the to key (optional)
  43795. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43796. * @returns the current animation group
  43797. */
  43798. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43799. /**
  43800. * Pause all animations
  43801. * @returns the animation group
  43802. */
  43803. pause(): AnimationGroup;
  43804. /**
  43805. * Play all animations to initial state
  43806. * This function will start() the animations if they were not started or will restart() them if they were paused
  43807. * @param loop defines if animations must loop
  43808. * @returns the animation group
  43809. */
  43810. play(loop?: boolean): AnimationGroup;
  43811. /**
  43812. * Reset all animations to initial state
  43813. * @returns the animation group
  43814. */
  43815. reset(): AnimationGroup;
  43816. /**
  43817. * Restart animations from key 0
  43818. * @returns the animation group
  43819. */
  43820. restart(): AnimationGroup;
  43821. /**
  43822. * Stop all animations
  43823. * @returns the animation group
  43824. */
  43825. stop(): AnimationGroup;
  43826. /**
  43827. * Set animation weight for all animatables
  43828. * @param weight defines the weight to use
  43829. * @return the animationGroup
  43830. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43831. */
  43832. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43833. /**
  43834. * Synchronize and normalize all animatables with a source animatable
  43835. * @param root defines the root animatable to synchronize with
  43836. * @return the animationGroup
  43837. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43838. */
  43839. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43840. /**
  43841. * Goes to a specific frame in this animation group
  43842. * @param frame the frame number to go to
  43843. * @return the animationGroup
  43844. */
  43845. goToFrame(frame: number): AnimationGroup;
  43846. /**
  43847. * Dispose all associated resources
  43848. */
  43849. dispose(): void;
  43850. private _checkAnimationGroupEnded;
  43851. /**
  43852. * Clone the current animation group and returns a copy
  43853. * @param newName defines the name of the new group
  43854. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43855. * @returns the new aniamtion group
  43856. */
  43857. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43858. /**
  43859. * Serializes the animationGroup to an object
  43860. * @returns Serialized object
  43861. */
  43862. serialize(): any;
  43863. /**
  43864. * Returns a new AnimationGroup object parsed from the source provided.
  43865. * @param parsedAnimationGroup defines the source
  43866. * @param scene defines the scene that will receive the animationGroup
  43867. * @returns a new AnimationGroup
  43868. */
  43869. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43870. /**
  43871. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43872. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43873. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43874. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43875. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43876. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43877. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43878. */
  43879. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43880. /**
  43881. * Returns the string "AnimationGroup"
  43882. * @returns "AnimationGroup"
  43883. */
  43884. getClassName(): string;
  43885. /**
  43886. * Creates a detailled string about the object
  43887. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43888. * @returns a string representing the object
  43889. */
  43890. toString(fullDetails?: boolean): string;
  43891. }
  43892. }
  43893. declare module BABYLON {
  43894. /**
  43895. * @hidden
  43896. **/
  43897. export class _TimeToken {
  43898. _startTimeQuery: Nullable<WebGLQuery>;
  43899. _endTimeQuery: Nullable<WebGLQuery>;
  43900. _timeElapsedQuery: Nullable<WebGLQuery>;
  43901. _timeElapsedQueryEnded: boolean;
  43902. }
  43903. }
  43904. declare module BABYLON {
  43905. /** @hidden */
  43906. export enum ExtensionName {
  43907. DepthClamping = "depth-clamping",
  43908. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43909. Depth32FloatStencil8 = "depth32float-stencil8",
  43910. PipelineStatisticsQuery = "pipeline-statistics-query",
  43911. TextureCompressionBC = "texture-compression-bc",
  43912. TimestampQuery = "timestamp-query"
  43913. }
  43914. /** @hidden */
  43915. export enum AddressMode {
  43916. ClampToEdge = "clamp-to-edge",
  43917. Repeat = "repeat",
  43918. MirrorRepeat = "mirror-repeat"
  43919. }
  43920. /** @hidden */
  43921. export enum BindingType {
  43922. UniformBuffer = "uniform-buffer",
  43923. StorageBuffer = "storage-buffer",
  43924. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43925. Sampler = "sampler",
  43926. ComparisonSampler = "comparison-sampler",
  43927. SampledTexture = "sampled-texture",
  43928. ReadonlyStorageTexture = "readonly-storage-texture",
  43929. WriteonlyStorageTexture = "writeonly-storage-texture"
  43930. }
  43931. /** @hidden */
  43932. export enum BlendFactor {
  43933. Zero = "zero",
  43934. One = "one",
  43935. SrcColor = "src-color",
  43936. OneMinusSrcColor = "one-minus-src-color",
  43937. SrcAlpha = "src-alpha",
  43938. OneMinusSrcAlpha = "one-minus-src-alpha",
  43939. DstColor = "dst-color",
  43940. OneMinusDstColor = "one-minus-dst-color",
  43941. DstAlpha = "dst-alpha",
  43942. OneMinusDstAlpha = "one-minus-dst-alpha",
  43943. SrcAlphaSaturated = "src-alpha-saturated",
  43944. BlendColor = "blend-color",
  43945. OneMinusBlendColor = "one-minus-blend-color"
  43946. }
  43947. /** @hidden */
  43948. export enum BlendOperation {
  43949. Add = "add",
  43950. Subtract = "subtract",
  43951. ReverseSubtract = "reverse-subtract",
  43952. Min = "min",
  43953. Max = "max"
  43954. }
  43955. /** @hidden */
  43956. export enum CompareFunction {
  43957. Never = "never",
  43958. Less = "less",
  43959. Equal = "equal",
  43960. LessEqual = "less-equal",
  43961. Greater = "greater",
  43962. NotEqual = "not-equal",
  43963. GreaterEqual = "greater-equal",
  43964. Always = "always"
  43965. }
  43966. /** @hidden */
  43967. export enum CullMode {
  43968. None = "none",
  43969. Front = "front",
  43970. Back = "back"
  43971. }
  43972. /** @hidden */
  43973. export enum FilterMode {
  43974. Nearest = "nearest",
  43975. Linear = "linear"
  43976. }
  43977. /** @hidden */
  43978. export enum FrontFace {
  43979. CCW = "ccw",
  43980. CW = "cw"
  43981. }
  43982. /** @hidden */
  43983. export enum IndexFormat {
  43984. Uint16 = "uint16",
  43985. Uint32 = "uint32"
  43986. }
  43987. /** @hidden */
  43988. export enum InputStepMode {
  43989. Vertex = "vertex",
  43990. Instance = "instance"
  43991. }
  43992. /** @hidden */
  43993. export enum LoadOp {
  43994. Load = "load"
  43995. }
  43996. /** @hidden */
  43997. export enum PrimitiveTopology {
  43998. PointList = "point-list",
  43999. LineList = "line-list",
  44000. LineStrip = "line-strip",
  44001. TriangleList = "triangle-list",
  44002. TriangleStrip = "triangle-strip"
  44003. }
  44004. /** @hidden */
  44005. export enum StencilOperation {
  44006. Keep = "keep",
  44007. Zero = "zero",
  44008. Replace = "replace",
  44009. Invert = "invert",
  44010. IncrementClamp = "increment-clamp",
  44011. DecrementClamp = "decrement-clamp",
  44012. IncrementWrap = "increment-wrap",
  44013. DecrementWrap = "decrement-wrap"
  44014. }
  44015. /** @hidden */
  44016. export enum StoreOp {
  44017. Store = "store",
  44018. Clear = "clear"
  44019. }
  44020. /** @hidden */
  44021. export enum TextureDimension {
  44022. E1d = "1d",
  44023. E2d = "2d",
  44024. E3d = "3d"
  44025. }
  44026. /** @hidden */
  44027. export enum TextureFormat {
  44028. R8Unorm = "r8unorm",
  44029. R8Snorm = "r8snorm",
  44030. R8Uint = "r8uint",
  44031. R8Sint = "r8sint",
  44032. R16Uint = "r16uint",
  44033. R16Sint = "r16sint",
  44034. R16Float = "r16float",
  44035. RG8Unorm = "rg8unorm",
  44036. RG8Snorm = "rg8snorm",
  44037. RG8Uint = "rg8uint",
  44038. RG8Sint = "rg8sint",
  44039. R32Uint = "r32uint",
  44040. R32Sint = "r32sint",
  44041. R32Float = "r32float",
  44042. RG16Uint = "rg16uint",
  44043. RG16Sint = "rg16sint",
  44044. RG16Float = "rg16float",
  44045. RGBA8Unorm = "rgba8unorm",
  44046. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44047. RGBA8Snorm = "rgba8snorm",
  44048. RGBA8Uint = "rgba8uint",
  44049. RGBA8Sint = "rgba8sint",
  44050. BGRA8Unorm = "bgra8unorm",
  44051. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44052. RGB9E5UFloat = "rgb9e5ufloat",
  44053. RGB10A2Unorm = "rgb10a2unorm",
  44054. RG11B10UFloat = "rg11b10ufloat",
  44055. RG32Uint = "rg32uint",
  44056. RG32Sint = "rg32sint",
  44057. RG32Float = "rg32float",
  44058. RGBA16Uint = "rgba16uint",
  44059. RGBA16Sint = "rgba16sint",
  44060. RGBA16Float = "rgba16float",
  44061. RGBA32Uint = "rgba32uint",
  44062. RGBA32Sint = "rgba32sint",
  44063. RGBA32Float = "rgba32float",
  44064. Stencil8 = "stencil8",
  44065. Depth16Unorm = "depth16unorm",
  44066. Depth24Plus = "depth24plus",
  44067. Depth24PlusStencil8 = "depth24plus-stencil8",
  44068. Depth32Float = "depth32float",
  44069. BC1RGBAUNorm = "bc1-rgba-unorm",
  44070. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44071. BC2RGBAUnorm = "bc2-rgba-unorm",
  44072. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44073. BC3RGBAUnorm = "bc3-rgba-unorm",
  44074. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44075. BC4RUnorm = "bc4-r-unorm",
  44076. BC4RSnorm = "bc4-r-snorm",
  44077. BC5RGUnorm = "bc5-rg-unorm",
  44078. BC5RGSnorm = "bc5-rg-snorm",
  44079. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44080. BC6HRGBFloat = "bc6h-rgb-float",
  44081. BC7RGBAUnorm = "bc7-rgba-unorm",
  44082. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44083. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44084. Depth32FloatStencil8 = "depth32float-stencil8"
  44085. }
  44086. /** @hidden */
  44087. export enum TextureComponentType {
  44088. Float = "float",
  44089. Sint = "sint",
  44090. Uint = "uint",
  44091. DepthComparison = "depth-comparison"
  44092. }
  44093. /** @hidden */
  44094. export enum TextureViewDimension {
  44095. E1d = "1d",
  44096. E2d = "2d",
  44097. E2dArray = "2d-array",
  44098. Cube = "cube",
  44099. CubeArray = "cube-array",
  44100. E3d = "3d"
  44101. }
  44102. /** @hidden */
  44103. export enum VertexFormat {
  44104. Uchar2 = "uchar2",
  44105. Uchar4 = "uchar4",
  44106. Char2 = "char2",
  44107. Char4 = "char4",
  44108. Uchar2Norm = "uchar2norm",
  44109. Uchar4Norm = "uchar4norm",
  44110. Char2Norm = "char2norm",
  44111. Char4Norm = "char4norm",
  44112. Ushort2 = "ushort2",
  44113. Ushort4 = "ushort4",
  44114. Short2 = "short2",
  44115. Short4 = "short4",
  44116. Ushort2Norm = "ushort2norm",
  44117. Ushort4Norm = "ushort4norm",
  44118. Short2Norm = "short2norm",
  44119. Short4Norm = "short4norm",
  44120. Half2 = "half2",
  44121. Half4 = "half4",
  44122. Float = "float",
  44123. Float2 = "float2",
  44124. Float3 = "float3",
  44125. Float4 = "float4",
  44126. Uint = "uint",
  44127. Uint2 = "uint2",
  44128. Uint3 = "uint3",
  44129. Uint4 = "uint4",
  44130. Int = "int",
  44131. Int2 = "int2",
  44132. Int3 = "int3",
  44133. Int4 = "int4"
  44134. }
  44135. /** @hidden */
  44136. export enum TextureAspect {
  44137. All = "all",
  44138. StencilOnly = "stencil-only",
  44139. DepthOnly = "depth-only"
  44140. }
  44141. /** @hidden */
  44142. export enum CompilationMessageType {
  44143. Error = "error",
  44144. Warning = "warning",
  44145. Info = "info"
  44146. }
  44147. /** @hidden */
  44148. export enum QueryType {
  44149. Occlusion = "occlusion"
  44150. }
  44151. /** @hidden */
  44152. export enum BufferUsage {
  44153. MapRead = 1,
  44154. MapWrite = 2,
  44155. CopySrc = 4,
  44156. CopyDst = 8,
  44157. Index = 16,
  44158. Vertex = 32,
  44159. Uniform = 64,
  44160. Storage = 128,
  44161. Indirect = 256,
  44162. QueryResolve = 512
  44163. }
  44164. /** @hidden */
  44165. export enum ColorWrite {
  44166. Red = 1,
  44167. Green = 2,
  44168. Blue = 4,
  44169. Alpha = 8,
  44170. All = 15
  44171. }
  44172. /** @hidden */
  44173. export enum ShaderStage {
  44174. Vertex = 1,
  44175. Fragment = 2,
  44176. Compute = 4
  44177. }
  44178. /** @hidden */
  44179. export enum TextureUsage {
  44180. CopySrc = 1,
  44181. CopyDst = 2,
  44182. Sampled = 4,
  44183. Storage = 8,
  44184. OutputAttachment = 16
  44185. }
  44186. /** @hidden */
  44187. export enum MapMode {
  44188. Read = 1,
  44189. Write = 2
  44190. }
  44191. }
  44192. declare module BABYLON {
  44193. /** @hidden */
  44194. export interface WebGPUBindingInfo {
  44195. setIndex: number;
  44196. bindingIndex: number;
  44197. }
  44198. /** @hidden */
  44199. export interface WebGPUTextureSamplerBindingDescription {
  44200. sampler: WebGPUBindingInfo;
  44201. isTextureArray: boolean;
  44202. textures: Array<WebGPUBindingInfo>;
  44203. }
  44204. /** @hidden
  44205. * If the binding is a UBO, isSampler=isTexture=false
  44206. */
  44207. export interface WebGPUBindingDescription {
  44208. name: string;
  44209. usedInVertex: boolean;
  44210. usedInFragment: boolean;
  44211. isSampler: boolean;
  44212. isComparisonSampler?: boolean;
  44213. isTexture: boolean;
  44214. componentType?: GPUTextureComponentType;
  44215. textureDimension?: GPUTextureViewDimension;
  44216. }
  44217. /**
  44218. * @hidden
  44219. */
  44220. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44221. uboNextBindingIndex: number;
  44222. freeSetIndex: number;
  44223. freeBindingIndex: number;
  44224. availableVaryings: {
  44225. [key: string]: number;
  44226. };
  44227. availableAttributes: {
  44228. [key: string]: number;
  44229. };
  44230. availableUBOs: {
  44231. [key: string]: {
  44232. setIndex: number;
  44233. bindingIndex: number;
  44234. };
  44235. };
  44236. availableSamplers: {
  44237. [key: string]: WebGPUTextureSamplerBindingDescription;
  44238. };
  44239. leftOverUniforms: {
  44240. name: string;
  44241. type: string;
  44242. length: number;
  44243. }[];
  44244. orderedAttributes: string[];
  44245. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44246. uniformBufferNames: string[];
  44247. private _attributeNextLocation;
  44248. private _varyingNextLocation;
  44249. constructor();
  44250. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44251. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44252. getNextFreeUBOBinding(): {
  44253. setIndex: number;
  44254. bindingIndex: number;
  44255. };
  44256. private _getNextFreeBinding;
  44257. }
  44258. }
  44259. declare module BABYLON {
  44260. /** @hidden */
  44261. export interface IWebGPUPipelineContextSamplerCache {
  44262. samplerBinding: number;
  44263. firstTextureName: string;
  44264. }
  44265. /** @hidden */
  44266. export interface IWebGPUPipelineContextTextureCache {
  44267. textureBinding: number;
  44268. texture: InternalTexture;
  44269. }
  44270. /** @hidden */
  44271. export interface IWebGPUPipelineContextVertexInputsCache {
  44272. indexBuffer: Nullable<GPUBuffer>;
  44273. indexOffset: number;
  44274. vertexStartSlot: number;
  44275. vertexBuffers: GPUBuffer[];
  44276. vertexOffsets: number[];
  44277. }
  44278. /** @hidden */
  44279. export interface IWebGPURenderPipelineStageDescriptor {
  44280. vertexStage: GPUProgrammableStageDescriptor;
  44281. fragmentStage?: GPUProgrammableStageDescriptor;
  44282. }
  44283. /** @hidden */
  44284. export class WebGPUPipelineContext implements IPipelineContext {
  44285. engine: WebGPUEngine;
  44286. shaderProcessingContext: WebGPUShaderProcessingContext;
  44287. leftOverUniformsByName: {
  44288. [name: string]: string;
  44289. };
  44290. sources: {
  44291. vertex: string;
  44292. fragment: string;
  44293. rawVertex: string;
  44294. rawFragment: string;
  44295. };
  44296. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44297. samplers: {
  44298. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44299. };
  44300. textures: {
  44301. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44302. };
  44303. bindGroupLayouts: GPUBindGroupLayout[];
  44304. bindGroupsCache: {
  44305. [key: string]: GPUBindGroup[];
  44306. };
  44307. /**
  44308. * Stores the uniform buffer
  44309. */
  44310. uniformBuffer: Nullable<UniformBuffer>;
  44311. onCompiled?: () => void;
  44312. get isAsync(): boolean;
  44313. get isReady(): boolean;
  44314. /** @hidden */
  44315. _name: string;
  44316. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44317. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44318. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44319. [key: string]: number;
  44320. }, uniformsNames: string[], uniforms: {
  44321. [key: string]: Nullable<WebGLUniformLocation>;
  44322. }, samplerList: string[], samplers: {
  44323. [key: string]: number;
  44324. }, attributesNames: string[], attributes: number[]): void;
  44325. /** @hidden */
  44326. /**
  44327. * Build the uniform buffer used in the material.
  44328. */
  44329. buildUniformLayout(): void;
  44330. /**
  44331. * Release all associated resources.
  44332. **/
  44333. dispose(): void;
  44334. /**
  44335. * Sets an integer value on a uniform variable.
  44336. * @param uniformName Name of the variable.
  44337. * @param value Value to be set.
  44338. */
  44339. setInt(uniformName: string, value: number): void;
  44340. /**
  44341. * Sets an int2 value on a uniform variable.
  44342. * @param uniformName Name of the variable.
  44343. * @param x First int in int2.
  44344. * @param y Second int in int2.
  44345. */
  44346. setInt2(uniformName: string, x: number, y: number): void;
  44347. /**
  44348. * Sets an int3 value on a uniform variable.
  44349. * @param uniformName Name of the variable.
  44350. * @param x First int in int3.
  44351. * @param y Second int in int3.
  44352. * @param z Third int in int3.
  44353. */
  44354. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44355. /**
  44356. * Sets an int4 value on a uniform variable.
  44357. * @param uniformName Name of the variable.
  44358. * @param x First int in int4.
  44359. * @param y Second int in int4.
  44360. * @param z Third int in int4.
  44361. * @param w Fourth int in int4.
  44362. */
  44363. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44364. /**
  44365. * Sets an int array on a uniform variable.
  44366. * @param uniformName Name of the variable.
  44367. * @param array array to be set.
  44368. */
  44369. setIntArray(uniformName: string, array: Int32Array): void;
  44370. /**
  44371. * 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)
  44372. * @param uniformName Name of the variable.
  44373. * @param array array to be set.
  44374. */
  44375. setIntArray2(uniformName: string, array: Int32Array): void;
  44376. /**
  44377. * 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)
  44378. * @param uniformName Name of the variable.
  44379. * @param array array to be set.
  44380. */
  44381. setIntArray3(uniformName: string, array: Int32Array): void;
  44382. /**
  44383. * 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)
  44384. * @param uniformName Name of the variable.
  44385. * @param array array to be set.
  44386. */
  44387. setIntArray4(uniformName: string, array: Int32Array): void;
  44388. /**
  44389. * Sets an array on a uniform variable.
  44390. * @param uniformName Name of the variable.
  44391. * @param array array to be set.
  44392. */
  44393. setArray(uniformName: string, array: number[]): void;
  44394. /**
  44395. * 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)
  44396. * @param uniformName Name of the variable.
  44397. * @param array array to be set.
  44398. */
  44399. setArray2(uniformName: string, array: number[]): void;
  44400. /**
  44401. * 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)
  44402. * @param uniformName Name of the variable.
  44403. * @param array array to be set.
  44404. * @returns this effect.
  44405. */
  44406. setArray3(uniformName: string, array: number[]): void;
  44407. /**
  44408. * 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)
  44409. * @param uniformName Name of the variable.
  44410. * @param array array to be set.
  44411. */
  44412. setArray4(uniformName: string, array: number[]): void;
  44413. /**
  44414. * Sets matrices on a uniform variable.
  44415. * @param uniformName Name of the variable.
  44416. * @param matrices matrices to be set.
  44417. */
  44418. setMatrices(uniformName: string, matrices: Float32Array): void;
  44419. /**
  44420. * Sets matrix on a uniform variable.
  44421. * @param uniformName Name of the variable.
  44422. * @param matrix matrix to be set.
  44423. */
  44424. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44425. /**
  44426. * 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)
  44427. * @param uniformName Name of the variable.
  44428. * @param matrix matrix to be set.
  44429. */
  44430. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44431. /**
  44432. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44433. * @param uniformName Name of the variable.
  44434. * @param matrix matrix to be set.
  44435. */
  44436. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44437. /**
  44438. * Sets a float on a uniform variable.
  44439. * @param uniformName Name of the variable.
  44440. * @param value value to be set.
  44441. * @returns this effect.
  44442. */
  44443. setFloat(uniformName: string, value: number): void;
  44444. /**
  44445. * Sets a Vector2 on a uniform variable.
  44446. * @param uniformName Name of the variable.
  44447. * @param vector2 vector2 to be set.
  44448. */
  44449. setVector2(uniformName: string, vector2: IVector2Like): void;
  44450. /**
  44451. * Sets a float2 on a uniform variable.
  44452. * @param uniformName Name of the variable.
  44453. * @param x First float in float2.
  44454. * @param y Second float in float2.
  44455. */
  44456. setFloat2(uniformName: string, x: number, y: number): void;
  44457. /**
  44458. * Sets a Vector3 on a uniform variable.
  44459. * @param uniformName Name of the variable.
  44460. * @param vector3 Value to be set.
  44461. */
  44462. setVector3(uniformName: string, vector3: IVector3Like): void;
  44463. /**
  44464. * Sets a float3 on a uniform variable.
  44465. * @param uniformName Name of the variable.
  44466. * @param x First float in float3.
  44467. * @param y Second float in float3.
  44468. * @param z Third float in float3.
  44469. */
  44470. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44471. /**
  44472. * Sets a Vector4 on a uniform variable.
  44473. * @param uniformName Name of the variable.
  44474. * @param vector4 Value to be set.
  44475. */
  44476. setVector4(uniformName: string, vector4: IVector4Like): void;
  44477. /**
  44478. * Sets a float4 on a uniform variable.
  44479. * @param uniformName Name of the variable.
  44480. * @param x First float in float4.
  44481. * @param y Second float in float4.
  44482. * @param z Third float in float4.
  44483. * @param w Fourth float in float4.
  44484. * @returns this effect.
  44485. */
  44486. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44487. /**
  44488. * Sets a Color3 on a uniform variable.
  44489. * @param uniformName Name of the variable.
  44490. * @param color3 Value to be set.
  44491. */
  44492. setColor3(uniformName: string, color3: IColor3Like): void;
  44493. /**
  44494. * Sets a Color4 on a uniform variable.
  44495. * @param uniformName Name of the variable.
  44496. * @param color3 Value to be set.
  44497. * @param alpha Alpha value to be set.
  44498. */
  44499. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44500. /**
  44501. * Sets a Color4 on a uniform variable
  44502. * @param uniformName defines the name of the variable
  44503. * @param color4 defines the value to be set
  44504. */
  44505. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44506. _getVertexShaderCode(): string | null;
  44507. _getFragmentShaderCode(): string | null;
  44508. }
  44509. }
  44510. declare module BABYLON {
  44511. /** @hidden */
  44512. export class WebGPUDataBuffer extends DataBuffer {
  44513. private _buffer;
  44514. constructor(resource: GPUBuffer);
  44515. get underlyingResource(): any;
  44516. }
  44517. }
  44518. declare module BABYLON {
  44519. /**
  44520. * Class used to inline functions in shader code
  44521. */
  44522. export class ShaderCodeInliner {
  44523. private static readonly _RegexpFindFunctionNameAndType;
  44524. private _sourceCode;
  44525. private _functionDescr;
  44526. private _numMaxIterations;
  44527. /** Gets or sets the token used to mark the functions to inline */
  44528. inlineToken: string;
  44529. /** Gets or sets the debug mode */
  44530. debug: boolean;
  44531. /** Gets the code after the inlining process */
  44532. get code(): string;
  44533. /**
  44534. * Initializes the inliner
  44535. * @param sourceCode shader code source to inline
  44536. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44537. */
  44538. constructor(sourceCode: string, numMaxIterations?: number);
  44539. /**
  44540. * Start the processing of the shader code
  44541. */
  44542. processCode(): void;
  44543. private _collectFunctions;
  44544. private _processInlining;
  44545. private _extractBetweenMarkers;
  44546. private _skipWhitespaces;
  44547. private _isIdentifierChar;
  44548. private _removeComments;
  44549. private _replaceFunctionCallsByCode;
  44550. private _findBackward;
  44551. private _escapeRegExp;
  44552. private _replaceNames;
  44553. }
  44554. }
  44555. declare module BABYLON {
  44556. /** @hidden */
  44557. export class WebGPUShaderProcessor implements IShaderProcessor {
  44558. protected _missingVaryings: Array<string>;
  44559. protected _textureArrayProcessing: Array<string>;
  44560. protected _preProcessors: {
  44561. [key: string]: string;
  44562. };
  44563. private _getArraySize;
  44564. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44565. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44566. [key: string]: string;
  44567. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44568. attributeProcessor(attribute: string, preProcessors: {
  44569. [key: string]: string;
  44570. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44571. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44572. [key: string]: string;
  44573. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44574. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44575. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44576. private _applyTextureArrayProcessing;
  44577. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44578. vertexCode: string;
  44579. fragmentCode: string;
  44580. };
  44581. }
  44582. }
  44583. declare module BABYLON {
  44584. /** @hidden */
  44585. export class WebGPUBufferManager {
  44586. private _device;
  44587. private _deferredReleaseBuffers;
  44588. private static _IsGPUBuffer;
  44589. constructor(device: GPUDevice);
  44590. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44591. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44592. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44593. private _FromHalfFloat;
  44594. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44595. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44596. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44597. destroyDeferredBuffers(): void;
  44598. }
  44599. }
  44600. declare module BABYLON {
  44601. /** @hidden */
  44602. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44603. private _webgpuTexture;
  44604. private _webgpuMSAATexture;
  44605. get underlyingResource(): Nullable<GPUTexture>;
  44606. get msaaTexture(): Nullable<GPUTexture>;
  44607. set msaaTexture(texture: Nullable<GPUTexture>);
  44608. view: Nullable<GPUTextureView>;
  44609. format: GPUTextureFormat;
  44610. textureUsages: number;
  44611. constructor(existingTexture?: Nullable<GPUTexture>);
  44612. set(hardwareTexture: GPUTexture): void;
  44613. setMSAATexture(hardwareTexture: GPUTexture): void;
  44614. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44615. createView(descriptor?: GPUTextureViewDescriptor): void;
  44616. reset(): void;
  44617. release(): void;
  44618. }
  44619. }
  44620. declare module BABYLON {
  44621. /** @hidden */
  44622. export class WebGPUTextureHelper {
  44623. private _device;
  44624. private _glslang;
  44625. private _bufferManager;
  44626. private _mipmapSampler;
  44627. private _invertYPreMultiplyAlphaSampler;
  44628. private _pipelines;
  44629. private _compiledShaders;
  44630. private _deferredReleaseTextures;
  44631. private _commandEncoderForCreation;
  44632. static ComputeNumMipmapLevels(width: number, height: number): number;
  44633. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44634. private _getPipeline;
  44635. private static _GetTextureTypeFromFormat;
  44636. private static _GetBlockInformationFromFormat;
  44637. private static _IsHardwareTexture;
  44638. private static _IsInternalTexture;
  44639. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44640. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44641. width: number;
  44642. height: number;
  44643. }): imageBitmap is ImageBitmap;
  44644. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44645. width: number;
  44646. height: number;
  44647. }): imageBitmap is ImageBitmap[];
  44648. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44649. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44650. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44651. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44652. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44653. createTexture(imageBitmap: ImageBitmap | {
  44654. width: number;
  44655. height: number;
  44656. layers: number;
  44657. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44658. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44659. width: number;
  44660. height: number;
  44661. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44662. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44663. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44664. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44665. createMSAATexture(texture: InternalTexture, samples: number): void;
  44666. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44667. 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;
  44668. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44669. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44670. destroyDeferredTextures(): void;
  44671. }
  44672. }
  44673. declare module BABYLON {
  44674. /** @hidden */
  44675. export class WebGPURenderPassWrapper {
  44676. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44677. renderPass: Nullable<GPURenderPassEncoder>;
  44678. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44679. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44680. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44681. depthTextureFormat: GPUTextureFormat | undefined;
  44682. constructor();
  44683. reset(fullReset?: boolean): void;
  44684. }
  44685. }
  44686. declare module BABYLON {
  44687. /** @hidden */
  44688. export class WebGPUCacheSampler {
  44689. private _samplers;
  44690. private _device;
  44691. disabled: boolean;
  44692. constructor(device: GPUDevice);
  44693. private static _GetSamplerHashCode;
  44694. private static _GetSamplerFilterDescriptor;
  44695. private static _GetWrappingMode;
  44696. private static _GetSamplerWrappingDescriptor;
  44697. private static _GetSamplerDescriptor;
  44698. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44699. }
  44700. }
  44701. declare module BABYLON {
  44702. /** @hidden */
  44703. export class WebGPUShaderManager {
  44704. private _shaders;
  44705. private _device;
  44706. constructor(device: GPUDevice);
  44707. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44708. }
  44709. }
  44710. declare module BABYLON {
  44711. /** @hidden */
  44712. export class WebGPUCacheRenderPipeline {
  44713. static NumCacheHitWithoutHash: number;
  44714. static NumCacheHitWithHash: number;
  44715. static NumCacheMiss: number;
  44716. static NumPipelineCreationLastFrame: number;
  44717. disabled: boolean;
  44718. private static _Cache;
  44719. private static _NumPipelineCreationCurrentFrame;
  44720. private _device;
  44721. private _states;
  44722. private _isDirty;
  44723. private _currentRenderPipeline;
  44724. private _emptyVertexBuffer;
  44725. private _shaderId;
  44726. private _alphaToCoverageEnabled;
  44727. private _frontFace;
  44728. private _cullEnabled;
  44729. private _cullFace;
  44730. private _clampDepth;
  44731. private _rasterizationState;
  44732. private _depthBias;
  44733. private _depthBiasClamp;
  44734. private _depthBiasSlopeScale;
  44735. private _colorFormat;
  44736. private _webgpuColorFormat;
  44737. private _mrtAttachments1;
  44738. private _mrtAttachments2;
  44739. private _mrtFormats;
  44740. private _alphaBlendEnabled;
  44741. private _alphaBlendFuncParams;
  44742. private _alphaBlendEqParams;
  44743. private _writeMask;
  44744. private _colorStates;
  44745. private _depthStencilFormat;
  44746. private _webgpuDepthStencilFormat;
  44747. private _depthTestEnabled;
  44748. private _depthWriteEnabled;
  44749. private _depthCompare;
  44750. private _stencilEnabled;
  44751. private _stencilFrontCompare;
  44752. private _stencilFrontDepthFailOp;
  44753. private _stencilFrontPassOp;
  44754. private _stencilFrontFailOp;
  44755. private _stencilReadMask;
  44756. private _stencilWriteMask;
  44757. private _depthStencilState;
  44758. private _vertexBuffers;
  44759. private _indexBuffer;
  44760. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  44761. reset(): void;
  44762. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  44763. endFrame(): void;
  44764. setAlphaToCoverage(enabled: boolean): void;
  44765. setFrontFace(frontFace: number): void;
  44766. setCullEnabled(enabled: boolean): void;
  44767. setCullFace(cullFace: number): void;
  44768. setClampDepth(clampDepth: boolean): void;
  44769. resetDepthCullingState(): void;
  44770. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  44771. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  44772. setColorFormat(format: GPUTextureFormat): void;
  44773. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  44774. setAlphaBlendEnabled(enabled: boolean): void;
  44775. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  44776. setWriteMask(mask: number): void;
  44777. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  44778. setDepthTestEnabled(enabled: boolean): void;
  44779. setDepthWriteEnabled(enabled: boolean): void;
  44780. setDepthCompare(func: Nullable<number>): void;
  44781. setStencilEnabled(enabled: boolean): void;
  44782. setStencilCompare(func: Nullable<number>): void;
  44783. setStencilDepthFailOp(op: Nullable<number>): void;
  44784. setStencilPassOp(op: Nullable<number>): void;
  44785. setStencilFailOp(op: Nullable<number>): void;
  44786. setStencilReadMask(mask: number): void;
  44787. setStencilWriteMask(mask: number): void;
  44788. resetStencilState(): void;
  44789. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  44790. setBuffers(vertexBuffers: Nullable<{
  44791. [key: string]: Nullable<VertexBuffer>;
  44792. }>, indexBuffer: Nullable<DataBuffer>): void;
  44793. private static _GetTopology;
  44794. private static _GetAphaBlendOperation;
  44795. private static _GetAphaBlendFactor;
  44796. private static _GetCompareFunction;
  44797. private static _GetStencilOpFunction;
  44798. private static _GetVertexInputDescriptorFormat;
  44799. private _getAphaBlendState;
  44800. private _getColorBlendState;
  44801. private _setShaderStage;
  44802. private _setRasterizationState;
  44803. private _setColorStates;
  44804. private _setDepthStencilState;
  44805. private _setVertexState;
  44806. private _createPipelineLayout;
  44807. private _getVertexInputDescriptor;
  44808. private _createRenderPipeline;
  44809. }
  44810. }
  44811. declare module BABYLON {
  44812. /** @hidden */
  44813. export var clearQuadVertexShader: {
  44814. name: string;
  44815. shader: string;
  44816. };
  44817. }
  44818. declare module BABYLON {
  44819. /** @hidden */
  44820. export var clearQuadPixelShader: {
  44821. name: string;
  44822. shader: string;
  44823. };
  44824. }
  44825. declare module BABYLON {
  44826. /**
  44827. * Options to load the associated Glslang library
  44828. */
  44829. export interface GlslangOptions {
  44830. /**
  44831. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44832. */
  44833. glslang?: any;
  44834. /**
  44835. * Defines the URL of the glslang JS File.
  44836. */
  44837. jsPath?: string;
  44838. /**
  44839. * Defines the URL of the glslang WASM File.
  44840. */
  44841. wasmPath?: string;
  44842. }
  44843. /**
  44844. * Options to create the WebGPU engine
  44845. */
  44846. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44847. /**
  44848. * If delta time between frames should be constant
  44849. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44850. */
  44851. deterministicLockstep?: boolean;
  44852. /**
  44853. * Maximum about of steps between frames (Default: 4)
  44854. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44855. */
  44856. lockstepMaxSteps?: number;
  44857. /**
  44858. * Defines the seconds between each deterministic lock step
  44859. */
  44860. timeStep?: number;
  44861. /**
  44862. * Defines that engine should ignore modifying touch action attribute and style
  44863. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44864. */
  44865. doNotHandleTouchAction?: boolean;
  44866. /**
  44867. * Defines if webaudio should be initialized as well
  44868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44869. */
  44870. audioEngine?: boolean;
  44871. /**
  44872. * Defines the category of adapter to use.
  44873. * Is it the discrete or integrated device.
  44874. */
  44875. powerPreference?: GPUPowerPreference;
  44876. /**
  44877. * Defines the device descriptor used to create a device.
  44878. */
  44879. deviceDescriptor?: GPUDeviceDescriptor;
  44880. /**
  44881. * Defines the requested Swap Chain Format.
  44882. */
  44883. swapChainFormat?: GPUTextureFormat;
  44884. /**
  44885. * Defines wether MSAA is enabled on the canvas.
  44886. */
  44887. antialiasing?: boolean;
  44888. /**
  44889. * Defines wether the stencil buffer should be enabled.
  44890. */
  44891. stencil?: boolean;
  44892. /**
  44893. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44894. */
  44895. enableGPUDebugMarkers?: boolean;
  44896. /**
  44897. * Options to load the associated Glslang library
  44898. */
  44899. glslangOptions?: GlslangOptions;
  44900. }
  44901. /**
  44902. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44903. */
  44904. export class WebGPUEngine extends Engine {
  44905. private static readonly _glslangDefaultOptions;
  44906. private readonly _uploadEncoderDescriptor;
  44907. private readonly _renderEncoderDescriptor;
  44908. private readonly _renderTargetEncoderDescriptor;
  44909. private readonly _clearDepthValue;
  44910. private readonly _clearReverseDepthValue;
  44911. private readonly _clearStencilValue;
  44912. private readonly _defaultSampleCount;
  44913. private _canvas;
  44914. private _options;
  44915. private _glslang;
  44916. private _adapter;
  44917. private _adapterSupportedExtensions;
  44918. private _device;
  44919. private _deviceEnabledExtensions;
  44920. private _context;
  44921. private _swapChain;
  44922. private _swapChainTexture;
  44923. private _mainPassSampleCount;
  44924. private _textureHelper;
  44925. private _bufferManager;
  44926. private _shaderManager;
  44927. private _cacheSampler;
  44928. private _cacheRenderPipeline;
  44929. private _emptyVertexBuffer;
  44930. private _lastCachedWrapU;
  44931. private _lastCachedWrapV;
  44932. private _lastCachedWrapR;
  44933. private _mrtAttachments;
  44934. private _counters;
  44935. private _mainTexture;
  44936. private _depthTexture;
  44937. private _mainTextureExtends;
  44938. private _depthTextureFormat;
  44939. private _colorFormat;
  44940. private _uploadEncoder;
  44941. private _renderEncoder;
  44942. private _renderTargetEncoder;
  44943. private _commandBuffers;
  44944. private _currentRenderPass;
  44945. private _mainRenderPassWrapper;
  44946. private _rttRenderPassWrapper;
  44947. private _pendingDebugCommands;
  44948. private _currentVertexBuffers;
  44949. private _currentIndexBuffer;
  44950. private __colorWrite;
  44951. private _uniformsBuffers;
  44952. private _forceEnableEffect;
  44953. /** @hidden */
  44954. dbgShowShaderCode: boolean;
  44955. /** @hidden */
  44956. dbgSanityChecks: boolean;
  44957. /** @hidden */
  44958. dbgGenerateLogs: boolean;
  44959. /** @hidden */
  44960. dbgVerboseLogsForFirstFrames: boolean;
  44961. /** @hidden */
  44962. dbgVerboseLogsNumFrames: number;
  44963. /** @hidden */
  44964. dbgShowWarningsNotImplemented: boolean;
  44965. /**
  44966. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  44967. */
  44968. get disableCacheSamplers(): boolean;
  44969. set disableCacheSamplers(disable: boolean);
  44970. /**
  44971. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  44972. */
  44973. get disableCacheRenderPipelines(): boolean;
  44974. set disableCacheRenderPipelines(disable: boolean);
  44975. /**
  44976. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  44977. * @returns true if the engine can be created
  44978. */
  44979. static get IsSupported(): boolean;
  44980. /**
  44981. * Gets a boolean indicating that the engine supports uniform buffers
  44982. */
  44983. get supportsUniformBuffers(): boolean;
  44984. /** Gets the supported extensions by the WebGPU adapter */
  44985. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  44986. /** Gets the currently enabled extensions on the WebGPU device */
  44987. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  44988. /**
  44989. * Returns the name of the engine
  44990. */
  44991. get name(): string;
  44992. /**
  44993. * Returns a string describing the current engine
  44994. */
  44995. get description(): string;
  44996. /**
  44997. * Returns the version of the engine
  44998. */
  44999. get version(): number;
  45000. /**
  45001. * Create a new instance of the gpu engine asynchronously
  45002. * @param canvas Defines the canvas to use to display the result
  45003. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45004. * @returns a promise that resolves with the created engine
  45005. */
  45006. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45007. /**
  45008. * Create a new instance of the gpu engine.
  45009. * @param canvas Defines the canvas to use to display the result
  45010. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45011. */
  45012. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45013. /**
  45014. * Initializes the WebGPU context and dependencies.
  45015. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45016. * @returns a promise notifying the readiness of the engine.
  45017. */
  45018. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45019. private _initGlslang;
  45020. private _initializeLimits;
  45021. private _initializeContextAndSwapChain;
  45022. private _initializeMainAttachments;
  45023. /**
  45024. * Force a specific size of the canvas
  45025. * @param width defines the new canvas' width
  45026. * @param height defines the new canvas' height
  45027. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45028. * @returns true if the size was changed
  45029. */
  45030. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45031. /**
  45032. * Gets a shader processor implementation fitting with the current engine type.
  45033. * @returns The shader processor implementation.
  45034. */
  45035. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45036. /** @hidden */
  45037. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45038. /**
  45039. * Force the entire cache to be cleared
  45040. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45041. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45042. */
  45043. wipeCaches(bruteForce?: boolean): void;
  45044. /**
  45045. * Enable or disable color writing
  45046. * @param enable defines the state to set
  45047. */
  45048. setColorWrite(enable: boolean): void;
  45049. /**
  45050. * Gets a boolean indicating if color writing is enabled
  45051. * @returns the current color writing state
  45052. */
  45053. getColorWrite(): boolean;
  45054. private _viewportsCurrent;
  45055. private _resetCurrentViewport;
  45056. private _applyViewport;
  45057. /** @hidden */
  45058. _viewport(x: number, y: number, width: number, height: number): void;
  45059. private _scissorsCurrent;
  45060. protected _scissorCached: {
  45061. x: number;
  45062. y: number;
  45063. z: number;
  45064. w: number;
  45065. };
  45066. private _resetCurrentScissor;
  45067. private _applyScissor;
  45068. private _scissorIsActive;
  45069. enableScissor(x: number, y: number, width: number, height: number): void;
  45070. disableScissor(): void;
  45071. /**
  45072. * Clear the current render buffer or the current render target (if any is set up)
  45073. * @param color defines the color to use
  45074. * @param backBuffer defines if the back buffer must be cleared
  45075. * @param depth defines if the depth buffer must be cleared
  45076. * @param stencil defines if the stencil buffer must be cleared
  45077. */
  45078. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45079. /**
  45080. * Clears a list of attachments
  45081. * @param attachments list of the attachments
  45082. * @param colorMain clear color for the main attachment (the first one)
  45083. * @param colorOthers clear color for the other attachments
  45084. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45085. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45086. */
  45087. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45088. /**
  45089. * Creates a vertex buffer
  45090. * @param data the data for the vertex buffer
  45091. * @returns the new buffer
  45092. */
  45093. createVertexBuffer(data: DataArray): DataBuffer;
  45094. /**
  45095. * Creates a vertex buffer
  45096. * @param data the data for the dynamic vertex buffer
  45097. * @returns the new buffer
  45098. */
  45099. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45100. /**
  45101. * Updates a vertex buffer.
  45102. * @param vertexBuffer the vertex buffer to update
  45103. * @param data the data used to update the vertex buffer
  45104. * @param byteOffset the byte offset of the data
  45105. * @param byteLength the byte length of the data
  45106. */
  45107. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45108. /**
  45109. * Creates a new index buffer
  45110. * @param indices defines the content of the index buffer
  45111. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45112. * @returns a new buffer
  45113. */
  45114. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45115. /**
  45116. * Update an index buffer
  45117. * @param indexBuffer defines the target index buffer
  45118. * @param indices defines the data to update
  45119. * @param offset defines the offset in the target index buffer where update should start
  45120. */
  45121. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45122. /** @hidden */
  45123. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45124. /** @hidden */
  45125. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45126. /**
  45127. * Bind a list of vertex buffers with the engine
  45128. * @param vertexBuffers defines the list of vertex buffers to bind
  45129. * @param indexBuffer defines the index buffer to bind
  45130. * @param effect defines the effect associated with the vertex buffers
  45131. */
  45132. bindBuffers(vertexBuffers: {
  45133. [key: string]: Nullable<VertexBuffer>;
  45134. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  45135. /** @hidden */
  45136. _releaseBuffer(buffer: DataBuffer): boolean;
  45137. createUniformBuffer(elements: FloatArray): DataBuffer;
  45138. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45139. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45140. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45141. /**
  45142. * Create a new effect (used to store vertex/fragment shaders)
  45143. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45144. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45145. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45146. * @param samplers defines an array of string used to represent textures
  45147. * @param defines defines the string containing the defines to use to compile the shaders
  45148. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  45149. * @param onCompiled defines a function to call when the effect creation is successful
  45150. * @param onError defines a function to call when the effect creation has failed
  45151. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45152. * @returns the new Effect
  45153. */
  45154. 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;
  45155. private _compileRawShaderToSpirV;
  45156. private _compileShaderToSpirV;
  45157. private _createPipelineStageDescriptor;
  45158. private _compileRawPipelineStageDescriptor;
  45159. private _compilePipelineStageDescriptor;
  45160. /** @hidden */
  45161. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45162. /** @hidden */
  45163. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45164. /**
  45165. * Creates a new pipeline context
  45166. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45167. * @returns the new pipeline
  45168. */
  45169. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45170. /** @hidden */
  45171. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45172. /**
  45173. * Gets the list of active attributes for a given WebGPU program
  45174. * @param pipelineContext defines the pipeline context to use
  45175. * @param attributesNames defines the list of attribute names to get
  45176. * @returns an array of indices indicating the offset of each attribute
  45177. */
  45178. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45179. /**
  45180. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45181. * @param effect defines the effect to activate
  45182. */
  45183. enableEffect(effect: Nullable<Effect>): void;
  45184. /** @hidden */
  45185. _releaseEffect(effect: Effect): void;
  45186. /**
  45187. * 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
  45188. */
  45189. releaseEffects(): void;
  45190. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45191. /**
  45192. * Gets a boolean indicating that only power of 2 textures are supported
  45193. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45194. */
  45195. get needPOTTextures(): boolean;
  45196. /** @hidden */
  45197. _createHardwareTexture(): HardwareTextureWrapper;
  45198. /** @hidden */
  45199. _releaseTexture(texture: InternalTexture): void;
  45200. /** @hidden */
  45201. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45202. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45203. /**
  45204. * Usually called from Texture.ts.
  45205. * Passed information to create a hardware texture
  45206. * @param url defines a value which contains one of the following:
  45207. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45208. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45209. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45210. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45211. * @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)
  45212. * @param scene needed for loading to the correct scene
  45213. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45214. * @param onLoad optional callback to be called upon successful completion
  45215. * @param onError optional callback to be called upon failure
  45216. * @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
  45217. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45218. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45219. * @param forcedExtension defines the extension to use to pick the right loader
  45220. * @param mimeType defines an optional mime type
  45221. * @param loaderOptions options to be passed to the loader
  45222. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45223. */
  45224. 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;
  45225. /** @hidden */
  45226. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45227. /**
  45228. * Creates a cube texture
  45229. * @param rootUrl defines the url where the files to load is located
  45230. * @param scene defines the current scene
  45231. * @param files defines the list of files to load (1 per face)
  45232. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45233. * @param onLoad defines an optional callback raised when the texture is loaded
  45234. * @param onError defines an optional callback raised if there is an issue to load the texture
  45235. * @param format defines the format of the data
  45236. * @param forcedExtension defines the extension to use to pick the right loader
  45237. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45238. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45239. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45240. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45241. * @param loaderOptions options to be passed to the loader
  45242. * @returns the cube texture as an InternalTexture
  45243. */
  45244. 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;
  45245. /**
  45246. * Creates a raw texture
  45247. * @param data defines the data to store in the texture
  45248. * @param width defines the width of the texture
  45249. * @param height defines the height of the texture
  45250. * @param format defines the format of the data
  45251. * @param generateMipMaps defines if the engine should generate the mip levels
  45252. * @param invertY defines if data must be stored with Y axis inverted
  45253. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45254. * @param compression defines the compression used (null by default)
  45255. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45256. * @returns the raw texture inside an InternalTexture
  45257. */
  45258. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45259. /**
  45260. * Creates a new raw cube texture
  45261. * @param data defines the array of data to use to create each face
  45262. * @param size defines the size of the textures
  45263. * @param format defines the format of the data
  45264. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45265. * @param generateMipMaps defines if the engine should generate the mip levels
  45266. * @param invertY defines if data must be stored with Y axis inverted
  45267. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45268. * @param compression defines the compression used (null by default)
  45269. * @returns the cube texture as an InternalTexture
  45270. */
  45271. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45272. /**
  45273. * Creates a new raw cube texture from a specified url
  45274. * @param url defines the url where the data is located
  45275. * @param scene defines the current scene
  45276. * @param size defines the size of the textures
  45277. * @param format defines the format of the data
  45278. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45279. * @param noMipmap defines if the engine should avoid generating the mip levels
  45280. * @param callback defines a callback used to extract texture data from loaded data
  45281. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45282. * @param onLoad defines a callback called when texture is loaded
  45283. * @param onError defines a callback called if there is an error
  45284. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45285. * @param invertY defines if data must be stored with Y axis inverted
  45286. * @returns the cube texture as an InternalTexture
  45287. */
  45288. 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;
  45289. /**
  45290. * Creates a new raw 2D array texture
  45291. * @param data defines the data used to create the texture
  45292. * @param width defines the width of the texture
  45293. * @param height defines the height of the texture
  45294. * @param depth defines the number of layers of the texture
  45295. * @param format defines the format of the texture
  45296. * @param generateMipMaps defines if the engine must generate mip levels
  45297. * @param invertY defines if data must be stored with Y axis inverted
  45298. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45299. * @param compression defines the compressed used (can be null)
  45300. * @param textureType defines the compressed used (can be null)
  45301. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45302. */
  45303. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45304. /**
  45305. * Creates a new raw 3D texture
  45306. * @param data defines the data used to create the texture
  45307. * @param width defines the width of the texture
  45308. * @param height defines the height of the texture
  45309. * @param depth defines the depth of the texture
  45310. * @param format defines the format of the texture
  45311. * @param generateMipMaps defines if the engine must generate mip levels
  45312. * @param invertY defines if data must be stored with Y axis inverted
  45313. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45314. * @param compression defines the compressed used (can be null)
  45315. * @param textureType defines the compressed used (can be null)
  45316. * @returns a new raw 3D texture (stored in an InternalTexture)
  45317. */
  45318. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45319. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45320. /**
  45321. * Update the sampling mode of a given texture
  45322. * @param samplingMode defines the required sampling mode
  45323. * @param texture defines the texture to update
  45324. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45325. */
  45326. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45327. /**
  45328. * Update the sampling mode of a given texture
  45329. * @param texture defines the texture to update
  45330. * @param wrapU defines the texture wrap mode of the u coordinates
  45331. * @param wrapV defines the texture wrap mode of the v coordinates
  45332. * @param wrapR defines the texture wrap mode of the r coordinates
  45333. */
  45334. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45335. /**
  45336. * Update the dimensions of a texture
  45337. * @param texture texture to update
  45338. * @param width new width of the texture
  45339. * @param height new height of the texture
  45340. * @param depth new depth of the texture
  45341. */
  45342. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45343. private _setInternalTexture;
  45344. /**
  45345. * Sets a texture to the according uniform.
  45346. * @param channel The texture channel
  45347. * @param unused unused parameter
  45348. * @param texture The texture to apply
  45349. * @param name The name of the uniform in the effect
  45350. */
  45351. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45352. /**
  45353. * Sets an array of texture to the WebGPU context
  45354. * @param channel defines the channel where the texture array must be set
  45355. * @param unused unused parameter
  45356. * @param textures defines the array of textures to bind
  45357. * @param name name of the channel
  45358. */
  45359. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45360. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45361. /** @hidden */
  45362. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45363. /** @hidden */
  45364. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45365. private _generateMipmaps;
  45366. /**
  45367. * Update the content of a texture
  45368. * @param texture defines the texture to update
  45369. * @param canvas defines the source containing the data
  45370. * @param invertY defines if data must be stored with Y axis inverted
  45371. * @param premulAlpha defines if alpha is stored as premultiplied
  45372. * @param format defines the format of the data
  45373. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45374. */
  45375. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45376. /**
  45377. * Update a portion of an internal texture
  45378. * @param texture defines the texture to update
  45379. * @param imageData defines the data to store into the texture
  45380. * @param xOffset defines the x coordinates of the update rectangle
  45381. * @param yOffset defines the y coordinates of the update rectangle
  45382. * @param width defines the width of the update rectangle
  45383. * @param height defines the height of the update rectangle
  45384. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45385. * @param lod defines the lod level to update (0 by default)
  45386. */
  45387. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45388. /**
  45389. * Update a video texture
  45390. * @param texture defines the texture to update
  45391. * @param video defines the video element to use
  45392. * @param invertY defines if data must be stored with Y axis inverted
  45393. */
  45394. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45395. /** @hidden */
  45396. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45397. /** @hidden */
  45398. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45399. /** @hidden */
  45400. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45401. /** @hidden */
  45402. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45403. /**
  45404. * Update a raw texture
  45405. * @param texture defines the texture to update
  45406. * @param bufferView defines the data to store in the texture
  45407. * @param format defines the format of the data
  45408. * @param invertY defines if data must be stored with Y axis inverted
  45409. * @param compression defines the compression used (null by default)
  45410. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45411. */
  45412. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45413. /**
  45414. * Update a raw cube texture
  45415. * @param texture defines the texture to udpdate
  45416. * @param bufferView defines the data to store
  45417. * @param format defines the data format
  45418. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45419. * @param invertY defines if data must be stored with Y axis inverted
  45420. * @param compression defines the compression used (null by default)
  45421. * @param level defines which level of the texture to update
  45422. */
  45423. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45424. /**
  45425. * Update a raw 2D array texture
  45426. * @param texture defines the texture to update
  45427. * @param bufferView defines the data to store
  45428. * @param format defines the data format
  45429. * @param invertY defines if data must be stored with Y axis inverted
  45430. * @param compression defines the used compression (can be null)
  45431. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45432. */
  45433. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45434. /**
  45435. * Update a raw 3D texture
  45436. * @param texture defines the texture to update
  45437. * @param bufferView defines the data to store
  45438. * @param format defines the data format
  45439. * @param invertY defines if data must be stored with Y axis inverted
  45440. * @param compression defines the used compression (can be null)
  45441. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45442. */
  45443. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45444. /**
  45445. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45446. * @param x defines the x coordinate of the rectangle where pixels must be read
  45447. * @param y defines the y coordinate of the rectangle where pixels must be read
  45448. * @param width defines the width of the rectangle where pixels must be read
  45449. * @param height defines the height of the rectangle where pixels must be read
  45450. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45451. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45452. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45453. */
  45454. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45455. /** @hidden */
  45456. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45457. /**
  45458. * Creates a new render target texture
  45459. * @param size defines the size of the texture
  45460. * @param options defines the options used to create the texture
  45461. * @returns a new render target texture stored in an InternalTexture
  45462. */
  45463. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45464. /**
  45465. * Create a multi render target texture
  45466. * @param size defines the size of the texture
  45467. * @param options defines the creation options
  45468. * @returns the cube texture as an InternalTexture
  45469. */
  45470. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45471. /**
  45472. * Creates a new render target cube texture
  45473. * @param size defines the size of the texture
  45474. * @param options defines the options used to create the texture
  45475. * @returns a new render target cube texture stored in an InternalTexture
  45476. */
  45477. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45478. /** @hidden */
  45479. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45480. width: number;
  45481. height: number;
  45482. layers?: number;
  45483. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45484. /** @hidden */
  45485. _createDepthStencilTexture(size: number | {
  45486. width: number;
  45487. height: number;
  45488. layers?: number;
  45489. }, options: DepthTextureCreationOptions): InternalTexture;
  45490. /** @hidden */
  45491. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45492. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45493. /**
  45494. * Update the sample count for a given multiple render target texture
  45495. * @param textures defines the textures to update
  45496. * @param samples defines the sample count to set
  45497. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45498. */
  45499. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45500. /**
  45501. * Begin a new frame
  45502. */
  45503. beginFrame(): void;
  45504. /**
  45505. * End the current frame
  45506. */
  45507. endFrame(): void;
  45508. /**
  45509. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45510. */
  45511. flushFramebuffer(): void;
  45512. private _startRenderTargetRenderPass;
  45513. private _endRenderTargetRenderPass;
  45514. private _getCurrentRenderPass;
  45515. private _startMainRenderPass;
  45516. private _endMainRenderPass;
  45517. /**
  45518. * Restores the WebGPU state to only draw on the main color attachment
  45519. */
  45520. restoreSingleAttachment(): void;
  45521. /**
  45522. * Creates a layout object to draw/clear on specific textures in a MRT
  45523. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45524. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45525. */
  45526. buildTextureLayout(textureStatus: boolean[]): number[];
  45527. /**
  45528. * Select a subsets of attachments to draw to.
  45529. * @param attachments index of attachments
  45530. */
  45531. bindAttachments(attachments: number[]): void;
  45532. /**
  45533. * Binds the frame buffer to the specified texture.
  45534. * @param texture The texture to render to or null for the default canvas
  45535. * @param faceIndex The face of the texture to render to in case of cube texture
  45536. * @param requiredWidth The width of the target to render to
  45537. * @param requiredHeight The height of the target to render to
  45538. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45539. * @param lodLevel defines the lod level to bind to the frame buffer
  45540. * @param layer defines the 2d array index to bind to frame buffer to
  45541. */
  45542. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45543. /**
  45544. * Unbind the current render target texture from the WebGPU context
  45545. * @param texture defines the render target texture to unbind
  45546. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45547. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45548. */
  45549. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45550. /**
  45551. * Unbind a list of render target textures from the WebGPU context
  45552. * @param textures defines the render target textures to unbind
  45553. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45554. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45555. */
  45556. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45557. /**
  45558. * Unbind the current render target and bind the default framebuffer
  45559. */
  45560. restoreDefaultFramebuffer(): void;
  45561. setZOffset(value: number): void;
  45562. private _setColorFormat;
  45563. private _setDepthTextureFormat;
  45564. setDepthBuffer(enable: boolean): void;
  45565. setDepthWrite(enable: boolean): void;
  45566. setStencilBuffer(enable: boolean): void;
  45567. setStencilMask(mask: number): void;
  45568. setStencilFunction(stencilFunc: number): void;
  45569. setStencilFunctionReference(reference: number): void;
  45570. setStencilFunctionMask(mask: number): void;
  45571. setStencilOperationFail(operation: number): void;
  45572. setStencilOperationDepthFail(operation: number): void;
  45573. setStencilOperationPass(operation: number): void;
  45574. setDitheringState(value: boolean): void;
  45575. setRasterizerState(value: boolean): void;
  45576. setDepthFunction(depthFunc: number): void;
  45577. setDepthFunctionToGreater(): void;
  45578. setDepthFunctionToGreaterOrEqual(): void;
  45579. setDepthFunctionToLess(): void;
  45580. setDepthFunctionToLessOrEqual(): void;
  45581. /**
  45582. * Set various states to the context
  45583. * @param culling defines backface culling state
  45584. * @param zOffset defines the value to apply to zOffset (0 by default)
  45585. * @param force defines if states must be applied even if cache is up to date
  45586. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45587. */
  45588. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45589. /**
  45590. * Sets the current alpha mode
  45591. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45592. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45593. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45594. */
  45595. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45596. /**
  45597. * Sets the current alpha equation
  45598. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45599. */
  45600. setAlphaEquation(equation: number): void;
  45601. private _getBindGroupsToRender;
  45602. private _bindVertexInputs;
  45603. private _setRenderBindGroups;
  45604. private _setRenderPipeline;
  45605. /**
  45606. * Draw a list of indexed primitives
  45607. * @param fillMode defines the primitive to use
  45608. * @param indexStart defines the starting index
  45609. * @param indexCount defines the number of index to draw
  45610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45611. */
  45612. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45613. /**
  45614. * Draw a list of unindexed primitives
  45615. * @param fillMode defines the primitive to use
  45616. * @param verticesStart defines the index of first vertex to draw
  45617. * @param verticesCount defines the count of vertices to draw
  45618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45619. */
  45620. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45621. private _bundleEncoder;
  45622. /**
  45623. * Start recording all the gpu calls into a bundle.
  45624. */
  45625. startRecordBundle(): void;
  45626. /**
  45627. * Stops recording the bundle.
  45628. * @returns the recorded bundle
  45629. */
  45630. stopRecordBundle(): GPURenderBundle;
  45631. /**
  45632. * Execute the previously recorded bundle.
  45633. * @param bundles defines the bundle to replay
  45634. */
  45635. executeBundles(bundles: GPURenderBundle[]): void;
  45636. /**
  45637. * Dispose and release all associated resources
  45638. */
  45639. dispose(): void;
  45640. /**
  45641. * Gets the current render width
  45642. * @param useScreen defines if screen size must be used (or the current render target if any)
  45643. * @returns a number defining the current render width
  45644. */
  45645. getRenderWidth(useScreen?: boolean): number;
  45646. /**
  45647. * Gets the current render height
  45648. * @param useScreen defines if screen size must be used (or the current render target if any)
  45649. * @returns a number defining the current render height
  45650. */
  45651. getRenderHeight(useScreen?: boolean): number;
  45652. /**
  45653. * Gets the HTML canvas attached with the current WebGPU context
  45654. * @returns a HTML canvas
  45655. */
  45656. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45657. /** @hidden */
  45658. _debugPushGroup(groupName: string, targetObject?: number): void;
  45659. /** @hidden */
  45660. _debugPopGroup(targetObject?: number): void;
  45661. /** @hidden */
  45662. _debugInsertMarker(text: string, targetObject?: number): void;
  45663. private _debugFlushPendingCommands;
  45664. /**
  45665. * Get the current error code of the WebGPU context
  45666. * @returns the error code
  45667. */
  45668. getError(): number;
  45669. /** @hidden */
  45670. bindSamplers(effect: Effect): void;
  45671. /** @hidden */
  45672. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45673. /** @hidden */
  45674. _releaseFramebufferObjects(texture: InternalTexture): void;
  45675. /** @hidden */
  45676. applyStates(): void;
  45677. /**
  45678. * Gets a boolean indicating if all created effects are ready
  45679. * @returns always true - No parallel shader compilation
  45680. */
  45681. areAllEffectsReady(): boolean;
  45682. /** @hidden */
  45683. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45684. /** @hidden */
  45685. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45686. /** @hidden */
  45687. _getUnpackAlignement(): number;
  45688. /** @hidden */
  45689. _unpackFlipY(value: boolean): void;
  45690. /** @hidden */
  45691. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45692. min: number;
  45693. mag: number;
  45694. };
  45695. /** @hidden */
  45696. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45697. /** @hidden */
  45698. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45699. /** @hidden */
  45700. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45701. /** @hidden */
  45702. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45703. /** @hidden */
  45704. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45705. /** @hidden */
  45706. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45707. /** @hidden */
  45708. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45709. /** @hidden */
  45710. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45711. /** @hidden */
  45712. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45713. /** @hidden */
  45714. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45715. /** @hidden */
  45716. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45717. /** @hidden */
  45718. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45719. /** @hidden */
  45720. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45721. /** @hidden */
  45722. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45723. /** @hidden */
  45724. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45725. /** @hidden */
  45726. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45727. /** @hidden */
  45728. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45729. }
  45730. }
  45731. declare module BABYLON {
  45732. /**
  45733. * Define an interface for all classes that will hold resources
  45734. */
  45735. export interface IDisposable {
  45736. /**
  45737. * Releases all held resources
  45738. */
  45739. dispose(): void;
  45740. }
  45741. /** Interface defining initialization parameters for Scene class */
  45742. export interface SceneOptions {
  45743. /**
  45744. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45745. * It will improve performance when the number of geometries becomes important.
  45746. */
  45747. useGeometryUniqueIdsMap?: boolean;
  45748. /**
  45749. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45750. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45751. */
  45752. useMaterialMeshMap?: boolean;
  45753. /**
  45754. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45755. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45756. */
  45757. useClonedMeshMap?: boolean;
  45758. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45759. virtual?: boolean;
  45760. }
  45761. /**
  45762. * Represents a scene to be rendered by the engine.
  45763. * @see https://doc.babylonjs.com/features/scene
  45764. */
  45765. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45766. /** The fog is deactivated */
  45767. static readonly FOGMODE_NONE: number;
  45768. /** The fog density is following an exponential function */
  45769. static readonly FOGMODE_EXP: number;
  45770. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45771. static readonly FOGMODE_EXP2: number;
  45772. /** The fog density is following a linear function. */
  45773. static readonly FOGMODE_LINEAR: number;
  45774. /**
  45775. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45776. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45777. */
  45778. static MinDeltaTime: number;
  45779. /**
  45780. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45781. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45782. */
  45783. static MaxDeltaTime: number;
  45784. /**
  45785. * Factory used to create the default material.
  45786. * @param name The name of the material to create
  45787. * @param scene The scene to create the material for
  45788. * @returns The default material
  45789. */
  45790. static DefaultMaterialFactory(scene: Scene): Material;
  45791. /**
  45792. * Factory used to create the a collision coordinator.
  45793. * @returns The collision coordinator
  45794. */
  45795. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45796. /** @hidden */
  45797. _inputManager: InputManager;
  45798. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45799. cameraToUseForPointers: Nullable<Camera>;
  45800. /** @hidden */
  45801. readonly _isScene: boolean;
  45802. /** @hidden */
  45803. _blockEntityCollection: boolean;
  45804. /**
  45805. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45806. */
  45807. autoClear: boolean;
  45808. /**
  45809. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45810. */
  45811. autoClearDepthAndStencil: boolean;
  45812. /**
  45813. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45814. */
  45815. clearColor: Color4;
  45816. /**
  45817. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45818. */
  45819. ambientColor: Color3;
  45820. /**
  45821. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45822. * It should only be one of the following (if not the default embedded one):
  45823. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45824. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45825. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45826. * The material properties need to be setup according to the type of texture in use.
  45827. */
  45828. environmentBRDFTexture: BaseTexture;
  45829. /**
  45830. * Texture used in all pbr material as the reflection texture.
  45831. * As in the majority of the scene they are the same (exception for multi room and so on),
  45832. * this is easier to reference from here than from all the materials.
  45833. */
  45834. get environmentTexture(): Nullable<BaseTexture>;
  45835. /**
  45836. * Texture used in all pbr material as the reflection texture.
  45837. * As in the majority of the scene they are the same (exception for multi room and so on),
  45838. * this is easier to set here than in all the materials.
  45839. */
  45840. set environmentTexture(value: Nullable<BaseTexture>);
  45841. /** @hidden */
  45842. protected _environmentIntensity: number;
  45843. /**
  45844. * Intensity of the environment in all pbr material.
  45845. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45846. * As in the majority of the scene they are the same (exception for multi room and so on),
  45847. * this is easier to reference from here than from all the materials.
  45848. */
  45849. get environmentIntensity(): number;
  45850. /**
  45851. * Intensity of the environment in all pbr material.
  45852. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45853. * As in the majority of the scene they are the same (exception for multi room and so on),
  45854. * this is easier to set here than in all the materials.
  45855. */
  45856. set environmentIntensity(value: number);
  45857. /** @hidden */
  45858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45859. /**
  45860. * Default image processing configuration used either in the rendering
  45861. * Forward main pass or through the imageProcessingPostProcess if present.
  45862. * As in the majority of the scene they are the same (exception for multi camera),
  45863. * this is easier to reference from here than from all the materials and post process.
  45864. *
  45865. * No setter as we it is a shared configuration, you can set the values instead.
  45866. */
  45867. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45868. private _forceWireframe;
  45869. /**
  45870. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45871. */
  45872. set forceWireframe(value: boolean);
  45873. get forceWireframe(): boolean;
  45874. private _skipFrustumClipping;
  45875. /**
  45876. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45877. */
  45878. set skipFrustumClipping(value: boolean);
  45879. get skipFrustumClipping(): boolean;
  45880. private _forcePointsCloud;
  45881. /**
  45882. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45883. */
  45884. set forcePointsCloud(value: boolean);
  45885. get forcePointsCloud(): boolean;
  45886. /**
  45887. * Gets or sets the active clipplane 1
  45888. */
  45889. clipPlane: Nullable<Plane>;
  45890. /**
  45891. * Gets or sets the active clipplane 2
  45892. */
  45893. clipPlane2: Nullable<Plane>;
  45894. /**
  45895. * Gets or sets the active clipplane 3
  45896. */
  45897. clipPlane3: Nullable<Plane>;
  45898. /**
  45899. * Gets or sets the active clipplane 4
  45900. */
  45901. clipPlane4: Nullable<Plane>;
  45902. /**
  45903. * Gets or sets the active clipplane 5
  45904. */
  45905. clipPlane5: Nullable<Plane>;
  45906. /**
  45907. * Gets or sets the active clipplane 6
  45908. */
  45909. clipPlane6: Nullable<Plane>;
  45910. /**
  45911. * Gets or sets a boolean indicating if animations are enabled
  45912. */
  45913. animationsEnabled: boolean;
  45914. private _animationPropertiesOverride;
  45915. /**
  45916. * Gets or sets the animation properties override
  45917. */
  45918. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45919. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45920. /**
  45921. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45922. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45923. */
  45924. useConstantAnimationDeltaTime: boolean;
  45925. /**
  45926. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45927. * Please note that it requires to run a ray cast through the scene on every frame
  45928. */
  45929. constantlyUpdateMeshUnderPointer: boolean;
  45930. /**
  45931. * Defines the HTML cursor to use when hovering over interactive elements
  45932. */
  45933. hoverCursor: string;
  45934. /**
  45935. * Defines the HTML default cursor to use (empty by default)
  45936. */
  45937. defaultCursor: string;
  45938. /**
  45939. * Defines whether cursors are handled by the scene.
  45940. */
  45941. doNotHandleCursors: boolean;
  45942. /**
  45943. * This is used to call preventDefault() on pointer down
  45944. * in order to block unwanted artifacts like system double clicks
  45945. */
  45946. preventDefaultOnPointerDown: boolean;
  45947. /**
  45948. * This is used to call preventDefault() on pointer up
  45949. * in order to block unwanted artifacts like system double clicks
  45950. */
  45951. preventDefaultOnPointerUp: boolean;
  45952. /**
  45953. * Gets or sets user defined metadata
  45954. */
  45955. metadata: any;
  45956. /**
  45957. * For internal use only. Please do not use.
  45958. */
  45959. reservedDataStore: any;
  45960. /**
  45961. * Gets the name of the plugin used to load this scene (null by default)
  45962. */
  45963. loadingPluginName: string;
  45964. /**
  45965. * Use this array to add regular expressions used to disable offline support for specific urls
  45966. */
  45967. disableOfflineSupportExceptionRules: RegExp[];
  45968. /**
  45969. * An event triggered when the scene is disposed.
  45970. */
  45971. onDisposeObservable: Observable<Scene>;
  45972. private _onDisposeObserver;
  45973. /** Sets a function to be executed when this scene is disposed. */
  45974. set onDispose(callback: () => void);
  45975. /**
  45976. * An event triggered before rendering the scene (right after animations and physics)
  45977. */
  45978. onBeforeRenderObservable: Observable<Scene>;
  45979. private _onBeforeRenderObserver;
  45980. /** Sets a function to be executed before rendering this scene */
  45981. set beforeRender(callback: Nullable<() => void>);
  45982. /**
  45983. * An event triggered after rendering the scene
  45984. */
  45985. onAfterRenderObservable: Observable<Scene>;
  45986. /**
  45987. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  45988. */
  45989. onAfterRenderCameraObservable: Observable<Camera>;
  45990. private _onAfterRenderObserver;
  45991. /** Sets a function to be executed after rendering this scene */
  45992. set afterRender(callback: Nullable<() => void>);
  45993. /**
  45994. * An event triggered before animating the scene
  45995. */
  45996. onBeforeAnimationsObservable: Observable<Scene>;
  45997. /**
  45998. * An event triggered after animations processing
  45999. */
  46000. onAfterAnimationsObservable: Observable<Scene>;
  46001. /**
  46002. * An event triggered before draw calls are ready to be sent
  46003. */
  46004. onBeforeDrawPhaseObservable: Observable<Scene>;
  46005. /**
  46006. * An event triggered after draw calls have been sent
  46007. */
  46008. onAfterDrawPhaseObservable: Observable<Scene>;
  46009. /**
  46010. * An event triggered when the scene is ready
  46011. */
  46012. onReadyObservable: Observable<Scene>;
  46013. /**
  46014. * An event triggered before rendering a camera
  46015. */
  46016. onBeforeCameraRenderObservable: Observable<Camera>;
  46017. private _onBeforeCameraRenderObserver;
  46018. /** Sets a function to be executed before rendering a camera*/
  46019. set beforeCameraRender(callback: () => void);
  46020. /**
  46021. * An event triggered after rendering a camera
  46022. */
  46023. onAfterCameraRenderObservable: Observable<Camera>;
  46024. private _onAfterCameraRenderObserver;
  46025. /** Sets a function to be executed after rendering a camera*/
  46026. set afterCameraRender(callback: () => void);
  46027. /**
  46028. * An event triggered when active meshes evaluation is about to start
  46029. */
  46030. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46031. /**
  46032. * An event triggered when active meshes evaluation is done
  46033. */
  46034. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46035. /**
  46036. * An event triggered when particles rendering is about to start
  46037. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46038. */
  46039. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46040. /**
  46041. * An event triggered when particles rendering is done
  46042. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46043. */
  46044. onAfterParticlesRenderingObservable: Observable<Scene>;
  46045. /**
  46046. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46047. */
  46048. onDataLoadedObservable: Observable<Scene>;
  46049. /**
  46050. * An event triggered when a camera is created
  46051. */
  46052. onNewCameraAddedObservable: Observable<Camera>;
  46053. /**
  46054. * An event triggered when a camera is removed
  46055. */
  46056. onCameraRemovedObservable: Observable<Camera>;
  46057. /**
  46058. * An event triggered when a light is created
  46059. */
  46060. onNewLightAddedObservable: Observable<Light>;
  46061. /**
  46062. * An event triggered when a light is removed
  46063. */
  46064. onLightRemovedObservable: Observable<Light>;
  46065. /**
  46066. * An event triggered when a geometry is created
  46067. */
  46068. onNewGeometryAddedObservable: Observable<Geometry>;
  46069. /**
  46070. * An event triggered when a geometry is removed
  46071. */
  46072. onGeometryRemovedObservable: Observable<Geometry>;
  46073. /**
  46074. * An event triggered when a transform node is created
  46075. */
  46076. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46077. /**
  46078. * An event triggered when a transform node is removed
  46079. */
  46080. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46081. /**
  46082. * An event triggered when a mesh is created
  46083. */
  46084. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46085. /**
  46086. * An event triggered when a mesh is removed
  46087. */
  46088. onMeshRemovedObservable: Observable<AbstractMesh>;
  46089. /**
  46090. * An event triggered when a skeleton is created
  46091. */
  46092. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46093. /**
  46094. * An event triggered when a skeleton is removed
  46095. */
  46096. onSkeletonRemovedObservable: Observable<Skeleton>;
  46097. /**
  46098. * An event triggered when a material is created
  46099. */
  46100. onNewMaterialAddedObservable: Observable<Material>;
  46101. /**
  46102. * An event triggered when a multi material is created
  46103. */
  46104. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46105. /**
  46106. * An event triggered when a material is removed
  46107. */
  46108. onMaterialRemovedObservable: Observable<Material>;
  46109. /**
  46110. * An event triggered when a multi material is removed
  46111. */
  46112. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46113. /**
  46114. * An event triggered when a texture is created
  46115. */
  46116. onNewTextureAddedObservable: Observable<BaseTexture>;
  46117. /**
  46118. * An event triggered when a texture is removed
  46119. */
  46120. onTextureRemovedObservable: Observable<BaseTexture>;
  46121. /**
  46122. * An event triggered when render targets are about to be rendered
  46123. * Can happen multiple times per frame.
  46124. */
  46125. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46126. /**
  46127. * An event triggered when render targets were rendered.
  46128. * Can happen multiple times per frame.
  46129. */
  46130. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46131. /**
  46132. * An event triggered before calculating deterministic simulation step
  46133. */
  46134. onBeforeStepObservable: Observable<Scene>;
  46135. /**
  46136. * An event triggered after calculating deterministic simulation step
  46137. */
  46138. onAfterStepObservable: Observable<Scene>;
  46139. /**
  46140. * An event triggered when the activeCamera property is updated
  46141. */
  46142. onActiveCameraChanged: Observable<Scene>;
  46143. /**
  46144. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46145. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46146. * 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)
  46147. */
  46148. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46149. /**
  46150. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46151. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46152. * 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)
  46153. */
  46154. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46155. /**
  46156. * This Observable will when a mesh has been imported into the scene.
  46157. */
  46158. onMeshImportedObservable: Observable<AbstractMesh>;
  46159. /**
  46160. * This Observable will when an animation file has been imported into the scene.
  46161. */
  46162. onAnimationFileImportedObservable: Observable<Scene>;
  46163. /**
  46164. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46165. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46166. */
  46167. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46168. /** @hidden */
  46169. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46170. /**
  46171. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46172. */
  46173. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46174. /**
  46175. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46176. */
  46177. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46178. /**
  46179. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46180. */
  46181. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46182. /** Callback called when a pointer move is detected */
  46183. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46184. /** Callback called when a pointer down is detected */
  46185. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46186. /** Callback called when a pointer up is detected */
  46187. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46188. /** Callback called when a pointer pick is detected */
  46189. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46190. /**
  46191. * 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).
  46192. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46193. */
  46194. onPrePointerObservable: Observable<PointerInfoPre>;
  46195. /**
  46196. * Observable event triggered each time an input event is received from the rendering canvas
  46197. */
  46198. onPointerObservable: Observable<PointerInfo>;
  46199. /**
  46200. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46201. */
  46202. get unTranslatedPointer(): Vector2;
  46203. /**
  46204. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46205. */
  46206. static get DragMovementThreshold(): number;
  46207. static set DragMovementThreshold(value: number);
  46208. /**
  46209. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46210. */
  46211. static get LongPressDelay(): number;
  46212. static set LongPressDelay(value: number);
  46213. /**
  46214. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46215. */
  46216. static get DoubleClickDelay(): number;
  46217. static set DoubleClickDelay(value: number);
  46218. /** If you need to check double click without raising a single click at first click, enable this flag */
  46219. static get ExclusiveDoubleClickMode(): boolean;
  46220. static set ExclusiveDoubleClickMode(value: boolean);
  46221. /** @hidden */
  46222. _mirroredCameraPosition: Nullable<Vector3>;
  46223. /**
  46224. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46225. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46226. */
  46227. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46228. /**
  46229. * Observable event triggered each time an keyboard event is received from the hosting window
  46230. */
  46231. onKeyboardObservable: Observable<KeyboardInfo>;
  46232. private _useRightHandedSystem;
  46233. /**
  46234. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46235. */
  46236. set useRightHandedSystem(value: boolean);
  46237. get useRightHandedSystem(): boolean;
  46238. private _timeAccumulator;
  46239. private _currentStepId;
  46240. private _currentInternalStep;
  46241. /**
  46242. * Sets the step Id used by deterministic lock step
  46243. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46244. * @param newStepId defines the step Id
  46245. */
  46246. setStepId(newStepId: number): void;
  46247. /**
  46248. * Gets the step Id used by deterministic lock step
  46249. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46250. * @returns the step Id
  46251. */
  46252. getStepId(): number;
  46253. /**
  46254. * Gets the internal step used by deterministic lock step
  46255. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46256. * @returns the internal step
  46257. */
  46258. getInternalStep(): number;
  46259. private _fogEnabled;
  46260. /**
  46261. * Gets or sets a boolean indicating if fog is enabled on this scene
  46262. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46263. * (Default is true)
  46264. */
  46265. set fogEnabled(value: boolean);
  46266. get fogEnabled(): boolean;
  46267. private _fogMode;
  46268. /**
  46269. * Gets or sets the fog mode to use
  46270. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46271. * | mode | value |
  46272. * | --- | --- |
  46273. * | FOGMODE_NONE | 0 |
  46274. * | FOGMODE_EXP | 1 |
  46275. * | FOGMODE_EXP2 | 2 |
  46276. * | FOGMODE_LINEAR | 3 |
  46277. */
  46278. set fogMode(value: number);
  46279. get fogMode(): number;
  46280. /**
  46281. * Gets or sets the fog color to use
  46282. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46283. * (Default is Color3(0.2, 0.2, 0.3))
  46284. */
  46285. fogColor: Color3;
  46286. /**
  46287. * Gets or sets the fog density to use
  46288. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46289. * (Default is 0.1)
  46290. */
  46291. fogDensity: number;
  46292. /**
  46293. * Gets or sets the fog start distance to use
  46294. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46295. * (Default is 0)
  46296. */
  46297. fogStart: number;
  46298. /**
  46299. * Gets or sets the fog end distance to use
  46300. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46301. * (Default is 1000)
  46302. */
  46303. fogEnd: number;
  46304. /**
  46305. * Flag indicating that the frame buffer binding is handled by another component
  46306. */
  46307. prePass: boolean;
  46308. private _shadowsEnabled;
  46309. /**
  46310. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46311. */
  46312. set shadowsEnabled(value: boolean);
  46313. get shadowsEnabled(): boolean;
  46314. private _lightsEnabled;
  46315. /**
  46316. * Gets or sets a boolean indicating if lights are enabled on this scene
  46317. */
  46318. set lightsEnabled(value: boolean);
  46319. get lightsEnabled(): boolean;
  46320. /** All of the active cameras added to this scene. */
  46321. activeCameras: Nullable<Camera[]>;
  46322. /** @hidden */
  46323. _activeCamera: Nullable<Camera>;
  46324. /** Gets or sets the current active camera */
  46325. get activeCamera(): Nullable<Camera>;
  46326. set activeCamera(value: Nullable<Camera>);
  46327. private _defaultMaterial;
  46328. /** The default material used on meshes when no material is affected */
  46329. get defaultMaterial(): Material;
  46330. /** The default material used on meshes when no material is affected */
  46331. set defaultMaterial(value: Material);
  46332. private _texturesEnabled;
  46333. /**
  46334. * Gets or sets a boolean indicating if textures are enabled on this scene
  46335. */
  46336. set texturesEnabled(value: boolean);
  46337. get texturesEnabled(): boolean;
  46338. /**
  46339. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46340. */
  46341. physicsEnabled: boolean;
  46342. /**
  46343. * Gets or sets a boolean indicating if particles are enabled on this scene
  46344. */
  46345. particlesEnabled: boolean;
  46346. /**
  46347. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46348. */
  46349. spritesEnabled: boolean;
  46350. private _skeletonsEnabled;
  46351. /**
  46352. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46353. */
  46354. set skeletonsEnabled(value: boolean);
  46355. get skeletonsEnabled(): boolean;
  46356. /**
  46357. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46358. */
  46359. lensFlaresEnabled: boolean;
  46360. /**
  46361. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46362. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46363. */
  46364. collisionsEnabled: boolean;
  46365. private _collisionCoordinator;
  46366. /** @hidden */
  46367. get collisionCoordinator(): ICollisionCoordinator;
  46368. /**
  46369. * Defines the gravity applied to this scene (used only for collisions)
  46370. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46371. */
  46372. gravity: Vector3;
  46373. /**
  46374. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46375. */
  46376. postProcessesEnabled: boolean;
  46377. /**
  46378. * Gets the current postprocess manager
  46379. */
  46380. postProcessManager: PostProcessManager;
  46381. /**
  46382. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46383. */
  46384. renderTargetsEnabled: boolean;
  46385. /**
  46386. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46387. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46388. */
  46389. dumpNextRenderTargets: boolean;
  46390. /**
  46391. * The list of user defined render targets added to the scene
  46392. */
  46393. customRenderTargets: RenderTargetTexture[];
  46394. /**
  46395. * Defines if texture loading must be delayed
  46396. * If true, textures will only be loaded when they need to be rendered
  46397. */
  46398. useDelayedTextureLoading: boolean;
  46399. /**
  46400. * Gets the list of meshes imported to the scene through SceneLoader
  46401. */
  46402. importedMeshesFiles: String[];
  46403. /**
  46404. * Gets or sets a boolean indicating if probes are enabled on this scene
  46405. */
  46406. probesEnabled: boolean;
  46407. /**
  46408. * Gets or sets the current offline provider to use to store scene data
  46409. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46410. */
  46411. offlineProvider: IOfflineProvider;
  46412. /**
  46413. * Gets or sets the action manager associated with the scene
  46414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46415. */
  46416. actionManager: AbstractActionManager;
  46417. private _meshesForIntersections;
  46418. /**
  46419. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46420. */
  46421. proceduralTexturesEnabled: boolean;
  46422. private _engine;
  46423. private _totalVertices;
  46424. /** @hidden */
  46425. _activeIndices: PerfCounter;
  46426. /** @hidden */
  46427. _activeParticles: PerfCounter;
  46428. /** @hidden */
  46429. _activeBones: PerfCounter;
  46430. private _animationRatio;
  46431. /** @hidden */
  46432. _animationTimeLast: number;
  46433. /** @hidden */
  46434. _animationTime: number;
  46435. /**
  46436. * Gets or sets a general scale for animation speed
  46437. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46438. */
  46439. animationTimeScale: number;
  46440. /** @hidden */
  46441. _cachedMaterial: Nullable<Material>;
  46442. /** @hidden */
  46443. _cachedEffect: Nullable<Effect>;
  46444. /** @hidden */
  46445. _cachedVisibility: Nullable<number>;
  46446. private _renderId;
  46447. private _frameId;
  46448. private _executeWhenReadyTimeoutId;
  46449. private _intermediateRendering;
  46450. private _viewUpdateFlag;
  46451. private _projectionUpdateFlag;
  46452. /** @hidden */
  46453. _toBeDisposed: Nullable<IDisposable>[];
  46454. private _activeRequests;
  46455. /** @hidden */
  46456. _pendingData: any[];
  46457. private _isDisposed;
  46458. /**
  46459. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46460. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46461. */
  46462. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46463. private _activeMeshes;
  46464. private _processedMaterials;
  46465. private _renderTargets;
  46466. /** @hidden */
  46467. _activeParticleSystems: SmartArray<IParticleSystem>;
  46468. private _activeSkeletons;
  46469. private _softwareSkinnedMeshes;
  46470. private _renderingManager;
  46471. /** @hidden */
  46472. _activeAnimatables: Animatable[];
  46473. private _transformMatrix;
  46474. private _sceneUbo;
  46475. /** @hidden */
  46476. _viewMatrix: Matrix;
  46477. /** @hidden */
  46478. _projectionMatrix: Matrix;
  46479. /** @hidden */
  46480. _forcedViewPosition: Nullable<Vector3>;
  46481. /** @hidden */
  46482. _frustumPlanes: Plane[];
  46483. /**
  46484. * Gets the list of frustum planes (built from the active camera)
  46485. */
  46486. get frustumPlanes(): Plane[];
  46487. /**
  46488. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46489. * This is useful if there are more lights that the maximum simulteanous authorized
  46490. */
  46491. requireLightSorting: boolean;
  46492. /** @hidden */
  46493. readonly useMaterialMeshMap: boolean;
  46494. /** @hidden */
  46495. readonly useClonedMeshMap: boolean;
  46496. private _externalData;
  46497. private _uid;
  46498. /**
  46499. * @hidden
  46500. * Backing store of defined scene components.
  46501. */
  46502. _components: ISceneComponent[];
  46503. /**
  46504. * @hidden
  46505. * Backing store of defined scene components.
  46506. */
  46507. _serializableComponents: ISceneSerializableComponent[];
  46508. /**
  46509. * List of components to register on the next registration step.
  46510. */
  46511. private _transientComponents;
  46512. /**
  46513. * Registers the transient components if needed.
  46514. */
  46515. private _registerTransientComponents;
  46516. /**
  46517. * @hidden
  46518. * Add a component to the scene.
  46519. * Note that the ccomponent could be registered on th next frame if this is called after
  46520. * the register component stage.
  46521. * @param component Defines the component to add to the scene
  46522. */
  46523. _addComponent(component: ISceneComponent): void;
  46524. /**
  46525. * @hidden
  46526. * Gets a component from the scene.
  46527. * @param name defines the name of the component to retrieve
  46528. * @returns the component or null if not present
  46529. */
  46530. _getComponent(name: string): Nullable<ISceneComponent>;
  46531. /**
  46532. * @hidden
  46533. * Defines the actions happening before camera updates.
  46534. */
  46535. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46536. /**
  46537. * @hidden
  46538. * Defines the actions happening before clear the canvas.
  46539. */
  46540. _beforeClearStage: Stage<SimpleStageAction>;
  46541. /**
  46542. * @hidden
  46543. * Defines the actions when collecting render targets for the frame.
  46544. */
  46545. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46546. /**
  46547. * @hidden
  46548. * Defines the actions happening for one camera in the frame.
  46549. */
  46550. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46551. /**
  46552. * @hidden
  46553. * Defines the actions happening during the per mesh ready checks.
  46554. */
  46555. _isReadyForMeshStage: Stage<MeshStageAction>;
  46556. /**
  46557. * @hidden
  46558. * Defines the actions happening before evaluate active mesh checks.
  46559. */
  46560. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46561. /**
  46562. * @hidden
  46563. * Defines the actions happening during the evaluate sub mesh checks.
  46564. */
  46565. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46566. /**
  46567. * @hidden
  46568. * Defines the actions happening during the active mesh stage.
  46569. */
  46570. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46571. /**
  46572. * @hidden
  46573. * Defines the actions happening during the per camera render target step.
  46574. */
  46575. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46576. /**
  46577. * @hidden
  46578. * Defines the actions happening just before the active camera is drawing.
  46579. */
  46580. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46581. /**
  46582. * @hidden
  46583. * Defines the actions happening just before a render target is drawing.
  46584. */
  46585. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46586. /**
  46587. * @hidden
  46588. * Defines the actions happening just before a rendering group is drawing.
  46589. */
  46590. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46591. /**
  46592. * @hidden
  46593. * Defines the actions happening just before a mesh is drawing.
  46594. */
  46595. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46596. /**
  46597. * @hidden
  46598. * Defines the actions happening just after a mesh has been drawn.
  46599. */
  46600. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46601. /**
  46602. * @hidden
  46603. * Defines the actions happening just after a rendering group has been drawn.
  46604. */
  46605. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46606. /**
  46607. * @hidden
  46608. * Defines the actions happening just after the active camera has been drawn.
  46609. */
  46610. _afterCameraDrawStage: Stage<CameraStageAction>;
  46611. /**
  46612. * @hidden
  46613. * Defines the actions happening just after a render target has been drawn.
  46614. */
  46615. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46616. /**
  46617. * @hidden
  46618. * Defines the actions happening just after rendering all cameras and computing intersections.
  46619. */
  46620. _afterRenderStage: Stage<SimpleStageAction>;
  46621. /**
  46622. * @hidden
  46623. * Defines the actions happening when a pointer move event happens.
  46624. */
  46625. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46626. /**
  46627. * @hidden
  46628. * Defines the actions happening when a pointer down event happens.
  46629. */
  46630. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46631. /**
  46632. * @hidden
  46633. * Defines the actions happening when a pointer up event happens.
  46634. */
  46635. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46636. /**
  46637. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46638. */
  46639. private geometriesByUniqueId;
  46640. private _renderBundles;
  46641. /**
  46642. * Creates a new Scene
  46643. * @param engine defines the engine to use to render this scene
  46644. * @param options defines the scene options
  46645. */
  46646. constructor(engine: Engine, options?: SceneOptions);
  46647. /**
  46648. * Gets a string identifying the name of the class
  46649. * @returns "Scene" string
  46650. */
  46651. getClassName(): string;
  46652. private _defaultMeshCandidates;
  46653. /**
  46654. * @hidden
  46655. */
  46656. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46657. private _defaultSubMeshCandidates;
  46658. /**
  46659. * @hidden
  46660. */
  46661. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46662. /**
  46663. * Sets the default candidate providers for the scene.
  46664. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46665. * and getCollidingSubMeshCandidates to their default function
  46666. */
  46667. setDefaultCandidateProviders(): void;
  46668. /**
  46669. * Gets the mesh that is currently under the pointer
  46670. */
  46671. get meshUnderPointer(): Nullable<AbstractMesh>;
  46672. /**
  46673. * Gets or sets the current on-screen X position of the pointer
  46674. */
  46675. get pointerX(): number;
  46676. set pointerX(value: number);
  46677. /**
  46678. * Gets or sets the current on-screen Y position of the pointer
  46679. */
  46680. get pointerY(): number;
  46681. set pointerY(value: number);
  46682. /**
  46683. * Gets the cached material (ie. the latest rendered one)
  46684. * @returns the cached material
  46685. */
  46686. getCachedMaterial(): Nullable<Material>;
  46687. /**
  46688. * Gets the cached effect (ie. the latest rendered one)
  46689. * @returns the cached effect
  46690. */
  46691. getCachedEffect(): Nullable<Effect>;
  46692. /**
  46693. * Gets the cached visibility state (ie. the latest rendered one)
  46694. * @returns the cached visibility state
  46695. */
  46696. getCachedVisibility(): Nullable<number>;
  46697. /**
  46698. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46699. * @param material defines the current material
  46700. * @param effect defines the current effect
  46701. * @param visibility defines the current visibility state
  46702. * @returns true if one parameter is not cached
  46703. */
  46704. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46705. /**
  46706. * Gets the engine associated with the scene
  46707. * @returns an Engine
  46708. */
  46709. getEngine(): Engine;
  46710. /**
  46711. * Gets the total number of vertices rendered per frame
  46712. * @returns the total number of vertices rendered per frame
  46713. */
  46714. getTotalVertices(): number;
  46715. /**
  46716. * Gets the performance counter for total vertices
  46717. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46718. */
  46719. get totalVerticesPerfCounter(): PerfCounter;
  46720. /**
  46721. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46722. * @returns the total number of active indices rendered per frame
  46723. */
  46724. getActiveIndices(): number;
  46725. /**
  46726. * Gets the performance counter for active indices
  46727. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46728. */
  46729. get totalActiveIndicesPerfCounter(): PerfCounter;
  46730. /**
  46731. * Gets the total number of active particles rendered per frame
  46732. * @returns the total number of active particles rendered per frame
  46733. */
  46734. getActiveParticles(): number;
  46735. /**
  46736. * Gets the performance counter for active particles
  46737. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46738. */
  46739. get activeParticlesPerfCounter(): PerfCounter;
  46740. /**
  46741. * Gets the total number of active bones rendered per frame
  46742. * @returns the total number of active bones rendered per frame
  46743. */
  46744. getActiveBones(): number;
  46745. /**
  46746. * Gets the performance counter for active bones
  46747. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46748. */
  46749. get activeBonesPerfCounter(): PerfCounter;
  46750. /**
  46751. * Gets the array of active meshes
  46752. * @returns an array of AbstractMesh
  46753. */
  46754. getActiveMeshes(): SmartArray<AbstractMesh>;
  46755. /**
  46756. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46757. * @returns a number
  46758. */
  46759. getAnimationRatio(): number;
  46760. /**
  46761. * Gets an unique Id for the current render phase
  46762. * @returns a number
  46763. */
  46764. getRenderId(): number;
  46765. /**
  46766. * Gets an unique Id for the current frame
  46767. * @returns a number
  46768. */
  46769. getFrameId(): number;
  46770. /** Call this function if you want to manually increment the render Id*/
  46771. incrementRenderId(): void;
  46772. private _createUbo;
  46773. /**
  46774. * Use this method to simulate a pointer move on a mesh
  46775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46778. * @returns the current scene
  46779. */
  46780. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46781. /**
  46782. * Use this method to simulate a pointer down on a mesh
  46783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46786. * @returns the current scene
  46787. */
  46788. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46789. /**
  46790. * Use this method to simulate a pointer up on a mesh
  46791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46794. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46795. * @returns the current scene
  46796. */
  46797. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46798. /**
  46799. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46800. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46801. * @returns true if the pointer was captured
  46802. */
  46803. isPointerCaptured(pointerId?: number): boolean;
  46804. /**
  46805. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46806. * @param attachUp defines if you want to attach events to pointerup
  46807. * @param attachDown defines if you want to attach events to pointerdown
  46808. * @param attachMove defines if you want to attach events to pointermove
  46809. */
  46810. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46811. /** Detaches all event handlers*/
  46812. detachControl(): void;
  46813. /**
  46814. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46815. * Delay loaded resources are not taking in account
  46816. * @return true if all required resources are ready
  46817. */
  46818. isReady(): boolean;
  46819. /** Resets all cached information relative to material (including effect and visibility) */
  46820. resetCachedMaterial(): void;
  46821. /**
  46822. * Registers a function to be called before every frame render
  46823. * @param func defines the function to register
  46824. */
  46825. registerBeforeRender(func: () => void): void;
  46826. /**
  46827. * Unregisters a function called before every frame render
  46828. * @param func defines the function to unregister
  46829. */
  46830. unregisterBeforeRender(func: () => void): void;
  46831. /**
  46832. * Registers a function to be called after every frame render
  46833. * @param func defines the function to register
  46834. */
  46835. registerAfterRender(func: () => void): void;
  46836. /**
  46837. * Unregisters a function called after every frame render
  46838. * @param func defines the function to unregister
  46839. */
  46840. unregisterAfterRender(func: () => void): void;
  46841. private _executeOnceBeforeRender;
  46842. /**
  46843. * The provided function will run before render once and will be disposed afterwards.
  46844. * A timeout delay can be provided so that the function will be executed in N ms.
  46845. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46846. * @param func The function to be executed.
  46847. * @param timeout optional delay in ms
  46848. */
  46849. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46850. /** @hidden */
  46851. _addPendingData(data: any): void;
  46852. /** @hidden */
  46853. _removePendingData(data: any): void;
  46854. /**
  46855. * Returns the number of items waiting to be loaded
  46856. * @returns the number of items waiting to be loaded
  46857. */
  46858. getWaitingItemsCount(): number;
  46859. /**
  46860. * Returns a boolean indicating if the scene is still loading data
  46861. */
  46862. get isLoading(): boolean;
  46863. /**
  46864. * Registers a function to be executed when the scene is ready
  46865. * @param {Function} func - the function to be executed
  46866. */
  46867. executeWhenReady(func: () => void): void;
  46868. /**
  46869. * Returns a promise that resolves when the scene is ready
  46870. * @returns A promise that resolves when the scene is ready
  46871. */
  46872. whenReadyAsync(): Promise<void>;
  46873. /** @hidden */
  46874. _checkIsReady(): void;
  46875. /**
  46876. * Gets all animatable attached to the scene
  46877. */
  46878. get animatables(): Animatable[];
  46879. /**
  46880. * Resets the last animation time frame.
  46881. * Useful to override when animations start running when loading a scene for the first time.
  46882. */
  46883. resetLastAnimationTimeFrame(): void;
  46884. /**
  46885. * Gets the current view matrix
  46886. * @returns a Matrix
  46887. */
  46888. getViewMatrix(): Matrix;
  46889. /**
  46890. * Gets the current projection matrix
  46891. * @returns a Matrix
  46892. */
  46893. getProjectionMatrix(): Matrix;
  46894. /**
  46895. * Gets the current transform matrix
  46896. * @returns a Matrix made of View * Projection
  46897. */
  46898. getTransformMatrix(): Matrix;
  46899. /**
  46900. * Sets the current transform matrix
  46901. * @param viewL defines the View matrix to use
  46902. * @param projectionL defines the Projection matrix to use
  46903. * @param viewR defines the right View matrix to use (if provided)
  46904. * @param projectionR defines the right Projection matrix to use (if provided)
  46905. */
  46906. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46907. /**
  46908. * Gets the uniform buffer used to store scene data
  46909. * @returns a UniformBuffer
  46910. */
  46911. getSceneUniformBuffer(): UniformBuffer;
  46912. /**
  46913. * Gets an unique (relatively to the current scene) Id
  46914. * @returns an unique number for the scene
  46915. */
  46916. getUniqueId(): number;
  46917. /**
  46918. * Add a mesh to the list of scene's meshes
  46919. * @param newMesh defines the mesh to add
  46920. * @param recursive if all child meshes should also be added to the scene
  46921. */
  46922. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46923. /**
  46924. * Remove a mesh for the list of scene's meshes
  46925. * @param toRemove defines the mesh to remove
  46926. * @param recursive if all child meshes should also be removed from the scene
  46927. * @returns the index where the mesh was in the mesh list
  46928. */
  46929. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46930. /**
  46931. * Add a transform node to the list of scene's transform nodes
  46932. * @param newTransformNode defines the transform node to add
  46933. */
  46934. addTransformNode(newTransformNode: TransformNode): void;
  46935. /**
  46936. * Remove a transform node for the list of scene's transform nodes
  46937. * @param toRemove defines the transform node to remove
  46938. * @returns the index where the transform node was in the transform node list
  46939. */
  46940. removeTransformNode(toRemove: TransformNode): number;
  46941. /**
  46942. * Remove a skeleton for the list of scene's skeletons
  46943. * @param toRemove defines the skeleton to remove
  46944. * @returns the index where the skeleton was in the skeleton list
  46945. */
  46946. removeSkeleton(toRemove: Skeleton): number;
  46947. /**
  46948. * Remove a morph target for the list of scene's morph targets
  46949. * @param toRemove defines the morph target to remove
  46950. * @returns the index where the morph target was in the morph target list
  46951. */
  46952. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  46953. /**
  46954. * Remove a light for the list of scene's lights
  46955. * @param toRemove defines the light to remove
  46956. * @returns the index where the light was in the light list
  46957. */
  46958. removeLight(toRemove: Light): number;
  46959. /**
  46960. * Remove a camera for the list of scene's cameras
  46961. * @param toRemove defines the camera to remove
  46962. * @returns the index where the camera was in the camera list
  46963. */
  46964. removeCamera(toRemove: Camera): number;
  46965. /**
  46966. * Remove a particle system for the list of scene's particle systems
  46967. * @param toRemove defines the particle system to remove
  46968. * @returns the index where the particle system was in the particle system list
  46969. */
  46970. removeParticleSystem(toRemove: IParticleSystem): number;
  46971. /**
  46972. * Remove a animation for the list of scene's animations
  46973. * @param toRemove defines the animation to remove
  46974. * @returns the index where the animation was in the animation list
  46975. */
  46976. removeAnimation(toRemove: Animation): number;
  46977. /**
  46978. * Will stop the animation of the given target
  46979. * @param target - the target
  46980. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  46981. * @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)
  46982. */
  46983. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  46984. /**
  46985. * Removes the given animation group from this scene.
  46986. * @param toRemove The animation group to remove
  46987. * @returns The index of the removed animation group
  46988. */
  46989. removeAnimationGroup(toRemove: AnimationGroup): number;
  46990. /**
  46991. * Removes the given multi-material from this scene.
  46992. * @param toRemove The multi-material to remove
  46993. * @returns The index of the removed multi-material
  46994. */
  46995. removeMultiMaterial(toRemove: MultiMaterial): number;
  46996. /**
  46997. * Removes the given material from this scene.
  46998. * @param toRemove The material to remove
  46999. * @returns The index of the removed material
  47000. */
  47001. removeMaterial(toRemove: Material): number;
  47002. /**
  47003. * Removes the given action manager from this scene.
  47004. * @param toRemove The action manager to remove
  47005. * @returns The index of the removed action manager
  47006. */
  47007. removeActionManager(toRemove: AbstractActionManager): number;
  47008. /**
  47009. * Removes the given texture from this scene.
  47010. * @param toRemove The texture to remove
  47011. * @returns The index of the removed texture
  47012. */
  47013. removeTexture(toRemove: BaseTexture): number;
  47014. /**
  47015. * Adds the given light to this scene
  47016. * @param newLight The light to add
  47017. */
  47018. addLight(newLight: Light): void;
  47019. /**
  47020. * Sorts the list list based on light priorities
  47021. */
  47022. sortLightsByPriority(): void;
  47023. /**
  47024. * Adds the given camera to this scene
  47025. * @param newCamera The camera to add
  47026. */
  47027. addCamera(newCamera: Camera): void;
  47028. /**
  47029. * Adds the given skeleton to this scene
  47030. * @param newSkeleton The skeleton to add
  47031. */
  47032. addSkeleton(newSkeleton: Skeleton): void;
  47033. /**
  47034. * Adds the given particle system to this scene
  47035. * @param newParticleSystem The particle system to add
  47036. */
  47037. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47038. /**
  47039. * Adds the given animation to this scene
  47040. * @param newAnimation The animation to add
  47041. */
  47042. addAnimation(newAnimation: Animation): void;
  47043. /**
  47044. * Adds the given animation group to this scene.
  47045. * @param newAnimationGroup The animation group to add
  47046. */
  47047. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47048. /**
  47049. * Adds the given multi-material to this scene
  47050. * @param newMultiMaterial The multi-material to add
  47051. */
  47052. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47053. /**
  47054. * Adds the given material to this scene
  47055. * @param newMaterial The material to add
  47056. */
  47057. addMaterial(newMaterial: Material): void;
  47058. /**
  47059. * Adds the given morph target to this scene
  47060. * @param newMorphTargetManager The morph target to add
  47061. */
  47062. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47063. /**
  47064. * Adds the given geometry to this scene
  47065. * @param newGeometry The geometry to add
  47066. */
  47067. addGeometry(newGeometry: Geometry): void;
  47068. /**
  47069. * Adds the given action manager to this scene
  47070. * @param newActionManager The action manager to add
  47071. */
  47072. addActionManager(newActionManager: AbstractActionManager): void;
  47073. /**
  47074. * Adds the given texture to this scene.
  47075. * @param newTexture The texture to add
  47076. */
  47077. addTexture(newTexture: BaseTexture): void;
  47078. /**
  47079. * Switch active camera
  47080. * @param newCamera defines the new active camera
  47081. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47082. */
  47083. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47084. /**
  47085. * sets the active camera of the scene using its ID
  47086. * @param id defines the camera's ID
  47087. * @return the new active camera or null if none found.
  47088. */
  47089. setActiveCameraByID(id: string): Nullable<Camera>;
  47090. /**
  47091. * sets the active camera of the scene using its name
  47092. * @param name defines the camera's name
  47093. * @returns the new active camera or null if none found.
  47094. */
  47095. setActiveCameraByName(name: string): Nullable<Camera>;
  47096. /**
  47097. * get an animation group using its name
  47098. * @param name defines the material's name
  47099. * @return the animation group or null if none found.
  47100. */
  47101. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47102. /**
  47103. * Get a material using its unique id
  47104. * @param uniqueId defines the material's unique id
  47105. * @return the material or null if none found.
  47106. */
  47107. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47108. /**
  47109. * get a material using its id
  47110. * @param id defines the material's ID
  47111. * @return the material or null if none found.
  47112. */
  47113. getMaterialByID(id: string): Nullable<Material>;
  47114. /**
  47115. * Gets a the last added material using a given id
  47116. * @param id defines the material's ID
  47117. * @return the last material with the given id or null if none found.
  47118. */
  47119. getLastMaterialByID(id: string): Nullable<Material>;
  47120. /**
  47121. * Gets a material using its name
  47122. * @param name defines the material's name
  47123. * @return the material or null if none found.
  47124. */
  47125. getMaterialByName(name: string): Nullable<Material>;
  47126. /**
  47127. * Get a texture using its unique id
  47128. * @param uniqueId defines the texture's unique id
  47129. * @return the texture or null if none found.
  47130. */
  47131. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47132. /**
  47133. * Gets a camera using its id
  47134. * @param id defines the id to look for
  47135. * @returns the camera or null if not found
  47136. */
  47137. getCameraByID(id: string): Nullable<Camera>;
  47138. /**
  47139. * Gets a camera using its unique id
  47140. * @param uniqueId defines the unique id to look for
  47141. * @returns the camera or null if not found
  47142. */
  47143. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47144. /**
  47145. * Gets a camera using its name
  47146. * @param name defines the camera's name
  47147. * @return the camera or null if none found.
  47148. */
  47149. getCameraByName(name: string): Nullable<Camera>;
  47150. /**
  47151. * Gets a bone using its id
  47152. * @param id defines the bone's id
  47153. * @return the bone or null if not found
  47154. */
  47155. getBoneByID(id: string): Nullable<Bone>;
  47156. /**
  47157. * Gets a bone using its id
  47158. * @param name defines the bone's name
  47159. * @return the bone or null if not found
  47160. */
  47161. getBoneByName(name: string): Nullable<Bone>;
  47162. /**
  47163. * Gets a light node using its name
  47164. * @param name defines the the light's name
  47165. * @return the light or null if none found.
  47166. */
  47167. getLightByName(name: string): Nullable<Light>;
  47168. /**
  47169. * Gets a light node using its id
  47170. * @param id defines the light's id
  47171. * @return the light or null if none found.
  47172. */
  47173. getLightByID(id: string): Nullable<Light>;
  47174. /**
  47175. * Gets a light node using its scene-generated unique ID
  47176. * @param uniqueId defines the light's unique id
  47177. * @return the light or null if none found.
  47178. */
  47179. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47180. /**
  47181. * Gets a particle system by id
  47182. * @param id defines the particle system id
  47183. * @return the corresponding system or null if none found
  47184. */
  47185. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47186. /**
  47187. * Gets a geometry using its ID
  47188. * @param id defines the geometry's id
  47189. * @return the geometry or null if none found.
  47190. */
  47191. getGeometryByID(id: string): Nullable<Geometry>;
  47192. private _getGeometryByUniqueID;
  47193. /**
  47194. * Add a new geometry to this scene
  47195. * @param geometry defines the geometry to be added to the scene.
  47196. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47197. * @return a boolean defining if the geometry was added or not
  47198. */
  47199. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47200. /**
  47201. * Removes an existing geometry
  47202. * @param geometry defines the geometry to be removed from the scene
  47203. * @return a boolean defining if the geometry was removed or not
  47204. */
  47205. removeGeometry(geometry: Geometry): boolean;
  47206. /**
  47207. * Gets the list of geometries attached to the scene
  47208. * @returns an array of Geometry
  47209. */
  47210. getGeometries(): Geometry[];
  47211. /**
  47212. * Gets the first added mesh found of a given ID
  47213. * @param id defines the id to search for
  47214. * @return the mesh found or null if not found at all
  47215. */
  47216. getMeshByID(id: string): Nullable<AbstractMesh>;
  47217. /**
  47218. * Gets a list of meshes using their id
  47219. * @param id defines the id to search for
  47220. * @returns a list of meshes
  47221. */
  47222. getMeshesByID(id: string): Array<AbstractMesh>;
  47223. /**
  47224. * Gets the first added transform node found of a given ID
  47225. * @param id defines the id to search for
  47226. * @return the found transform node or null if not found at all.
  47227. */
  47228. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47229. /**
  47230. * Gets a transform node with its auto-generated unique id
  47231. * @param uniqueId efines the unique id to search for
  47232. * @return the found transform node or null if not found at all.
  47233. */
  47234. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47235. /**
  47236. * Gets a list of transform nodes using their id
  47237. * @param id defines the id to search for
  47238. * @returns a list of transform nodes
  47239. */
  47240. getTransformNodesByID(id: string): Array<TransformNode>;
  47241. /**
  47242. * Gets a mesh with its auto-generated unique id
  47243. * @param uniqueId defines the unique id to search for
  47244. * @return the found mesh or null if not found at all.
  47245. */
  47246. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47247. /**
  47248. * Gets a the last added mesh using a given id
  47249. * @param id defines the id to search for
  47250. * @return the found mesh or null if not found at all.
  47251. */
  47252. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47253. /**
  47254. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47255. * @param id defines the id to search for
  47256. * @return the found node or null if not found at all
  47257. */
  47258. getLastEntryByID(id: string): Nullable<Node>;
  47259. /**
  47260. * Gets a node (Mesh, Camera, Light) using a given id
  47261. * @param id defines the id to search for
  47262. * @return the found node or null if not found at all
  47263. */
  47264. getNodeByID(id: string): Nullable<Node>;
  47265. /**
  47266. * Gets a node (Mesh, Camera, Light) using a given name
  47267. * @param name defines the name to search for
  47268. * @return the found node or null if not found at all.
  47269. */
  47270. getNodeByName(name: string): Nullable<Node>;
  47271. /**
  47272. * Gets a mesh using a given name
  47273. * @param name defines the name to search for
  47274. * @return the found mesh or null if not found at all.
  47275. */
  47276. getMeshByName(name: string): Nullable<AbstractMesh>;
  47277. /**
  47278. * Gets a transform node using a given name
  47279. * @param name defines the name to search for
  47280. * @return the found transform node or null if not found at all.
  47281. */
  47282. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47283. /**
  47284. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47285. * @param id defines the id to search for
  47286. * @return the found skeleton or null if not found at all.
  47287. */
  47288. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47289. /**
  47290. * Gets a skeleton using a given auto generated unique id
  47291. * @param uniqueId defines the unique id to search for
  47292. * @return the found skeleton or null if not found at all.
  47293. */
  47294. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47295. /**
  47296. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47297. * @param id defines the id to search for
  47298. * @return the found skeleton or null if not found at all.
  47299. */
  47300. getSkeletonById(id: string): Nullable<Skeleton>;
  47301. /**
  47302. * Gets a skeleton using a given name
  47303. * @param name defines the name to search for
  47304. * @return the found skeleton or null if not found at all.
  47305. */
  47306. getSkeletonByName(name: string): Nullable<Skeleton>;
  47307. /**
  47308. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47309. * @param id defines the id to search for
  47310. * @return the found morph target manager or null if not found at all.
  47311. */
  47312. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47313. /**
  47314. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47315. * @param id defines the id to search for
  47316. * @return the found morph target or null if not found at all.
  47317. */
  47318. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47319. /**
  47320. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47321. * @param name defines the name to search for
  47322. * @return the found morph target or null if not found at all.
  47323. */
  47324. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47325. /**
  47326. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47327. * @param name defines the name to search for
  47328. * @return the found post process or null if not found at all.
  47329. */
  47330. getPostProcessByName(name: string): Nullable<PostProcess>;
  47331. /**
  47332. * Gets a boolean indicating if the given mesh is active
  47333. * @param mesh defines the mesh to look for
  47334. * @returns true if the mesh is in the active list
  47335. */
  47336. isActiveMesh(mesh: AbstractMesh): boolean;
  47337. /**
  47338. * Return a unique id as a string which can serve as an identifier for the scene
  47339. */
  47340. get uid(): string;
  47341. /**
  47342. * Add an externaly attached data from its key.
  47343. * This method call will fail and return false, if such key already exists.
  47344. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47345. * @param key the unique key that identifies the data
  47346. * @param data the data object to associate to the key for this Engine instance
  47347. * @return true if no such key were already present and the data was added successfully, false otherwise
  47348. */
  47349. addExternalData<T>(key: string, data: T): boolean;
  47350. /**
  47351. * Get an externaly attached data from its key
  47352. * @param key the unique key that identifies the data
  47353. * @return the associated data, if present (can be null), or undefined if not present
  47354. */
  47355. getExternalData<T>(key: string): Nullable<T>;
  47356. /**
  47357. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47358. * @param key the unique key that identifies the data
  47359. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47360. * @return the associated data, can be null if the factory returned null.
  47361. */
  47362. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47363. /**
  47364. * Remove an externaly attached data from the Engine instance
  47365. * @param key the unique key that identifies the data
  47366. * @return true if the data was successfully removed, false if it doesn't exist
  47367. */
  47368. removeExternalData(key: string): boolean;
  47369. private _evaluateSubMesh;
  47370. /**
  47371. * Clear the processed materials smart array preventing retention point in material dispose.
  47372. */
  47373. freeProcessedMaterials(): void;
  47374. private _preventFreeActiveMeshesAndRenderingGroups;
  47375. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47376. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47377. * when disposing several meshes in a row or a hierarchy of meshes.
  47378. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47379. */
  47380. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47381. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47382. /**
  47383. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47384. */
  47385. freeActiveMeshes(): void;
  47386. /**
  47387. * Clear the info related to rendering groups preventing retention points during dispose.
  47388. */
  47389. freeRenderingGroups(): void;
  47390. /** @hidden */
  47391. _isInIntermediateRendering(): boolean;
  47392. /**
  47393. * Lambda returning the list of potentially active meshes.
  47394. */
  47395. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47396. /**
  47397. * Lambda returning the list of potentially active sub meshes.
  47398. */
  47399. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47400. /**
  47401. * Lambda returning the list of potentially intersecting sub meshes.
  47402. */
  47403. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47404. /**
  47405. * Lambda returning the list of potentially colliding sub meshes.
  47406. */
  47407. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47408. /** @hidden */
  47409. _activeMeshesFrozen: boolean;
  47410. private _skipEvaluateActiveMeshesCompletely;
  47411. /**
  47412. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47413. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47414. * @param onSuccess optional success callback
  47415. * @param onError optional error callback
  47416. * @returns the current scene
  47417. */
  47418. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47419. /**
  47420. * Use this function to restart evaluating active meshes on every frame
  47421. * @returns the current scene
  47422. */
  47423. unfreezeActiveMeshes(): Scene;
  47424. private _evaluateActiveMeshes;
  47425. private _activeMesh;
  47426. /**
  47427. * Update the transform matrix to update from the current active camera
  47428. * @param force defines a boolean used to force the update even if cache is up to date
  47429. */
  47430. updateTransformMatrix(force?: boolean): void;
  47431. private _bindFrameBuffer;
  47432. /** @hidden */
  47433. _allowPostProcessClearColor: boolean;
  47434. /** @hidden */
  47435. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47436. private _processSubCameras;
  47437. private _checkIntersections;
  47438. /** @hidden */
  47439. _advancePhysicsEngineStep(step: number): void;
  47440. /**
  47441. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47442. */
  47443. getDeterministicFrameTime: () => number;
  47444. /** @hidden */
  47445. _animate(): void;
  47446. /** Execute all animations (for a frame) */
  47447. animate(): void;
  47448. /**
  47449. * Render the scene
  47450. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47451. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47452. */
  47453. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47454. /**
  47455. * Freeze all materials
  47456. * A frozen material will not be updatable but should be faster to render
  47457. */
  47458. freezeMaterials(): void;
  47459. /**
  47460. * Unfreeze all materials
  47461. * A frozen material will not be updatable but should be faster to render
  47462. */
  47463. unfreezeMaterials(): void;
  47464. /**
  47465. * Releases all held ressources
  47466. */
  47467. dispose(): void;
  47468. /**
  47469. * Gets if the scene is already disposed
  47470. */
  47471. get isDisposed(): boolean;
  47472. /**
  47473. * Call this function to reduce memory footprint of the scene.
  47474. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47475. */
  47476. clearCachedVertexData(): void;
  47477. /**
  47478. * This function will remove the local cached buffer data from texture.
  47479. * It will save memory but will prevent the texture from being rebuilt
  47480. */
  47481. cleanCachedTextureBuffer(): void;
  47482. /**
  47483. * Get the world extend vectors with an optional filter
  47484. *
  47485. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47486. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47487. */
  47488. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47489. min: Vector3;
  47490. max: Vector3;
  47491. };
  47492. /**
  47493. * Creates a ray that can be used to pick in the scene
  47494. * @param x defines the x coordinate of the origin (on-screen)
  47495. * @param y defines the y coordinate of the origin (on-screen)
  47496. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47497. * @param camera defines the camera to use for the picking
  47498. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47499. * @returns a Ray
  47500. */
  47501. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47502. /**
  47503. * Creates a ray that can be used to pick in the scene
  47504. * @param x defines the x coordinate of the origin (on-screen)
  47505. * @param y defines the y coordinate of the origin (on-screen)
  47506. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47507. * @param result defines the ray where to store the picking ray
  47508. * @param camera defines the camera to use for the picking
  47509. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47510. * @returns the current scene
  47511. */
  47512. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47513. /**
  47514. * Creates a ray that can be used to pick in the scene
  47515. * @param x defines the x coordinate of the origin (on-screen)
  47516. * @param y defines the y coordinate of the origin (on-screen)
  47517. * @param camera defines the camera to use for the picking
  47518. * @returns a Ray
  47519. */
  47520. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47521. /**
  47522. * Creates a ray that can be used to pick in the scene
  47523. * @param x defines the x coordinate of the origin (on-screen)
  47524. * @param y defines the y coordinate of the origin (on-screen)
  47525. * @param result defines the ray where to store the picking ray
  47526. * @param camera defines the camera to use for the picking
  47527. * @returns the current scene
  47528. */
  47529. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47530. /** Launch a ray to try to pick a mesh in the scene
  47531. * @param x position on screen
  47532. * @param y position on screen
  47533. * @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
  47534. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47535. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47536. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47537. * @returns a PickingInfo
  47538. */
  47539. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47540. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47541. * @param x position on screen
  47542. * @param y position on screen
  47543. * @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
  47544. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47545. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47546. * @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)
  47547. */
  47548. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47549. /** Use the given ray to pick a mesh in the scene
  47550. * @param ray The ray to use to pick meshes
  47551. * @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
  47552. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47553. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47554. * @returns a PickingInfo
  47555. */
  47556. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47557. /**
  47558. * Launch a ray to try to pick a mesh in the scene
  47559. * @param x X position on screen
  47560. * @param y Y position on screen
  47561. * @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
  47562. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47563. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47564. * @returns an array of PickingInfo
  47565. */
  47566. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47567. /**
  47568. * Launch a ray to try to pick a mesh in the scene
  47569. * @param ray Ray to use
  47570. * @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
  47571. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47572. * @returns an array of PickingInfo
  47573. */
  47574. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47575. /**
  47576. * Force the value of meshUnderPointer
  47577. * @param mesh defines the mesh to use
  47578. * @param pointerId optional pointer id when using more than one pointer
  47579. */
  47580. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47581. /**
  47582. * Gets the mesh under the pointer
  47583. * @returns a Mesh or null if no mesh is under the pointer
  47584. */
  47585. getPointerOverMesh(): Nullable<AbstractMesh>;
  47586. /** @hidden */
  47587. _rebuildGeometries(): void;
  47588. /** @hidden */
  47589. _rebuildTextures(): void;
  47590. private _getByTags;
  47591. /**
  47592. * Get a list of meshes by tags
  47593. * @param tagsQuery defines the tags query to use
  47594. * @param forEach defines a predicate used to filter results
  47595. * @returns an array of Mesh
  47596. */
  47597. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47598. /**
  47599. * Get a list of cameras by tags
  47600. * @param tagsQuery defines the tags query to use
  47601. * @param forEach defines a predicate used to filter results
  47602. * @returns an array of Camera
  47603. */
  47604. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47605. /**
  47606. * Get a list of lights by tags
  47607. * @param tagsQuery defines the tags query to use
  47608. * @param forEach defines a predicate used to filter results
  47609. * @returns an array of Light
  47610. */
  47611. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47612. /**
  47613. * Get a list of materials by tags
  47614. * @param tagsQuery defines the tags query to use
  47615. * @param forEach defines a predicate used to filter results
  47616. * @returns an array of Material
  47617. */
  47618. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47619. /**
  47620. * Get a list of transform nodes by tags
  47621. * @param tagsQuery defines the tags query to use
  47622. * @param forEach defines a predicate used to filter results
  47623. * @returns an array of TransformNode
  47624. */
  47625. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47626. /**
  47627. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47628. * This allowed control for front to back rendering or reversly depending of the special needs.
  47629. *
  47630. * @param renderingGroupId The rendering group id corresponding to its index
  47631. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47632. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47633. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47634. */
  47635. 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;
  47636. /**
  47637. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47638. *
  47639. * @param renderingGroupId The rendering group id corresponding to its index
  47640. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47641. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47642. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47643. */
  47644. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47645. /**
  47646. * Gets the current auto clear configuration for one rendering group of the rendering
  47647. * manager.
  47648. * @param index the rendering group index to get the information for
  47649. * @returns The auto clear setup for the requested rendering group
  47650. */
  47651. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47652. private _blockMaterialDirtyMechanism;
  47653. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47654. get blockMaterialDirtyMechanism(): boolean;
  47655. set blockMaterialDirtyMechanism(value: boolean);
  47656. /**
  47657. * Will flag all materials as dirty to trigger new shader compilation
  47658. * @param flag defines the flag used to specify which material part must be marked as dirty
  47659. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47660. */
  47661. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47662. /** @hidden */
  47663. _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;
  47664. /** @hidden */
  47665. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47666. /** @hidden */
  47667. _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;
  47668. /** @hidden */
  47669. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47670. /** @hidden */
  47671. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47672. /** @hidden */
  47673. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47674. }
  47675. }
  47676. declare module BABYLON {
  47677. /**
  47678. * Set of assets to keep when moving a scene into an asset container.
  47679. */
  47680. export class KeepAssets extends AbstractScene {
  47681. }
  47682. /**
  47683. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47684. */
  47685. export class InstantiatedEntries {
  47686. /**
  47687. * List of new root nodes (eg. nodes with no parent)
  47688. */
  47689. rootNodes: TransformNode[];
  47690. /**
  47691. * List of new skeletons
  47692. */
  47693. skeletons: Skeleton[];
  47694. /**
  47695. * List of new animation groups
  47696. */
  47697. animationGroups: AnimationGroup[];
  47698. }
  47699. /**
  47700. * Container with a set of assets that can be added or removed from a scene.
  47701. */
  47702. export class AssetContainer extends AbstractScene {
  47703. private _wasAddedToScene;
  47704. /**
  47705. * The scene the AssetContainer belongs to.
  47706. */
  47707. scene: Scene;
  47708. /**
  47709. * Instantiates an AssetContainer.
  47710. * @param scene The scene the AssetContainer belongs to.
  47711. */
  47712. constructor(scene: Scene);
  47713. /**
  47714. * Instantiate or clone all meshes and add the new ones to the scene.
  47715. * Skeletons and animation groups will all be cloned
  47716. * @param nameFunction defines an optional function used to get new names for clones
  47717. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47718. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47719. */
  47720. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47721. /**
  47722. * Adds all the assets from the container to the scene.
  47723. */
  47724. addAllToScene(): void;
  47725. /**
  47726. * Removes all the assets in the container from the scene
  47727. */
  47728. removeAllFromScene(): void;
  47729. /**
  47730. * Disposes all the assets in the container
  47731. */
  47732. dispose(): void;
  47733. private _moveAssets;
  47734. /**
  47735. * Removes all the assets contained in the scene and adds them to the container.
  47736. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47737. */
  47738. moveAllFromScene(keepAssets?: KeepAssets): void;
  47739. /**
  47740. * 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.
  47741. * @returns the root mesh
  47742. */
  47743. createRootMesh(): Mesh;
  47744. /**
  47745. * Merge animations (direct and animation groups) from this asset container into a scene
  47746. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47747. * @param animatables set of animatables to retarget to a node from the scene
  47748. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47749. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47750. */
  47751. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47752. }
  47753. }
  47754. declare module BABYLON {
  47755. /**
  47756. * Defines how the parser contract is defined.
  47757. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47758. */
  47759. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47760. /**
  47761. * Defines how the individual parser contract is defined.
  47762. * These parser can parse an individual asset
  47763. */
  47764. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47765. /**
  47766. * Base class of the scene acting as a container for the different elements composing a scene.
  47767. * This class is dynamically extended by the different components of the scene increasing
  47768. * flexibility and reducing coupling
  47769. */
  47770. export abstract class AbstractScene {
  47771. /**
  47772. * Stores the list of available parsers in the application.
  47773. */
  47774. private static _BabylonFileParsers;
  47775. /**
  47776. * Stores the list of available individual parsers in the application.
  47777. */
  47778. private static _IndividualBabylonFileParsers;
  47779. /**
  47780. * Adds a parser in the list of available ones
  47781. * @param name Defines the name of the parser
  47782. * @param parser Defines the parser to add
  47783. */
  47784. static AddParser(name: string, parser: BabylonFileParser): void;
  47785. /**
  47786. * Gets a general parser from the list of avaialble ones
  47787. * @param name Defines the name of the parser
  47788. * @returns the requested parser or null
  47789. */
  47790. static GetParser(name: string): Nullable<BabylonFileParser>;
  47791. /**
  47792. * Adds n individual parser in the list of available ones
  47793. * @param name Defines the name of the parser
  47794. * @param parser Defines the parser to add
  47795. */
  47796. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47797. /**
  47798. * Gets an individual parser from the list of avaialble ones
  47799. * @param name Defines the name of the parser
  47800. * @returns the requested parser or null
  47801. */
  47802. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47803. /**
  47804. * Parser json data and populate both a scene and its associated container object
  47805. * @param jsonData Defines the data to parse
  47806. * @param scene Defines the scene to parse the data for
  47807. * @param container Defines the container attached to the parsing sequence
  47808. * @param rootUrl Defines the root url of the data
  47809. */
  47810. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47811. /**
  47812. * Gets the list of root nodes (ie. nodes with no parent)
  47813. */
  47814. rootNodes: Node[];
  47815. /** All of the cameras added to this scene
  47816. * @see https://doc.babylonjs.com/babylon101/cameras
  47817. */
  47818. cameras: Camera[];
  47819. /**
  47820. * All of the lights added to this scene
  47821. * @see https://doc.babylonjs.com/babylon101/lights
  47822. */
  47823. lights: Light[];
  47824. /**
  47825. * All of the (abstract) meshes added to this scene
  47826. */
  47827. meshes: AbstractMesh[];
  47828. /**
  47829. * The list of skeletons added to the scene
  47830. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47831. */
  47832. skeletons: Skeleton[];
  47833. /**
  47834. * All of the particle systems added to this scene
  47835. * @see https://doc.babylonjs.com/babylon101/particles
  47836. */
  47837. particleSystems: IParticleSystem[];
  47838. /**
  47839. * Gets a list of Animations associated with the scene
  47840. */
  47841. animations: Animation[];
  47842. /**
  47843. * All of the animation groups added to this scene
  47844. * @see https://doc.babylonjs.com/how_to/group
  47845. */
  47846. animationGroups: AnimationGroup[];
  47847. /**
  47848. * All of the multi-materials added to this scene
  47849. * @see https://doc.babylonjs.com/how_to/multi_materials
  47850. */
  47851. multiMaterials: MultiMaterial[];
  47852. /**
  47853. * All of the materials added to this scene
  47854. * In the context of a Scene, it is not supposed to be modified manually.
  47855. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47856. * Note also that the order of the Material within the array is not significant and might change.
  47857. * @see https://doc.babylonjs.com/babylon101/materials
  47858. */
  47859. materials: Material[];
  47860. /**
  47861. * The list of morph target managers added to the scene
  47862. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47863. */
  47864. morphTargetManagers: MorphTargetManager[];
  47865. /**
  47866. * The list of geometries used in the scene.
  47867. */
  47868. geometries: Geometry[];
  47869. /**
  47870. * All of the tranform nodes added to this scene
  47871. * In the context of a Scene, it is not supposed to be modified manually.
  47872. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47873. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47874. * @see https://doc.babylonjs.com/how_to/transformnode
  47875. */
  47876. transformNodes: TransformNode[];
  47877. /**
  47878. * ActionManagers available on the scene.
  47879. */
  47880. actionManagers: AbstractActionManager[];
  47881. /**
  47882. * Textures to keep.
  47883. */
  47884. textures: BaseTexture[];
  47885. /** @hidden */
  47886. protected _environmentTexture: Nullable<BaseTexture>;
  47887. /**
  47888. * Texture used in all pbr material as the reflection texture.
  47889. * As in the majority of the scene they are the same (exception for multi room and so on),
  47890. * this is easier to reference from here than from all the materials.
  47891. */
  47892. get environmentTexture(): Nullable<BaseTexture>;
  47893. set environmentTexture(value: Nullable<BaseTexture>);
  47894. /**
  47895. * The list of postprocesses added to the scene
  47896. */
  47897. postProcesses: PostProcess[];
  47898. /**
  47899. * @returns all meshes, lights, cameras, transformNodes and bones
  47900. */
  47901. getNodes(): Array<Node>;
  47902. }
  47903. }
  47904. declare module BABYLON {
  47905. /**
  47906. * Interface used to define options for Sound class
  47907. */
  47908. export interface ISoundOptions {
  47909. /**
  47910. * Does the sound autoplay once loaded.
  47911. */
  47912. autoplay?: boolean;
  47913. /**
  47914. * Does the sound loop after it finishes playing once.
  47915. */
  47916. loop?: boolean;
  47917. /**
  47918. * Sound's volume
  47919. */
  47920. volume?: number;
  47921. /**
  47922. * Is it a spatial sound?
  47923. */
  47924. spatialSound?: boolean;
  47925. /**
  47926. * Maximum distance to hear that sound
  47927. */
  47928. maxDistance?: number;
  47929. /**
  47930. * Uses user defined attenuation function
  47931. */
  47932. useCustomAttenuation?: boolean;
  47933. /**
  47934. * Define the roll off factor of spatial sounds.
  47935. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47936. */
  47937. rolloffFactor?: number;
  47938. /**
  47939. * Define the reference distance the sound should be heard perfectly.
  47940. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47941. */
  47942. refDistance?: number;
  47943. /**
  47944. * Define the distance attenuation model the sound will follow.
  47945. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47946. */
  47947. distanceModel?: string;
  47948. /**
  47949. * Defines the playback speed (1 by default)
  47950. */
  47951. playbackRate?: number;
  47952. /**
  47953. * Defines if the sound is from a streaming source
  47954. */
  47955. streaming?: boolean;
  47956. /**
  47957. * Defines an optional length (in seconds) inside the sound file
  47958. */
  47959. length?: number;
  47960. /**
  47961. * Defines an optional offset (in seconds) inside the sound file
  47962. */
  47963. offset?: number;
  47964. /**
  47965. * If true, URLs will not be required to state the audio file codec to use.
  47966. */
  47967. skipCodecCheck?: boolean;
  47968. }
  47969. }
  47970. declare module BABYLON {
  47971. /**
  47972. * Defines a sound that can be played in the application.
  47973. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  47974. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47975. */
  47976. export class Sound {
  47977. /**
  47978. * The name of the sound in the scene.
  47979. */
  47980. name: string;
  47981. /**
  47982. * Does the sound autoplay once loaded.
  47983. */
  47984. autoplay: boolean;
  47985. private _loop;
  47986. /**
  47987. * Does the sound loop after it finishes playing once.
  47988. */
  47989. get loop(): boolean;
  47990. set loop(value: boolean);
  47991. /**
  47992. * Does the sound use a custom attenuation curve to simulate the falloff
  47993. * happening when the source gets further away from the camera.
  47994. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  47995. */
  47996. useCustomAttenuation: boolean;
  47997. /**
  47998. * The sound track id this sound belongs to.
  47999. */
  48000. soundTrackId: number;
  48001. /**
  48002. * Is this sound currently played.
  48003. */
  48004. isPlaying: boolean;
  48005. /**
  48006. * Is this sound currently paused.
  48007. */
  48008. isPaused: boolean;
  48009. /**
  48010. * Does this sound enables spatial sound.
  48011. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48012. */
  48013. spatialSound: boolean;
  48014. /**
  48015. * Define the reference distance the sound should be heard perfectly.
  48016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48017. */
  48018. refDistance: number;
  48019. /**
  48020. * Define the roll off factor of spatial sounds.
  48021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48022. */
  48023. rolloffFactor: number;
  48024. /**
  48025. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48026. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48027. */
  48028. maxDistance: number;
  48029. /**
  48030. * Define the distance attenuation model the sound will follow.
  48031. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48032. */
  48033. distanceModel: string;
  48034. /**
  48035. * @hidden
  48036. * Back Compat
  48037. **/
  48038. onended: () => any;
  48039. /**
  48040. * Gets or sets an object used to store user defined information for the sound.
  48041. */
  48042. metadata: any;
  48043. /**
  48044. * Observable event when the current playing sound finishes.
  48045. */
  48046. onEndedObservable: Observable<Sound>;
  48047. /**
  48048. * Gets the current time for the sound.
  48049. */
  48050. get currentTime(): number;
  48051. private _panningModel;
  48052. private _playbackRate;
  48053. private _streaming;
  48054. private _startTime;
  48055. private _startOffset;
  48056. private _position;
  48057. /** @hidden */
  48058. _positionInEmitterSpace: boolean;
  48059. private _localDirection;
  48060. private _volume;
  48061. private _isReadyToPlay;
  48062. private _isDirectional;
  48063. private _readyToPlayCallback;
  48064. private _audioBuffer;
  48065. private _soundSource;
  48066. private _streamingSource;
  48067. private _soundPanner;
  48068. private _soundGain;
  48069. private _inputAudioNode;
  48070. private _outputAudioNode;
  48071. private _coneInnerAngle;
  48072. private _coneOuterAngle;
  48073. private _coneOuterGain;
  48074. private _scene;
  48075. private _connectedTransformNode;
  48076. private _customAttenuationFunction;
  48077. private _registerFunc;
  48078. private _isOutputConnected;
  48079. private _htmlAudioElement;
  48080. private _urlType;
  48081. private _length?;
  48082. private _offset?;
  48083. /** @hidden */
  48084. static _SceneComponentInitialization: (scene: Scene) => void;
  48085. /**
  48086. * Create a sound and attach it to a scene
  48087. * @param name Name of your sound
  48088. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48089. * @param scene defines the scene the sound belongs to
  48090. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48091. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48092. */
  48093. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48094. /**
  48095. * Release the sound and its associated resources
  48096. */
  48097. dispose(): void;
  48098. /**
  48099. * Gets if the sounds is ready to be played or not.
  48100. * @returns true if ready, otherwise false
  48101. */
  48102. isReady(): boolean;
  48103. /**
  48104. * Get the current class name.
  48105. * @returns current class name
  48106. */
  48107. getClassName(): string;
  48108. private _soundLoaded;
  48109. /**
  48110. * Sets the data of the sound from an audiobuffer
  48111. * @param audioBuffer The audioBuffer containing the data
  48112. */
  48113. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48114. /**
  48115. * Updates the current sounds options such as maxdistance, loop...
  48116. * @param options A JSON object containing values named as the object properties
  48117. */
  48118. updateOptions(options: ISoundOptions): void;
  48119. private _createSpatialParameters;
  48120. private _updateSpatialParameters;
  48121. /**
  48122. * Switch the panning model to HRTF:
  48123. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48124. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48125. */
  48126. switchPanningModelToHRTF(): void;
  48127. /**
  48128. * Switch the panning model to Equal Power:
  48129. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48130. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48131. */
  48132. switchPanningModelToEqualPower(): void;
  48133. private _switchPanningModel;
  48134. /**
  48135. * Connect this sound to a sound track audio node like gain...
  48136. * @param soundTrackAudioNode the sound track audio node to connect to
  48137. */
  48138. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48139. /**
  48140. * Transform this sound into a directional source
  48141. * @param coneInnerAngle Size of the inner cone in degree
  48142. * @param coneOuterAngle Size of the outer cone in degree
  48143. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48144. */
  48145. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48146. /**
  48147. * Gets or sets the inner angle for the directional cone.
  48148. */
  48149. get directionalConeInnerAngle(): number;
  48150. /**
  48151. * Gets or sets the inner angle for the directional cone.
  48152. */
  48153. set directionalConeInnerAngle(value: number);
  48154. /**
  48155. * Gets or sets the outer angle for the directional cone.
  48156. */
  48157. get directionalConeOuterAngle(): number;
  48158. /**
  48159. * Gets or sets the outer angle for the directional cone.
  48160. */
  48161. set directionalConeOuterAngle(value: number);
  48162. /**
  48163. * Sets the position of the emitter if spatial sound is enabled
  48164. * @param newPosition Defines the new posisiton
  48165. */
  48166. setPosition(newPosition: Vector3): void;
  48167. /**
  48168. * Sets the local direction of the emitter if spatial sound is enabled
  48169. * @param newLocalDirection Defines the new local direction
  48170. */
  48171. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48172. private _updateDirection;
  48173. /** @hidden */
  48174. updateDistanceFromListener(): void;
  48175. /**
  48176. * Sets a new custom attenuation function for the sound.
  48177. * @param callback Defines the function used for the attenuation
  48178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48179. */
  48180. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48181. /**
  48182. * Play the sound
  48183. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48184. * @param offset (optional) Start the sound at a specific time in seconds
  48185. * @param length (optional) Sound duration (in seconds)
  48186. */
  48187. play(time?: number, offset?: number, length?: number): void;
  48188. private _onended;
  48189. /**
  48190. * Stop the sound
  48191. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48192. */
  48193. stop(time?: number): void;
  48194. /**
  48195. * Put the sound in pause
  48196. */
  48197. pause(): void;
  48198. /**
  48199. * Sets a dedicated volume for this sounds
  48200. * @param newVolume Define the new volume of the sound
  48201. * @param time Define time for gradual change to new volume
  48202. */
  48203. setVolume(newVolume: number, time?: number): void;
  48204. /**
  48205. * Set the sound play back rate
  48206. * @param newPlaybackRate Define the playback rate the sound should be played at
  48207. */
  48208. setPlaybackRate(newPlaybackRate: number): void;
  48209. /**
  48210. * Gets the volume of the sound.
  48211. * @returns the volume of the sound
  48212. */
  48213. getVolume(): number;
  48214. /**
  48215. * Attach the sound to a dedicated mesh
  48216. * @param transformNode The transform node to connect the sound with
  48217. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48218. */
  48219. attachToMesh(transformNode: TransformNode): void;
  48220. /**
  48221. * Detach the sound from the previously attached mesh
  48222. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48223. */
  48224. detachFromMesh(): void;
  48225. private _onRegisterAfterWorldMatrixUpdate;
  48226. /**
  48227. * Clone the current sound in the scene.
  48228. * @returns the new sound clone
  48229. */
  48230. clone(): Nullable<Sound>;
  48231. /**
  48232. * Gets the current underlying audio buffer containing the data
  48233. * @returns the audio buffer
  48234. */
  48235. getAudioBuffer(): Nullable<AudioBuffer>;
  48236. /**
  48237. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48238. * @returns the source node
  48239. */
  48240. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48241. /**
  48242. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48243. * @returns the gain node
  48244. */
  48245. getSoundGain(): Nullable<GainNode>;
  48246. /**
  48247. * Serializes the Sound in a JSON representation
  48248. * @returns the JSON representation of the sound
  48249. */
  48250. serialize(): any;
  48251. /**
  48252. * Parse a JSON representation of a sound to innstantiate in a given scene
  48253. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48254. * @param scene Define the scene the new parsed sound should be created in
  48255. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48256. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48257. * @returns the newly parsed sound
  48258. */
  48259. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48260. }
  48261. }
  48262. declare module BABYLON {
  48263. /**
  48264. * This defines an action helpful to play a defined sound on a triggered action.
  48265. */
  48266. export class PlaySoundAction extends Action {
  48267. private _sound;
  48268. /**
  48269. * Instantiate the action
  48270. * @param triggerOptions defines the trigger options
  48271. * @param sound defines the sound to play
  48272. * @param condition defines the trigger related conditions
  48273. */
  48274. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48275. /** @hidden */
  48276. _prepare(): void;
  48277. /**
  48278. * Execute the action and play the sound.
  48279. */
  48280. execute(): void;
  48281. /**
  48282. * Serializes the actions and its related information.
  48283. * @param parent defines the object to serialize in
  48284. * @returns the serialized object
  48285. */
  48286. serialize(parent: any): any;
  48287. }
  48288. /**
  48289. * This defines an action helpful to stop a defined sound on a triggered action.
  48290. */
  48291. export class StopSoundAction extends Action {
  48292. private _sound;
  48293. /**
  48294. * Instantiate the action
  48295. * @param triggerOptions defines the trigger options
  48296. * @param sound defines the sound to stop
  48297. * @param condition defines the trigger related conditions
  48298. */
  48299. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48300. /** @hidden */
  48301. _prepare(): void;
  48302. /**
  48303. * Execute the action and stop the sound.
  48304. */
  48305. execute(): void;
  48306. /**
  48307. * Serializes the actions and its related information.
  48308. * @param parent defines the object to serialize in
  48309. * @returns the serialized object
  48310. */
  48311. serialize(parent: any): any;
  48312. }
  48313. }
  48314. declare module BABYLON {
  48315. /**
  48316. * This defines an action responsible to change the value of a property
  48317. * by interpolating between its current value and the newly set one once triggered.
  48318. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48319. */
  48320. export class InterpolateValueAction extends Action {
  48321. /**
  48322. * Defines the path of the property where the value should be interpolated
  48323. */
  48324. propertyPath: string;
  48325. /**
  48326. * Defines the target value at the end of the interpolation.
  48327. */
  48328. value: any;
  48329. /**
  48330. * Defines the time it will take for the property to interpolate to the value.
  48331. */
  48332. duration: number;
  48333. /**
  48334. * Defines if the other scene animations should be stopped when the action has been triggered
  48335. */
  48336. stopOtherAnimations?: boolean;
  48337. /**
  48338. * Defines a callback raised once the interpolation animation has been done.
  48339. */
  48340. onInterpolationDone?: () => void;
  48341. /**
  48342. * Observable triggered once the interpolation animation has been done.
  48343. */
  48344. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48345. private _target;
  48346. private _effectiveTarget;
  48347. private _property;
  48348. /**
  48349. * Instantiate the action
  48350. * @param triggerOptions defines the trigger options
  48351. * @param target defines the object containing the value to interpolate
  48352. * @param propertyPath defines the path to the property in the target object
  48353. * @param value defines the target value at the end of the interpolation
  48354. * @param duration deines the time it will take for the property to interpolate to the value.
  48355. * @param condition defines the trigger related conditions
  48356. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48357. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48358. */
  48359. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48360. /** @hidden */
  48361. _prepare(): void;
  48362. /**
  48363. * Execute the action starts the value interpolation.
  48364. */
  48365. execute(): void;
  48366. /**
  48367. * Serializes the actions and its related information.
  48368. * @param parent defines the object to serialize in
  48369. * @returns the serialized object
  48370. */
  48371. serialize(parent: any): any;
  48372. }
  48373. }
  48374. declare module BABYLON {
  48375. /**
  48376. * This represents the default audio engine used in babylon.
  48377. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48378. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48379. */
  48380. export class AudioEngine implements IAudioEngine {
  48381. private _audioContext;
  48382. private _audioContextInitialized;
  48383. private _muteButton;
  48384. private _hostElement;
  48385. /**
  48386. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48387. */
  48388. canUseWebAudio: boolean;
  48389. /**
  48390. * The master gain node defines the global audio volume of your audio engine.
  48391. */
  48392. masterGain: GainNode;
  48393. /**
  48394. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48395. * @ignoreNaming
  48396. */
  48397. WarnedWebAudioUnsupported: boolean;
  48398. /**
  48399. * Gets whether or not mp3 are supported by your browser.
  48400. */
  48401. isMP3supported: boolean;
  48402. /**
  48403. * Gets whether or not ogg are supported by your browser.
  48404. */
  48405. isOGGsupported: boolean;
  48406. /**
  48407. * Gets whether audio has been unlocked on the device.
  48408. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48409. * a user interaction has happened.
  48410. */
  48411. unlocked: boolean;
  48412. /**
  48413. * Defines if the audio engine relies on a custom unlocked button.
  48414. * In this case, the embedded button will not be displayed.
  48415. */
  48416. useCustomUnlockedButton: boolean;
  48417. /**
  48418. * Event raised when audio has been unlocked on the browser.
  48419. */
  48420. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48421. /**
  48422. * Event raised when audio has been locked on the browser.
  48423. */
  48424. onAudioLockedObservable: Observable<IAudioEngine>;
  48425. /**
  48426. * Gets the current AudioContext if available.
  48427. */
  48428. get audioContext(): Nullable<AudioContext>;
  48429. private _connectedAnalyser;
  48430. /**
  48431. * Instantiates a new audio engine.
  48432. *
  48433. * There should be only one per page as some browsers restrict the number
  48434. * of audio contexts you can create.
  48435. * @param hostElement defines the host element where to display the mute icon if necessary
  48436. */
  48437. constructor(hostElement?: Nullable<HTMLElement>);
  48438. /**
  48439. * Flags the audio engine in Locked state.
  48440. * This happens due to new browser policies preventing audio to autoplay.
  48441. */
  48442. lock(): void;
  48443. /**
  48444. * Unlocks the audio engine once a user action has been done on the dom.
  48445. * This is helpful to resume play once browser policies have been satisfied.
  48446. */
  48447. unlock(): void;
  48448. private _resumeAudioContext;
  48449. private _initializeAudioContext;
  48450. private _tryToRun;
  48451. private _triggerRunningState;
  48452. private _triggerSuspendedState;
  48453. private _displayMuteButton;
  48454. private _moveButtonToTopLeft;
  48455. private _onResize;
  48456. private _hideMuteButton;
  48457. /**
  48458. * Destroy and release the resources associated with the audio ccontext.
  48459. */
  48460. dispose(): void;
  48461. /**
  48462. * Gets the global volume sets on the master gain.
  48463. * @returns the global volume if set or -1 otherwise
  48464. */
  48465. getGlobalVolume(): number;
  48466. /**
  48467. * Sets the global volume of your experience (sets on the master gain).
  48468. * @param newVolume Defines the new global volume of the application
  48469. */
  48470. setGlobalVolume(newVolume: number): void;
  48471. /**
  48472. * Connect the audio engine to an audio analyser allowing some amazing
  48473. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48474. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48475. * @param analyser The analyser to connect to the engine
  48476. */
  48477. connectToAnalyser(analyser: Analyser): void;
  48478. }
  48479. }
  48480. declare module BABYLON {
  48481. /**
  48482. * Options allowed during the creation of a sound track.
  48483. */
  48484. export interface ISoundTrackOptions {
  48485. /**
  48486. * The volume the sound track should take during creation
  48487. */
  48488. volume?: number;
  48489. /**
  48490. * Define if the sound track is the main sound track of the scene
  48491. */
  48492. mainTrack?: boolean;
  48493. }
  48494. /**
  48495. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48496. * It will be also used in a future release to apply effects on a specific track.
  48497. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48498. */
  48499. export class SoundTrack {
  48500. /**
  48501. * The unique identifier of the sound track in the scene.
  48502. */
  48503. id: number;
  48504. /**
  48505. * The list of sounds included in the sound track.
  48506. */
  48507. soundCollection: Array<Sound>;
  48508. private _outputAudioNode;
  48509. private _scene;
  48510. private _connectedAnalyser;
  48511. private _options;
  48512. private _isInitialized;
  48513. /**
  48514. * Creates a new sound track.
  48515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48516. * @param scene Define the scene the sound track belongs to
  48517. * @param options
  48518. */
  48519. constructor(scene: Scene, options?: ISoundTrackOptions);
  48520. private _initializeSoundTrackAudioGraph;
  48521. /**
  48522. * Release the sound track and its associated resources
  48523. */
  48524. dispose(): void;
  48525. /**
  48526. * Adds a sound to this sound track
  48527. * @param sound define the cound to add
  48528. * @ignoreNaming
  48529. */
  48530. addSound(sound: Sound): void;
  48531. /**
  48532. * Removes a sound to this sound track
  48533. * @param sound define the cound to remove
  48534. * @ignoreNaming
  48535. */
  48536. removeSound(sound: Sound): void;
  48537. /**
  48538. * Set a global volume for the full sound track.
  48539. * @param newVolume Define the new volume of the sound track
  48540. */
  48541. setVolume(newVolume: number): void;
  48542. /**
  48543. * Switch the panning model to HRTF:
  48544. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48546. */
  48547. switchPanningModelToHRTF(): void;
  48548. /**
  48549. * Switch the panning model to Equal Power:
  48550. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48551. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48552. */
  48553. switchPanningModelToEqualPower(): void;
  48554. /**
  48555. * Connect the sound track to an audio analyser allowing some amazing
  48556. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48557. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48558. * @param analyser The analyser to connect to the engine
  48559. */
  48560. connectToAnalyser(analyser: Analyser): void;
  48561. }
  48562. }
  48563. declare module BABYLON {
  48564. interface AbstractScene {
  48565. /**
  48566. * The list of sounds used in the scene.
  48567. */
  48568. sounds: Nullable<Array<Sound>>;
  48569. }
  48570. interface Scene {
  48571. /**
  48572. * @hidden
  48573. * Backing field
  48574. */
  48575. _mainSoundTrack: SoundTrack;
  48576. /**
  48577. * The main sound track played by the scene.
  48578. * It cotains your primary collection of sounds.
  48579. */
  48580. mainSoundTrack: SoundTrack;
  48581. /**
  48582. * The list of sound tracks added to the scene
  48583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48584. */
  48585. soundTracks: Nullable<Array<SoundTrack>>;
  48586. /**
  48587. * Gets a sound using a given name
  48588. * @param name defines the name to search for
  48589. * @return the found sound or null if not found at all.
  48590. */
  48591. getSoundByName(name: string): Nullable<Sound>;
  48592. /**
  48593. * Gets or sets if audio support is enabled
  48594. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48595. */
  48596. audioEnabled: boolean;
  48597. /**
  48598. * Gets or sets if audio will be output to headphones
  48599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48600. */
  48601. headphone: boolean;
  48602. /**
  48603. * Gets or sets custom audio listener position provider
  48604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48605. */
  48606. audioListenerPositionProvider: Nullable<() => Vector3>;
  48607. /**
  48608. * Gets or sets a refresh rate when using 3D audio positioning
  48609. */
  48610. audioPositioningRefreshRate: number;
  48611. }
  48612. /**
  48613. * Defines the sound scene component responsible to manage any sounds
  48614. * in a given scene.
  48615. */
  48616. export class AudioSceneComponent implements ISceneSerializableComponent {
  48617. private static _CameraDirectionLH;
  48618. private static _CameraDirectionRH;
  48619. /**
  48620. * The component name helpfull to identify the component in the list of scene components.
  48621. */
  48622. readonly name: string;
  48623. /**
  48624. * The scene the component belongs to.
  48625. */
  48626. scene: Scene;
  48627. private _audioEnabled;
  48628. /**
  48629. * Gets whether audio is enabled or not.
  48630. * Please use related enable/disable method to switch state.
  48631. */
  48632. get audioEnabled(): boolean;
  48633. private _headphone;
  48634. /**
  48635. * Gets whether audio is outputing to headphone or not.
  48636. * Please use the according Switch methods to change output.
  48637. */
  48638. get headphone(): boolean;
  48639. /**
  48640. * Gets or sets a refresh rate when using 3D audio positioning
  48641. */
  48642. audioPositioningRefreshRate: number;
  48643. private _audioListenerPositionProvider;
  48644. /**
  48645. * Gets the current audio listener position provider
  48646. */
  48647. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48648. /**
  48649. * Sets a custom listener position for all sounds in the scene
  48650. * By default, this is the position of the first active camera
  48651. */
  48652. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48653. /**
  48654. * Creates a new instance of the component for the given scene
  48655. * @param scene Defines the scene to register the component in
  48656. */
  48657. constructor(scene: Scene);
  48658. /**
  48659. * Registers the component in a given scene
  48660. */
  48661. register(): void;
  48662. /**
  48663. * Rebuilds the elements related to this component in case of
  48664. * context lost for instance.
  48665. */
  48666. rebuild(): void;
  48667. /**
  48668. * Serializes the component data to the specified json object
  48669. * @param serializationObject The object to serialize to
  48670. */
  48671. serialize(serializationObject: any): void;
  48672. /**
  48673. * Adds all the elements from the container to the scene
  48674. * @param container the container holding the elements
  48675. */
  48676. addFromContainer(container: AbstractScene): void;
  48677. /**
  48678. * Removes all the elements in the container from the scene
  48679. * @param container contains the elements to remove
  48680. * @param dispose if the removed element should be disposed (default: false)
  48681. */
  48682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48683. /**
  48684. * Disposes the component and the associated ressources.
  48685. */
  48686. dispose(): void;
  48687. /**
  48688. * Disables audio in the associated scene.
  48689. */
  48690. disableAudio(): void;
  48691. /**
  48692. * Enables audio in the associated scene.
  48693. */
  48694. enableAudio(): void;
  48695. /**
  48696. * Switch audio to headphone output.
  48697. */
  48698. switchAudioModeForHeadphones(): void;
  48699. /**
  48700. * Switch audio to normal speakers.
  48701. */
  48702. switchAudioModeForNormalSpeakers(): void;
  48703. private _cachedCameraDirection;
  48704. private _cachedCameraPosition;
  48705. private _lastCheck;
  48706. private _afterRender;
  48707. }
  48708. }
  48709. declare module BABYLON {
  48710. /**
  48711. * Wraps one or more Sound objects and selects one with random weight for playback.
  48712. */
  48713. export class WeightedSound {
  48714. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48715. loop: boolean;
  48716. private _coneInnerAngle;
  48717. private _coneOuterAngle;
  48718. private _volume;
  48719. /** A Sound is currently playing. */
  48720. isPlaying: boolean;
  48721. /** A Sound is currently paused. */
  48722. isPaused: boolean;
  48723. private _sounds;
  48724. private _weights;
  48725. private _currentIndex?;
  48726. /**
  48727. * Creates a new WeightedSound from the list of sounds given.
  48728. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48729. * @param sounds Array of Sounds that will be selected from.
  48730. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48731. */
  48732. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48733. /**
  48734. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48735. */
  48736. get directionalConeInnerAngle(): number;
  48737. /**
  48738. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48739. */
  48740. set directionalConeInnerAngle(value: number);
  48741. /**
  48742. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48743. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48744. */
  48745. get directionalConeOuterAngle(): number;
  48746. /**
  48747. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48748. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48749. */
  48750. set directionalConeOuterAngle(value: number);
  48751. /**
  48752. * Playback volume.
  48753. */
  48754. get volume(): number;
  48755. /**
  48756. * Playback volume.
  48757. */
  48758. set volume(value: number);
  48759. private _onended;
  48760. /**
  48761. * Suspend playback
  48762. */
  48763. pause(): void;
  48764. /**
  48765. * Stop playback
  48766. */
  48767. stop(): void;
  48768. /**
  48769. * Start playback.
  48770. * @param startOffset Position the clip head at a specific time in seconds.
  48771. */
  48772. play(startOffset?: number): void;
  48773. }
  48774. }
  48775. declare module BABYLON {
  48776. /**
  48777. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48778. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48779. */
  48780. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48781. /**
  48782. * Gets the name of the behavior.
  48783. */
  48784. get name(): string;
  48785. /**
  48786. * The easing function used by animations
  48787. */
  48788. static EasingFunction: BackEase;
  48789. /**
  48790. * The easing mode used by animations
  48791. */
  48792. static EasingMode: number;
  48793. /**
  48794. * The duration of the animation, in milliseconds
  48795. */
  48796. transitionDuration: number;
  48797. /**
  48798. * Length of the distance animated by the transition when lower radius is reached
  48799. */
  48800. lowerRadiusTransitionRange: number;
  48801. /**
  48802. * Length of the distance animated by the transition when upper radius is reached
  48803. */
  48804. upperRadiusTransitionRange: number;
  48805. private _autoTransitionRange;
  48806. /**
  48807. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48808. */
  48809. get autoTransitionRange(): boolean;
  48810. /**
  48811. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48812. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48813. */
  48814. set autoTransitionRange(value: boolean);
  48815. private _attachedCamera;
  48816. private _onAfterCheckInputsObserver;
  48817. private _onMeshTargetChangedObserver;
  48818. /**
  48819. * Initializes the behavior.
  48820. */
  48821. init(): void;
  48822. /**
  48823. * Attaches the behavior to its arc rotate camera.
  48824. * @param camera Defines the camera to attach the behavior to
  48825. */
  48826. attach(camera: ArcRotateCamera): void;
  48827. /**
  48828. * Detaches the behavior from its current arc rotate camera.
  48829. */
  48830. detach(): void;
  48831. private _radiusIsAnimating;
  48832. private _radiusBounceTransition;
  48833. private _animatables;
  48834. private _cachedWheelPrecision;
  48835. /**
  48836. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48837. * @param radiusLimit The limit to check against.
  48838. * @return Bool to indicate if at limit.
  48839. */
  48840. private _isRadiusAtLimit;
  48841. /**
  48842. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48843. * @param radiusDelta The delta by which to animate to. Can be negative.
  48844. */
  48845. private _applyBoundRadiusAnimation;
  48846. /**
  48847. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48848. */
  48849. protected _clearAnimationLocks(): void;
  48850. /**
  48851. * Stops and removes all animations that have been applied to the camera
  48852. */
  48853. stopAllAnimations(): void;
  48854. }
  48855. }
  48856. declare module BABYLON {
  48857. /**
  48858. * 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.
  48859. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48860. */
  48861. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48862. /**
  48863. * Gets the name of the behavior.
  48864. */
  48865. get name(): string;
  48866. private _mode;
  48867. private _radiusScale;
  48868. private _positionScale;
  48869. private _defaultElevation;
  48870. private _elevationReturnTime;
  48871. private _elevationReturnWaitTime;
  48872. private _zoomStopsAnimation;
  48873. private _framingTime;
  48874. /**
  48875. * The easing function used by animations
  48876. */
  48877. static EasingFunction: ExponentialEase;
  48878. /**
  48879. * The easing mode used by animations
  48880. */
  48881. static EasingMode: number;
  48882. /**
  48883. * Sets the current mode used by the behavior
  48884. */
  48885. set mode(mode: number);
  48886. /**
  48887. * Gets current mode used by the behavior.
  48888. */
  48889. get mode(): number;
  48890. /**
  48891. * Sets the scale applied to the radius (1 by default)
  48892. */
  48893. set radiusScale(radius: number);
  48894. /**
  48895. * Gets the scale applied to the radius
  48896. */
  48897. get radiusScale(): number;
  48898. /**
  48899. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48900. */
  48901. set positionScale(scale: number);
  48902. /**
  48903. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48904. */
  48905. get positionScale(): number;
  48906. /**
  48907. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48908. * behaviour is triggered, in radians.
  48909. */
  48910. set defaultElevation(elevation: number);
  48911. /**
  48912. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48913. * behaviour is triggered, in radians.
  48914. */
  48915. get defaultElevation(): number;
  48916. /**
  48917. * Sets the time (in milliseconds) taken to return to the default beta position.
  48918. * Negative value indicates camera should not return to default.
  48919. */
  48920. set elevationReturnTime(speed: number);
  48921. /**
  48922. * Gets the time (in milliseconds) taken to return to the default beta position.
  48923. * Negative value indicates camera should not return to default.
  48924. */
  48925. get elevationReturnTime(): number;
  48926. /**
  48927. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48928. */
  48929. set elevationReturnWaitTime(time: number);
  48930. /**
  48931. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48932. */
  48933. get elevationReturnWaitTime(): number;
  48934. /**
  48935. * Sets the flag that indicates if user zooming should stop animation.
  48936. */
  48937. set zoomStopsAnimation(flag: boolean);
  48938. /**
  48939. * Gets the flag that indicates if user zooming should stop animation.
  48940. */
  48941. get zoomStopsAnimation(): boolean;
  48942. /**
  48943. * Sets the transition time when framing the mesh, in milliseconds
  48944. */
  48945. set framingTime(time: number);
  48946. /**
  48947. * Gets the transition time when framing the mesh, in milliseconds
  48948. */
  48949. get framingTime(): number;
  48950. /**
  48951. * Define if the behavior should automatically change the configured
  48952. * camera limits and sensibilities.
  48953. */
  48954. autoCorrectCameraLimitsAndSensibility: boolean;
  48955. private _onPrePointerObservableObserver;
  48956. private _onAfterCheckInputsObserver;
  48957. private _onMeshTargetChangedObserver;
  48958. private _attachedCamera;
  48959. private _isPointerDown;
  48960. private _lastInteractionTime;
  48961. /**
  48962. * Initializes the behavior.
  48963. */
  48964. init(): void;
  48965. /**
  48966. * Attaches the behavior to its arc rotate camera.
  48967. * @param camera Defines the camera to attach the behavior to
  48968. */
  48969. attach(camera: ArcRotateCamera): void;
  48970. /**
  48971. * Detaches the behavior from its current arc rotate camera.
  48972. */
  48973. detach(): void;
  48974. private _animatables;
  48975. private _betaIsAnimating;
  48976. private _betaTransition;
  48977. private _radiusTransition;
  48978. private _vectorTransition;
  48979. /**
  48980. * Targets the given mesh and updates zoom level accordingly.
  48981. * @param mesh The mesh to target.
  48982. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48983. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48984. */
  48985. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48986. /**
  48987. * Targets the given mesh with its children and updates zoom level accordingly.
  48988. * @param mesh The mesh to target.
  48989. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48990. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48991. */
  48992. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48993. /**
  48994. * Targets the given meshes with their children and updates zoom level accordingly.
  48995. * @param meshes The mesh to target.
  48996. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48997. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48998. */
  48999. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49000. /**
  49001. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49002. * @param minimumWorld Determines the smaller position of the bounding box extend
  49003. * @param maximumWorld Determines the bigger position of the bounding box extend
  49004. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49005. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49006. */
  49007. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49008. /**
  49009. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49010. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49011. * frustum width.
  49012. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49013. * to fully enclose the mesh in the viewing frustum.
  49014. */
  49015. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49016. /**
  49017. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49018. * is automatically returned to its default position (expected to be above ground plane).
  49019. */
  49020. private _maintainCameraAboveGround;
  49021. /**
  49022. * Returns the frustum slope based on the canvas ratio and camera FOV
  49023. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49024. */
  49025. private _getFrustumSlope;
  49026. /**
  49027. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49028. */
  49029. private _clearAnimationLocks;
  49030. /**
  49031. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49032. */
  49033. private _applyUserInteraction;
  49034. /**
  49035. * Stops and removes all animations that have been applied to the camera
  49036. */
  49037. stopAllAnimations(): void;
  49038. /**
  49039. * Gets a value indicating if the user is moving the camera
  49040. */
  49041. get isUserIsMoving(): boolean;
  49042. /**
  49043. * The camera can move all the way towards the mesh.
  49044. */
  49045. static IgnoreBoundsSizeMode: number;
  49046. /**
  49047. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49048. */
  49049. static FitFrustumSidesMode: number;
  49050. }
  49051. }
  49052. declare module BABYLON {
  49053. /**
  49054. * Base class for Camera Pointer Inputs.
  49055. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49056. * for example usage.
  49057. */
  49058. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49059. /**
  49060. * Defines the camera the input is attached to.
  49061. */
  49062. abstract camera: Camera;
  49063. /**
  49064. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49065. */
  49066. protected _altKey: boolean;
  49067. protected _ctrlKey: boolean;
  49068. protected _metaKey: boolean;
  49069. protected _shiftKey: boolean;
  49070. /**
  49071. * Which mouse buttons were pressed at time of last mouse event.
  49072. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49073. */
  49074. protected _buttonsPressed: number;
  49075. /**
  49076. * Defines the buttons associated with the input to handle camera move.
  49077. */
  49078. buttons: number[];
  49079. /**
  49080. * Attach the input controls to a specific dom element to get the input from.
  49081. * @param element Defines the element the controls should be listened from
  49082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49083. */
  49084. attachControl(noPreventDefault?: boolean): void;
  49085. /**
  49086. * Detach the current controls from the specified dom element.
  49087. */
  49088. detachControl(): void;
  49089. /**
  49090. * Gets the class name of the current input.
  49091. * @returns the class name
  49092. */
  49093. getClassName(): string;
  49094. /**
  49095. * Get the friendly name associated with the input class.
  49096. * @returns the input friendly name
  49097. */
  49098. getSimpleName(): string;
  49099. /**
  49100. * Called on pointer POINTERDOUBLETAP event.
  49101. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49102. */
  49103. protected onDoubleTap(type: string): void;
  49104. /**
  49105. * Called on pointer POINTERMOVE event if only a single touch is active.
  49106. * Override this method to provide functionality.
  49107. */
  49108. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49109. /**
  49110. * Called on pointer POINTERMOVE event if multiple touches are active.
  49111. * Override this method to provide functionality.
  49112. */
  49113. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49114. /**
  49115. * Called on JS contextmenu event.
  49116. * Override this method to provide functionality.
  49117. */
  49118. protected onContextMenu(evt: PointerEvent): void;
  49119. /**
  49120. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49121. * press.
  49122. * Override this method to provide functionality.
  49123. */
  49124. protected onButtonDown(evt: PointerEvent): void;
  49125. /**
  49126. * Called each time a new POINTERUP event occurs. Ie, for each button
  49127. * release.
  49128. * Override this method to provide functionality.
  49129. */
  49130. protected onButtonUp(evt: PointerEvent): void;
  49131. /**
  49132. * Called when window becomes inactive.
  49133. * Override this method to provide functionality.
  49134. */
  49135. protected onLostFocus(): void;
  49136. private _pointerInput;
  49137. private _observer;
  49138. private _onLostFocus;
  49139. private pointA;
  49140. private pointB;
  49141. }
  49142. }
  49143. declare module BABYLON {
  49144. /**
  49145. * Manage the pointers inputs to control an arc rotate camera.
  49146. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49147. */
  49148. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49149. /**
  49150. * Defines the camera the input is attached to.
  49151. */
  49152. camera: ArcRotateCamera;
  49153. /**
  49154. * Gets the class name of the current input.
  49155. * @returns the class name
  49156. */
  49157. getClassName(): string;
  49158. /**
  49159. * Defines the buttons associated with the input to handle camera move.
  49160. */
  49161. buttons: number[];
  49162. /**
  49163. * Defines the pointer angular sensibility along the X axis or how fast is
  49164. * the camera rotating.
  49165. */
  49166. angularSensibilityX: number;
  49167. /**
  49168. * Defines the pointer angular sensibility along the Y axis or how fast is
  49169. * the camera rotating.
  49170. */
  49171. angularSensibilityY: number;
  49172. /**
  49173. * Defines the pointer pinch precision or how fast is the camera zooming.
  49174. */
  49175. pinchPrecision: number;
  49176. /**
  49177. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49178. * from 0.
  49179. * It defines the percentage of current camera.radius to use as delta when
  49180. * pinch zoom is used.
  49181. */
  49182. pinchDeltaPercentage: number;
  49183. /**
  49184. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49185. * that any object in the plane at the camera's target point will scale
  49186. * perfectly with finger motion.
  49187. * Overrides pinchDeltaPercentage and pinchPrecision.
  49188. */
  49189. useNaturalPinchZoom: boolean;
  49190. /**
  49191. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49192. */
  49193. pinchZoom: boolean;
  49194. /**
  49195. * Defines the pointer panning sensibility or how fast is the camera moving.
  49196. */
  49197. panningSensibility: number;
  49198. /**
  49199. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49200. */
  49201. multiTouchPanning: boolean;
  49202. /**
  49203. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49204. * zoom (pinch) through multitouch.
  49205. */
  49206. multiTouchPanAndZoom: boolean;
  49207. /**
  49208. * Revers pinch action direction.
  49209. */
  49210. pinchInwards: boolean;
  49211. private _isPanClick;
  49212. private _twoFingerActivityCount;
  49213. private _isPinching;
  49214. /**
  49215. * Move camera from multi touch panning positions.
  49216. */
  49217. private _computeMultiTouchPanning;
  49218. /**
  49219. * Move camera from pinch zoom distances.
  49220. */
  49221. private _computePinchZoom;
  49222. /**
  49223. * Called on pointer POINTERMOVE event if only a single touch is active.
  49224. */
  49225. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49226. /**
  49227. * Called on pointer POINTERDOUBLETAP event.
  49228. */
  49229. protected onDoubleTap(type: string): void;
  49230. /**
  49231. * Called on pointer POINTERMOVE event if multiple touches are active.
  49232. */
  49233. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49234. /**
  49235. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49236. * press.
  49237. */
  49238. protected onButtonDown(evt: PointerEvent): void;
  49239. /**
  49240. * Called each time a new POINTERUP event occurs. Ie, for each button
  49241. * release.
  49242. */
  49243. protected onButtonUp(evt: PointerEvent): void;
  49244. /**
  49245. * Called when window becomes inactive.
  49246. */
  49247. protected onLostFocus(): void;
  49248. }
  49249. }
  49250. declare module BABYLON {
  49251. /**
  49252. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49253. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49254. */
  49255. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49256. /**
  49257. * Defines the camera the input is attached to.
  49258. */
  49259. camera: ArcRotateCamera;
  49260. /**
  49261. * Defines the list of key codes associated with the up action (increase alpha)
  49262. */
  49263. keysUp: number[];
  49264. /**
  49265. * Defines the list of key codes associated with the down action (decrease alpha)
  49266. */
  49267. keysDown: number[];
  49268. /**
  49269. * Defines the list of key codes associated with the left action (increase beta)
  49270. */
  49271. keysLeft: number[];
  49272. /**
  49273. * Defines the list of key codes associated with the right action (decrease beta)
  49274. */
  49275. keysRight: number[];
  49276. /**
  49277. * Defines the list of key codes associated with the reset action.
  49278. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49279. */
  49280. keysReset: number[];
  49281. /**
  49282. * Defines the panning sensibility of the inputs.
  49283. * (How fast is the camera panning)
  49284. */
  49285. panningSensibility: number;
  49286. /**
  49287. * Defines the zooming sensibility of the inputs.
  49288. * (How fast is the camera zooming)
  49289. */
  49290. zoomingSensibility: number;
  49291. /**
  49292. * Defines whether maintaining the alt key down switch the movement mode from
  49293. * orientation to zoom.
  49294. */
  49295. useAltToZoom: boolean;
  49296. /**
  49297. * Rotation speed of the camera
  49298. */
  49299. angularSpeed: number;
  49300. private _keys;
  49301. private _ctrlPressed;
  49302. private _altPressed;
  49303. private _onCanvasBlurObserver;
  49304. private _onKeyboardObserver;
  49305. private _engine;
  49306. private _scene;
  49307. /**
  49308. * Attach the input controls to a specific dom element to get the input from.
  49309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49310. */
  49311. attachControl(noPreventDefault?: boolean): void;
  49312. /**
  49313. * Detach the current controls from the specified dom element.
  49314. */
  49315. detachControl(): void;
  49316. /**
  49317. * Update the current camera state depending on the inputs that have been used this frame.
  49318. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49319. */
  49320. checkInputs(): void;
  49321. /**
  49322. * Gets the class name of the current intput.
  49323. * @returns the class name
  49324. */
  49325. getClassName(): string;
  49326. /**
  49327. * Get the friendly name associated with the input class.
  49328. * @returns the input friendly name
  49329. */
  49330. getSimpleName(): string;
  49331. }
  49332. }
  49333. declare module BABYLON {
  49334. /**
  49335. * Manage the mouse wheel inputs to control an arc rotate camera.
  49336. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49337. */
  49338. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49339. /**
  49340. * Defines the camera the input is attached to.
  49341. */
  49342. camera: ArcRotateCamera;
  49343. /**
  49344. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49345. */
  49346. wheelPrecision: number;
  49347. /**
  49348. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49349. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49350. */
  49351. wheelDeltaPercentage: number;
  49352. private _wheel;
  49353. private _observer;
  49354. private computeDeltaFromMouseWheelLegacyEvent;
  49355. /**
  49356. * Attach the input controls to a specific dom element to get the input from.
  49357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49358. */
  49359. attachControl(noPreventDefault?: boolean): void;
  49360. /**
  49361. * Detach the current controls from the specified dom element.
  49362. */
  49363. detachControl(): void;
  49364. /**
  49365. * Gets the class name of the current intput.
  49366. * @returns the class name
  49367. */
  49368. getClassName(): string;
  49369. /**
  49370. * Get the friendly name associated with the input class.
  49371. * @returns the input friendly name
  49372. */
  49373. getSimpleName(): string;
  49374. }
  49375. }
  49376. declare module BABYLON {
  49377. /**
  49378. * Default Inputs manager for the ArcRotateCamera.
  49379. * It groups all the default supported inputs for ease of use.
  49380. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49381. */
  49382. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49383. /**
  49384. * Instantiates a new ArcRotateCameraInputsManager.
  49385. * @param camera Defines the camera the inputs belong to
  49386. */
  49387. constructor(camera: ArcRotateCamera);
  49388. /**
  49389. * Add mouse wheel input support to the input manager.
  49390. * @returns the current input manager
  49391. */
  49392. addMouseWheel(): ArcRotateCameraInputsManager;
  49393. /**
  49394. * Add pointers input support to the input manager.
  49395. * @returns the current input manager
  49396. */
  49397. addPointers(): ArcRotateCameraInputsManager;
  49398. /**
  49399. * Add keyboard input support to the input manager.
  49400. * @returns the current input manager
  49401. */
  49402. addKeyboard(): ArcRotateCameraInputsManager;
  49403. }
  49404. }
  49405. declare module BABYLON {
  49406. /**
  49407. * This represents an orbital type of camera.
  49408. *
  49409. * 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.
  49410. * 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.
  49411. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49412. */
  49413. export class ArcRotateCamera extends TargetCamera {
  49414. /**
  49415. * Defines the rotation angle of the camera along the longitudinal axis.
  49416. */
  49417. alpha: number;
  49418. /**
  49419. * Defines the rotation angle of the camera along the latitudinal axis.
  49420. */
  49421. beta: number;
  49422. /**
  49423. * Defines the radius of the camera from it s target point.
  49424. */
  49425. radius: number;
  49426. protected _target: Vector3;
  49427. protected _targetHost: Nullable<AbstractMesh>;
  49428. /**
  49429. * Defines the target point of the camera.
  49430. * The camera looks towards it form the radius distance.
  49431. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49432. */
  49433. get target(): Vector3;
  49434. set target(value: Vector3);
  49435. /**
  49436. * Define the current local position of the camera in the scene
  49437. */
  49438. get position(): Vector3;
  49439. set position(newPosition: Vector3);
  49440. protected _upToYMatrix: Matrix;
  49441. protected _YToUpMatrix: Matrix;
  49442. /**
  49443. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49444. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49445. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49446. */
  49447. set upVector(vec: Vector3);
  49448. get upVector(): Vector3;
  49449. /**
  49450. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49451. */
  49452. setMatUp(): void;
  49453. /**
  49454. * Current inertia value on the longitudinal axis.
  49455. * The bigger this number the longer it will take for the camera to stop.
  49456. */
  49457. inertialAlphaOffset: number;
  49458. /**
  49459. * Current inertia value on the latitudinal axis.
  49460. * The bigger this number the longer it will take for the camera to stop.
  49461. */
  49462. inertialBetaOffset: number;
  49463. /**
  49464. * Current inertia value on the radius axis.
  49465. * The bigger this number the longer it will take for the camera to stop.
  49466. */
  49467. inertialRadiusOffset: number;
  49468. /**
  49469. * Minimum allowed angle on the longitudinal axis.
  49470. * This can help limiting how the Camera is able to move in the scene.
  49471. */
  49472. lowerAlphaLimit: Nullable<number>;
  49473. /**
  49474. * Maximum allowed angle on the longitudinal axis.
  49475. * This can help limiting how the Camera is able to move in the scene.
  49476. */
  49477. upperAlphaLimit: Nullable<number>;
  49478. /**
  49479. * Minimum allowed angle on the latitudinal axis.
  49480. * This can help limiting how the Camera is able to move in the scene.
  49481. */
  49482. lowerBetaLimit: number;
  49483. /**
  49484. * Maximum allowed angle on the latitudinal axis.
  49485. * This can help limiting how the Camera is able to move in the scene.
  49486. */
  49487. upperBetaLimit: number;
  49488. /**
  49489. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49490. * This can help limiting how the Camera is able to move in the scene.
  49491. */
  49492. lowerRadiusLimit: Nullable<number>;
  49493. /**
  49494. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49495. * This can help limiting how the Camera is able to move in the scene.
  49496. */
  49497. upperRadiusLimit: Nullable<number>;
  49498. /**
  49499. * Defines the current inertia value used during panning of the camera along the X axis.
  49500. */
  49501. inertialPanningX: number;
  49502. /**
  49503. * Defines the current inertia value used during panning of the camera along the Y axis.
  49504. */
  49505. inertialPanningY: number;
  49506. /**
  49507. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49508. * Basically if your fingers moves away from more than this distance you will be considered
  49509. * in pinch mode.
  49510. */
  49511. pinchToPanMaxDistance: number;
  49512. /**
  49513. * Defines the maximum distance the camera can pan.
  49514. * This could help keeping the cammera always in your scene.
  49515. */
  49516. panningDistanceLimit: Nullable<number>;
  49517. /**
  49518. * Defines the target of the camera before paning.
  49519. */
  49520. panningOriginTarget: Vector3;
  49521. /**
  49522. * Defines the value of the inertia used during panning.
  49523. * 0 would mean stop inertia and one would mean no decelleration at all.
  49524. */
  49525. panningInertia: number;
  49526. /**
  49527. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49528. */
  49529. get angularSensibilityX(): number;
  49530. set angularSensibilityX(value: number);
  49531. /**
  49532. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49533. */
  49534. get angularSensibilityY(): number;
  49535. set angularSensibilityY(value: number);
  49536. /**
  49537. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49538. */
  49539. get pinchPrecision(): number;
  49540. set pinchPrecision(value: number);
  49541. /**
  49542. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49543. * It will be used instead of pinchDeltaPrecision if different from 0.
  49544. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49545. */
  49546. get pinchDeltaPercentage(): number;
  49547. set pinchDeltaPercentage(value: number);
  49548. /**
  49549. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49550. * and pinch delta percentage.
  49551. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49552. * that any object in the plane at the camera's target point will scale
  49553. * perfectly with finger motion.
  49554. */
  49555. get useNaturalPinchZoom(): boolean;
  49556. set useNaturalPinchZoom(value: boolean);
  49557. /**
  49558. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49559. */
  49560. get panningSensibility(): number;
  49561. set panningSensibility(value: number);
  49562. /**
  49563. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49564. */
  49565. get keysUp(): number[];
  49566. set keysUp(value: number[]);
  49567. /**
  49568. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49569. */
  49570. get keysDown(): number[];
  49571. set keysDown(value: number[]);
  49572. /**
  49573. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49574. */
  49575. get keysLeft(): number[];
  49576. set keysLeft(value: number[]);
  49577. /**
  49578. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49579. */
  49580. get keysRight(): number[];
  49581. set keysRight(value: number[]);
  49582. /**
  49583. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49584. */
  49585. get wheelPrecision(): number;
  49586. set wheelPrecision(value: number);
  49587. /**
  49588. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49589. * It will be used instead of pinchDeltaPrecision if different from 0.
  49590. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49591. */
  49592. get wheelDeltaPercentage(): number;
  49593. set wheelDeltaPercentage(value: number);
  49594. /**
  49595. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49596. */
  49597. zoomOnFactor: number;
  49598. /**
  49599. * Defines a screen offset for the camera position.
  49600. */
  49601. targetScreenOffset: Vector2;
  49602. /**
  49603. * Allows the camera to be completely reversed.
  49604. * If false the camera can not arrive upside down.
  49605. */
  49606. allowUpsideDown: boolean;
  49607. /**
  49608. * Define if double tap/click is used to restore the previously saved state of the camera.
  49609. */
  49610. useInputToRestoreState: boolean;
  49611. /** @hidden */
  49612. _viewMatrix: Matrix;
  49613. /** @hidden */
  49614. _useCtrlForPanning: boolean;
  49615. /** @hidden */
  49616. _panningMouseButton: number;
  49617. /**
  49618. * Defines the input associated to the camera.
  49619. */
  49620. inputs: ArcRotateCameraInputsManager;
  49621. /** @hidden */
  49622. _reset: () => void;
  49623. /**
  49624. * Defines the allowed panning axis.
  49625. */
  49626. panningAxis: Vector3;
  49627. protected _transformedDirection: Vector3;
  49628. private _bouncingBehavior;
  49629. /**
  49630. * Gets the bouncing behavior of the camera if it has been enabled.
  49631. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49632. */
  49633. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49634. /**
  49635. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49636. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49637. */
  49638. get useBouncingBehavior(): boolean;
  49639. set useBouncingBehavior(value: boolean);
  49640. private _framingBehavior;
  49641. /**
  49642. * Gets the framing behavior of the camera if it has been enabled.
  49643. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49644. */
  49645. get framingBehavior(): Nullable<FramingBehavior>;
  49646. /**
  49647. * Defines if the framing behavior of the camera is enabled on the camera.
  49648. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49649. */
  49650. get useFramingBehavior(): boolean;
  49651. set useFramingBehavior(value: boolean);
  49652. private _autoRotationBehavior;
  49653. /**
  49654. * Gets the auto rotation behavior of the camera if it has been enabled.
  49655. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49656. */
  49657. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49658. /**
  49659. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49660. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49661. */
  49662. get useAutoRotationBehavior(): boolean;
  49663. set useAutoRotationBehavior(value: boolean);
  49664. /**
  49665. * Observable triggered when the mesh target has been changed on the camera.
  49666. */
  49667. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49668. /**
  49669. * Event raised when the camera is colliding with a mesh.
  49670. */
  49671. onCollide: (collidedMesh: AbstractMesh) => void;
  49672. /**
  49673. * Defines whether the camera should check collision with the objects oh the scene.
  49674. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49675. */
  49676. checkCollisions: boolean;
  49677. /**
  49678. * Defines the collision radius of the camera.
  49679. * This simulates a sphere around the camera.
  49680. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49681. */
  49682. collisionRadius: Vector3;
  49683. protected _collider: Collider;
  49684. protected _previousPosition: Vector3;
  49685. protected _collisionVelocity: Vector3;
  49686. protected _newPosition: Vector3;
  49687. protected _previousAlpha: number;
  49688. protected _previousBeta: number;
  49689. protected _previousRadius: number;
  49690. protected _collisionTriggered: boolean;
  49691. protected _targetBoundingCenter: Nullable<Vector3>;
  49692. private _computationVector;
  49693. /**
  49694. * Instantiates a new ArcRotateCamera in a given scene
  49695. * @param name Defines the name of the camera
  49696. * @param alpha Defines the camera rotation along the logitudinal axis
  49697. * @param beta Defines the camera rotation along the latitudinal axis
  49698. * @param radius Defines the camera distance from its target
  49699. * @param target Defines the camera target
  49700. * @param scene Defines the scene the camera belongs to
  49701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49702. */
  49703. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49704. /** @hidden */
  49705. _initCache(): void;
  49706. /** @hidden */
  49707. _updateCache(ignoreParentClass?: boolean): void;
  49708. protected _getTargetPosition(): Vector3;
  49709. private _storedAlpha;
  49710. private _storedBeta;
  49711. private _storedRadius;
  49712. private _storedTarget;
  49713. private _storedTargetScreenOffset;
  49714. /**
  49715. * Stores the current state of the camera (alpha, beta, radius and target)
  49716. * @returns the camera itself
  49717. */
  49718. storeState(): Camera;
  49719. /**
  49720. * @hidden
  49721. * Restored camera state. You must call storeState() first
  49722. */
  49723. _restoreStateValues(): boolean;
  49724. /** @hidden */
  49725. _isSynchronizedViewMatrix(): boolean;
  49726. /**
  49727. * Attach the input controls to a specific dom element to get the input from.
  49728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49729. */
  49730. attachControl(noPreventDefault?: boolean): void;
  49731. /**
  49732. * Attach the input controls to a specific dom element to get the input from.
  49733. * @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
  49734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49735. */
  49736. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49737. /**
  49738. * Attached controls to the current camera.
  49739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49740. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49741. */
  49742. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49743. /**
  49744. * Attached controls to the current camera.
  49745. * @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
  49746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49747. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49748. */
  49749. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49750. /**
  49751. * Attached controls to the current camera.
  49752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49753. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49754. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49755. */
  49756. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49757. /**
  49758. * Detach the current controls from the specified dom element.
  49759. */
  49760. detachControl(): void;
  49761. /**
  49762. * Detach the current controls from the specified dom element.
  49763. * @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
  49764. */
  49765. detachControl(ignored: any): void;
  49766. /** @hidden */
  49767. _checkInputs(): void;
  49768. protected _checkLimits(): void;
  49769. /**
  49770. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49771. */
  49772. rebuildAnglesAndRadius(): void;
  49773. /**
  49774. * Use a position to define the current camera related information like alpha, beta and radius
  49775. * @param position Defines the position to set the camera at
  49776. */
  49777. setPosition(position: Vector3): void;
  49778. /**
  49779. * Defines the target the camera should look at.
  49780. * This will automatically adapt alpha beta and radius to fit within the new target.
  49781. * @param target Defines the new target as a Vector or a mesh
  49782. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49783. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49784. */
  49785. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49786. /** @hidden */
  49787. _getViewMatrix(): Matrix;
  49788. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49789. /**
  49790. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49791. * @param meshes Defines the mesh to zoom on
  49792. * @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)
  49793. */
  49794. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49795. /**
  49796. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49797. * The target will be changed but the radius
  49798. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49799. * @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)
  49800. */
  49801. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49802. min: Vector3;
  49803. max: Vector3;
  49804. distance: number;
  49805. }, doNotUpdateMaxZ?: boolean): void;
  49806. /**
  49807. * @override
  49808. * Override Camera.createRigCamera
  49809. */
  49810. createRigCamera(name: string, cameraIndex: number): Camera;
  49811. /**
  49812. * @hidden
  49813. * @override
  49814. * Override Camera._updateRigCameras
  49815. */
  49816. _updateRigCameras(): void;
  49817. /**
  49818. * Destroy the camera and release the current resources hold by it.
  49819. */
  49820. dispose(): void;
  49821. /**
  49822. * Gets the current object class name.
  49823. * @return the class name
  49824. */
  49825. getClassName(): string;
  49826. }
  49827. }
  49828. declare module BABYLON {
  49829. /**
  49830. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49831. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49832. */
  49833. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49834. /**
  49835. * Gets the name of the behavior.
  49836. */
  49837. get name(): string;
  49838. private _zoomStopsAnimation;
  49839. private _idleRotationSpeed;
  49840. private _idleRotationWaitTime;
  49841. private _idleRotationSpinupTime;
  49842. /**
  49843. * Sets the flag that indicates if user zooming should stop animation.
  49844. */
  49845. set zoomStopsAnimation(flag: boolean);
  49846. /**
  49847. * Gets the flag that indicates if user zooming should stop animation.
  49848. */
  49849. get zoomStopsAnimation(): boolean;
  49850. /**
  49851. * Sets the default speed at which the camera rotates around the model.
  49852. */
  49853. set idleRotationSpeed(speed: number);
  49854. /**
  49855. * Gets the default speed at which the camera rotates around the model.
  49856. */
  49857. get idleRotationSpeed(): number;
  49858. /**
  49859. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49860. */
  49861. set idleRotationWaitTime(time: number);
  49862. /**
  49863. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49864. */
  49865. get idleRotationWaitTime(): number;
  49866. /**
  49867. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49868. */
  49869. set idleRotationSpinupTime(time: number);
  49870. /**
  49871. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49872. */
  49873. get idleRotationSpinupTime(): number;
  49874. /**
  49875. * Gets a value indicating if the camera is currently rotating because of this behavior
  49876. */
  49877. get rotationInProgress(): boolean;
  49878. private _onPrePointerObservableObserver;
  49879. private _onAfterCheckInputsObserver;
  49880. private _attachedCamera;
  49881. private _isPointerDown;
  49882. private _lastFrameTime;
  49883. private _lastInteractionTime;
  49884. private _cameraRotationSpeed;
  49885. /**
  49886. * Initializes the behavior.
  49887. */
  49888. init(): void;
  49889. /**
  49890. * Attaches the behavior to its arc rotate camera.
  49891. * @param camera Defines the camera to attach the behavior to
  49892. */
  49893. attach(camera: ArcRotateCamera): void;
  49894. /**
  49895. * Detaches the behavior from its current arc rotate camera.
  49896. */
  49897. detach(): void;
  49898. /**
  49899. * Returns true if user is scrolling.
  49900. * @return true if user is scrolling.
  49901. */
  49902. private _userIsZooming;
  49903. private _lastFrameRadius;
  49904. private _shouldAnimationStopForInteraction;
  49905. /**
  49906. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49907. */
  49908. private _applyUserInteraction;
  49909. private _userIsMoving;
  49910. }
  49911. }
  49912. declare module BABYLON {
  49913. /**
  49914. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49915. */
  49916. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49917. private ui;
  49918. /**
  49919. * The name of the behavior
  49920. */
  49921. name: string;
  49922. /**
  49923. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49924. */
  49925. distanceAwayFromFace: number;
  49926. /**
  49927. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49928. */
  49929. distanceAwayFromBottomOfFace: number;
  49930. private _faceVectors;
  49931. private _target;
  49932. private _scene;
  49933. private _onRenderObserver;
  49934. private _tmpMatrix;
  49935. private _tmpVector;
  49936. /**
  49937. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  49938. * @param ui The transform node that should be attched to the mesh
  49939. */
  49940. constructor(ui: TransformNode);
  49941. /**
  49942. * Initializes the behavior
  49943. */
  49944. init(): void;
  49945. private _closestFace;
  49946. private _zeroVector;
  49947. private _lookAtTmpMatrix;
  49948. private _lookAtToRef;
  49949. /**
  49950. * Attaches the AttachToBoxBehavior to the passed in mesh
  49951. * @param target The mesh that the specified node will be attached to
  49952. */
  49953. attach(target: Mesh): void;
  49954. /**
  49955. * Detaches the behavior from the mesh
  49956. */
  49957. detach(): void;
  49958. }
  49959. }
  49960. declare module BABYLON {
  49961. /**
  49962. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  49963. */
  49964. export class FadeInOutBehavior implements Behavior<Mesh> {
  49965. /**
  49966. * Time in milliseconds to delay before fading in (Default: 0)
  49967. */
  49968. delay: number;
  49969. /**
  49970. * Time in milliseconds for the mesh to fade in (Default: 300)
  49971. */
  49972. fadeInTime: number;
  49973. private _millisecondsPerFrame;
  49974. private _hovered;
  49975. private _hoverValue;
  49976. private _ownerNode;
  49977. /**
  49978. * Instatiates the FadeInOutBehavior
  49979. */
  49980. constructor();
  49981. /**
  49982. * The name of the behavior
  49983. */
  49984. get name(): string;
  49985. /**
  49986. * Initializes the behavior
  49987. */
  49988. init(): void;
  49989. /**
  49990. * Attaches the fade behavior on the passed in mesh
  49991. * @param ownerNode The mesh that will be faded in/out once attached
  49992. */
  49993. attach(ownerNode: Mesh): void;
  49994. /**
  49995. * Detaches the behavior from the mesh
  49996. */
  49997. detach(): void;
  49998. /**
  49999. * Triggers the mesh to begin fading in or out
  50000. * @param value if the object should fade in or out (true to fade in)
  50001. */
  50002. fadeIn(value: boolean): void;
  50003. private _update;
  50004. private _setAllVisibility;
  50005. }
  50006. }
  50007. declare module BABYLON {
  50008. /**
  50009. * Class containing a set of static utilities functions for managing Pivots
  50010. * @hidden
  50011. */
  50012. export class PivotTools {
  50013. private static _PivotCached;
  50014. private static _OldPivotPoint;
  50015. private static _PivotTranslation;
  50016. private static _PivotTmpVector;
  50017. private static _PivotPostMultiplyPivotMatrix;
  50018. /** @hidden */
  50019. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50020. /** @hidden */
  50021. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50022. }
  50023. }
  50024. declare module BABYLON {
  50025. /**
  50026. * Class containing static functions to help procedurally build meshes
  50027. */
  50028. export class PlaneBuilder {
  50029. /**
  50030. * Creates a plane mesh
  50031. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50032. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50033. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50035. * * 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
  50036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50037. * @param name defines the name of the mesh
  50038. * @param options defines the options used to create the mesh
  50039. * @param scene defines the hosting scene
  50040. * @returns the plane mesh
  50041. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50042. */
  50043. static CreatePlane(name: string, options: {
  50044. size?: number;
  50045. width?: number;
  50046. height?: number;
  50047. sideOrientation?: number;
  50048. frontUVs?: Vector4;
  50049. backUVs?: Vector4;
  50050. updatable?: boolean;
  50051. sourcePlane?: Plane;
  50052. }, scene?: Nullable<Scene>): Mesh;
  50053. }
  50054. }
  50055. declare module BABYLON {
  50056. /**
  50057. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50058. */
  50059. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50060. private static _AnyMouseID;
  50061. /**
  50062. * Abstract mesh the behavior is set on
  50063. */
  50064. attachedNode: AbstractMesh;
  50065. private _dragPlane;
  50066. private _scene;
  50067. private _pointerObserver;
  50068. private _beforeRenderObserver;
  50069. private static _planeScene;
  50070. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50071. /**
  50072. * 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)
  50073. */
  50074. maxDragAngle: number;
  50075. /**
  50076. * @hidden
  50077. */
  50078. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50079. /**
  50080. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50081. */
  50082. currentDraggingPointerID: number;
  50083. /**
  50084. * The last position where the pointer hit the drag plane in world space
  50085. */
  50086. lastDragPosition: Vector3;
  50087. /**
  50088. * If the behavior is currently in a dragging state
  50089. */
  50090. dragging: boolean;
  50091. /**
  50092. * 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)
  50093. */
  50094. dragDeltaRatio: number;
  50095. /**
  50096. * If the drag plane orientation should be updated during the dragging (Default: true)
  50097. */
  50098. updateDragPlane: boolean;
  50099. private _debugMode;
  50100. private _moving;
  50101. /**
  50102. * Fires each time the attached mesh is dragged with the pointer
  50103. * * delta between last drag position and current drag position in world space
  50104. * * dragDistance along the drag axis
  50105. * * dragPlaneNormal normal of the current drag plane used during the drag
  50106. * * dragPlanePoint in world space where the drag intersects the drag plane
  50107. */
  50108. onDragObservable: Observable<{
  50109. delta: Vector3;
  50110. dragPlanePoint: Vector3;
  50111. dragPlaneNormal: Vector3;
  50112. dragDistance: number;
  50113. pointerId: number;
  50114. }>;
  50115. /**
  50116. * Fires each time a drag begins (eg. mouse down on mesh)
  50117. */
  50118. onDragStartObservable: Observable<{
  50119. dragPlanePoint: Vector3;
  50120. pointerId: number;
  50121. }>;
  50122. /**
  50123. * Fires each time a drag ends (eg. mouse release after drag)
  50124. */
  50125. onDragEndObservable: Observable<{
  50126. dragPlanePoint: Vector3;
  50127. pointerId: number;
  50128. }>;
  50129. /**
  50130. * If the attached mesh should be moved when dragged
  50131. */
  50132. moveAttached: boolean;
  50133. /**
  50134. * If the drag behavior will react to drag events (Default: true)
  50135. */
  50136. enabled: boolean;
  50137. /**
  50138. * If pointer events should start and release the drag (Default: true)
  50139. */
  50140. startAndReleaseDragOnPointerEvents: boolean;
  50141. /**
  50142. * If camera controls should be detached during the drag
  50143. */
  50144. detachCameraControls: boolean;
  50145. /**
  50146. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50147. */
  50148. useObjectOrientationForDragging: boolean;
  50149. private _options;
  50150. /**
  50151. * Gets the options used by the behavior
  50152. */
  50153. get options(): {
  50154. dragAxis?: Vector3;
  50155. dragPlaneNormal?: Vector3;
  50156. };
  50157. /**
  50158. * Sets the options used by the behavior
  50159. */
  50160. set options(options: {
  50161. dragAxis?: Vector3;
  50162. dragPlaneNormal?: Vector3;
  50163. });
  50164. /**
  50165. * Creates a pointer drag behavior that can be attached to a mesh
  50166. * @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)
  50167. */
  50168. constructor(options?: {
  50169. dragAxis?: Vector3;
  50170. dragPlaneNormal?: Vector3;
  50171. });
  50172. /**
  50173. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50174. */
  50175. validateDrag: (targetPosition: Vector3) => boolean;
  50176. /**
  50177. * The name of the behavior
  50178. */
  50179. get name(): string;
  50180. /**
  50181. * Initializes the behavior
  50182. */
  50183. init(): void;
  50184. private _tmpVector;
  50185. private _alternatePickedPoint;
  50186. private _worldDragAxis;
  50187. private _targetPosition;
  50188. private _attachedToElement;
  50189. /**
  50190. * Attaches the drag behavior the passed in mesh
  50191. * @param ownerNode The mesh that will be dragged around once attached
  50192. * @param predicate Predicate to use for pick filtering
  50193. */
  50194. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50195. /**
  50196. * Force relase the drag action by code.
  50197. */
  50198. releaseDrag(): void;
  50199. private _startDragRay;
  50200. private _lastPointerRay;
  50201. /**
  50202. * Simulates the start of a pointer drag event on the behavior
  50203. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50204. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50205. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50206. */
  50207. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50208. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50209. private _dragDelta;
  50210. protected _moveDrag(ray: Ray): void;
  50211. private _pickWithRayOnDragPlane;
  50212. private _pointA;
  50213. private _pointC;
  50214. private _localAxis;
  50215. private _lookAt;
  50216. private _updateDragPlanePosition;
  50217. /**
  50218. * Detaches the behavior from the mesh
  50219. */
  50220. detach(): void;
  50221. }
  50222. }
  50223. declare module BABYLON {
  50224. /**
  50225. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50226. */
  50227. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50228. private _dragBehaviorA;
  50229. private _dragBehaviorB;
  50230. private _startDistance;
  50231. private _initialScale;
  50232. private _targetScale;
  50233. private _ownerNode;
  50234. private _sceneRenderObserver;
  50235. /**
  50236. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50237. */
  50238. constructor();
  50239. /**
  50240. * The name of the behavior
  50241. */
  50242. get name(): string;
  50243. /**
  50244. * Initializes the behavior
  50245. */
  50246. init(): void;
  50247. private _getCurrentDistance;
  50248. /**
  50249. * Attaches the scale behavior the passed in mesh
  50250. * @param ownerNode The mesh that will be scaled around once attached
  50251. */
  50252. attach(ownerNode: Mesh): void;
  50253. /**
  50254. * Detaches the behavior from the mesh
  50255. */
  50256. detach(): void;
  50257. }
  50258. }
  50259. declare module BABYLON {
  50260. /**
  50261. * 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
  50262. */
  50263. export class SixDofDragBehavior implements Behavior<Mesh> {
  50264. private static _virtualScene;
  50265. private _ownerNode;
  50266. private _sceneRenderObserver;
  50267. private _scene;
  50268. private _targetPosition;
  50269. private _virtualOriginMesh;
  50270. private _virtualDragMesh;
  50271. private _pointerObserver;
  50272. private _moving;
  50273. private _startingOrientation;
  50274. private _attachedToElement;
  50275. /**
  50276. * 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)
  50277. */
  50278. private zDragFactor;
  50279. /**
  50280. * If the object should rotate to face the drag origin
  50281. */
  50282. rotateDraggedObject: boolean;
  50283. /**
  50284. * If the behavior is currently in a dragging state
  50285. */
  50286. dragging: boolean;
  50287. /**
  50288. * 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)
  50289. */
  50290. dragDeltaRatio: number;
  50291. /**
  50292. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50293. */
  50294. currentDraggingPointerID: number;
  50295. /**
  50296. * If camera controls should be detached during the drag
  50297. */
  50298. detachCameraControls: boolean;
  50299. /**
  50300. * Fires each time a drag starts
  50301. */
  50302. onDragStartObservable: Observable<{}>;
  50303. /**
  50304. * Fires each time a drag happens
  50305. */
  50306. onDragObservable: Observable<void>;
  50307. /**
  50308. * Fires each time a drag ends (eg. mouse release after drag)
  50309. */
  50310. onDragEndObservable: Observable<{}>;
  50311. /**
  50312. * 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
  50313. */
  50314. constructor();
  50315. /**
  50316. * The name of the behavior
  50317. */
  50318. get name(): string;
  50319. /**
  50320. * Initializes the behavior
  50321. */
  50322. init(): void;
  50323. /**
  50324. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50325. */
  50326. private get _pointerCamera();
  50327. /**
  50328. * Attaches the scale behavior the passed in mesh
  50329. * @param ownerNode The mesh that will be scaled around once attached
  50330. */
  50331. attach(ownerNode: Mesh): void;
  50332. /**
  50333. * Detaches the behavior from the mesh
  50334. */
  50335. detach(): void;
  50336. }
  50337. }
  50338. declare module BABYLON {
  50339. /**
  50340. * Class used to apply inverse kinematics to bones
  50341. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50342. */
  50343. export class BoneIKController {
  50344. private static _tmpVecs;
  50345. private static _tmpQuat;
  50346. private static _tmpMats;
  50347. /**
  50348. * Gets or sets the target mesh
  50349. */
  50350. targetMesh: AbstractMesh;
  50351. /** Gets or sets the mesh used as pole */
  50352. poleTargetMesh: AbstractMesh;
  50353. /**
  50354. * Gets or sets the bone used as pole
  50355. */
  50356. poleTargetBone: Nullable<Bone>;
  50357. /**
  50358. * Gets or sets the target position
  50359. */
  50360. targetPosition: Vector3;
  50361. /**
  50362. * Gets or sets the pole target position
  50363. */
  50364. poleTargetPosition: Vector3;
  50365. /**
  50366. * Gets or sets the pole target local offset
  50367. */
  50368. poleTargetLocalOffset: Vector3;
  50369. /**
  50370. * Gets or sets the pole angle
  50371. */
  50372. poleAngle: number;
  50373. /**
  50374. * Gets or sets the mesh associated with the controller
  50375. */
  50376. mesh: AbstractMesh;
  50377. /**
  50378. * 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)
  50379. */
  50380. slerpAmount: number;
  50381. private _bone1Quat;
  50382. private _bone1Mat;
  50383. private _bone2Ang;
  50384. private _bone1;
  50385. private _bone2;
  50386. private _bone1Length;
  50387. private _bone2Length;
  50388. private _maxAngle;
  50389. private _maxReach;
  50390. private _rightHandedSystem;
  50391. private _bendAxis;
  50392. private _slerping;
  50393. private _adjustRoll;
  50394. /**
  50395. * Gets or sets maximum allowed angle
  50396. */
  50397. get maxAngle(): number;
  50398. set maxAngle(value: number);
  50399. /**
  50400. * Creates a new BoneIKController
  50401. * @param mesh defines the mesh to control
  50402. * @param bone defines the bone to control
  50403. * @param options defines options to set up the controller
  50404. */
  50405. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50406. targetMesh?: AbstractMesh;
  50407. poleTargetMesh?: AbstractMesh;
  50408. poleTargetBone?: Bone;
  50409. poleTargetLocalOffset?: Vector3;
  50410. poleAngle?: number;
  50411. bendAxis?: Vector3;
  50412. maxAngle?: number;
  50413. slerpAmount?: number;
  50414. });
  50415. private _setMaxAngle;
  50416. /**
  50417. * Force the controller to update the bones
  50418. */
  50419. update(): void;
  50420. }
  50421. }
  50422. declare module BABYLON {
  50423. /**
  50424. * Class used to make a bone look toward a point in space
  50425. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50426. */
  50427. export class BoneLookController {
  50428. private static _tmpVecs;
  50429. private static _tmpQuat;
  50430. private static _tmpMats;
  50431. /**
  50432. * The target Vector3 that the bone will look at
  50433. */
  50434. target: Vector3;
  50435. /**
  50436. * The mesh that the bone is attached to
  50437. */
  50438. mesh: AbstractMesh;
  50439. /**
  50440. * The bone that will be looking to the target
  50441. */
  50442. bone: Bone;
  50443. /**
  50444. * The up axis of the coordinate system that is used when the bone is rotated
  50445. */
  50446. upAxis: Vector3;
  50447. /**
  50448. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50449. */
  50450. upAxisSpace: Space;
  50451. /**
  50452. * Used to make an adjustment to the yaw of the bone
  50453. */
  50454. adjustYaw: number;
  50455. /**
  50456. * Used to make an adjustment to the pitch of the bone
  50457. */
  50458. adjustPitch: number;
  50459. /**
  50460. * Used to make an adjustment to the roll of the bone
  50461. */
  50462. adjustRoll: number;
  50463. /**
  50464. * 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)
  50465. */
  50466. slerpAmount: number;
  50467. private _minYaw;
  50468. private _maxYaw;
  50469. private _minPitch;
  50470. private _maxPitch;
  50471. private _minYawSin;
  50472. private _minYawCos;
  50473. private _maxYawSin;
  50474. private _maxYawCos;
  50475. private _midYawConstraint;
  50476. private _minPitchTan;
  50477. private _maxPitchTan;
  50478. private _boneQuat;
  50479. private _slerping;
  50480. private _transformYawPitch;
  50481. private _transformYawPitchInv;
  50482. private _firstFrameSkipped;
  50483. private _yawRange;
  50484. private _fowardAxis;
  50485. /**
  50486. * Gets or sets the minimum yaw angle that the bone can look to
  50487. */
  50488. get minYaw(): number;
  50489. set minYaw(value: number);
  50490. /**
  50491. * Gets or sets the maximum yaw angle that the bone can look to
  50492. */
  50493. get maxYaw(): number;
  50494. set maxYaw(value: number);
  50495. /**
  50496. * Gets or sets the minimum pitch angle that the bone can look to
  50497. */
  50498. get minPitch(): number;
  50499. set minPitch(value: number);
  50500. /**
  50501. * Gets or sets the maximum pitch angle that the bone can look to
  50502. */
  50503. get maxPitch(): number;
  50504. set maxPitch(value: number);
  50505. /**
  50506. * Create a BoneLookController
  50507. * @param mesh the mesh that the bone belongs to
  50508. * @param bone the bone that will be looking to the target
  50509. * @param target the target Vector3 to look at
  50510. * @param options optional settings:
  50511. * * maxYaw: the maximum angle the bone will yaw to
  50512. * * minYaw: the minimum angle the bone will yaw to
  50513. * * maxPitch: the maximum angle the bone will pitch to
  50514. * * minPitch: the minimum angle the bone will yaw to
  50515. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50516. * * upAxis: the up axis of the coordinate system
  50517. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50518. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50519. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50520. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50521. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50522. * * adjustRoll: used to make an adjustment to the roll of the bone
  50523. **/
  50524. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50525. maxYaw?: number;
  50526. minYaw?: number;
  50527. maxPitch?: number;
  50528. minPitch?: number;
  50529. slerpAmount?: number;
  50530. upAxis?: Vector3;
  50531. upAxisSpace?: Space;
  50532. yawAxis?: Vector3;
  50533. pitchAxis?: Vector3;
  50534. adjustYaw?: number;
  50535. adjustPitch?: number;
  50536. adjustRoll?: number;
  50537. });
  50538. /**
  50539. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50540. */
  50541. update(): void;
  50542. private _getAngleDiff;
  50543. private _getAngleBetween;
  50544. private _isAngleBetween;
  50545. }
  50546. }
  50547. declare module BABYLON {
  50548. /**
  50549. * Manage the gamepad inputs to control an arc rotate camera.
  50550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50551. */
  50552. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50553. /**
  50554. * Defines the camera the input is attached to.
  50555. */
  50556. camera: ArcRotateCamera;
  50557. /**
  50558. * Defines the gamepad the input is gathering event from.
  50559. */
  50560. gamepad: Nullable<Gamepad>;
  50561. /**
  50562. * Defines the gamepad rotation sensiblity.
  50563. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50564. */
  50565. gamepadRotationSensibility: number;
  50566. /**
  50567. * Defines the gamepad move sensiblity.
  50568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50569. */
  50570. gamepadMoveSensibility: number;
  50571. private _yAxisScale;
  50572. /**
  50573. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50574. */
  50575. get invertYAxis(): boolean;
  50576. set invertYAxis(value: boolean);
  50577. private _onGamepadConnectedObserver;
  50578. private _onGamepadDisconnectedObserver;
  50579. /**
  50580. * Attach the input controls to a specific dom element to get the input from.
  50581. */
  50582. attachControl(): void;
  50583. /**
  50584. * Detach the current controls from the specified dom element.
  50585. */
  50586. detachControl(): void;
  50587. /**
  50588. * Update the current camera state depending on the inputs that have been used this frame.
  50589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50590. */
  50591. checkInputs(): void;
  50592. /**
  50593. * Gets the class name of the current intput.
  50594. * @returns the class name
  50595. */
  50596. getClassName(): string;
  50597. /**
  50598. * Get the friendly name associated with the input class.
  50599. * @returns the input friendly name
  50600. */
  50601. getSimpleName(): string;
  50602. }
  50603. }
  50604. declare module BABYLON {
  50605. interface ArcRotateCameraInputsManager {
  50606. /**
  50607. * Add orientation input support to the input manager.
  50608. * @returns the current input manager
  50609. */
  50610. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50611. }
  50612. /**
  50613. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50615. */
  50616. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50617. /**
  50618. * Defines the camera the input is attached to.
  50619. */
  50620. camera: ArcRotateCamera;
  50621. /**
  50622. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50623. */
  50624. alphaCorrection: number;
  50625. /**
  50626. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50627. */
  50628. gammaCorrection: number;
  50629. private _alpha;
  50630. private _gamma;
  50631. private _dirty;
  50632. private _deviceOrientationHandler;
  50633. /**
  50634. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50635. */
  50636. constructor();
  50637. /**
  50638. * Attach the input controls to a specific dom element to get the input from.
  50639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50640. */
  50641. attachControl(noPreventDefault?: boolean): void;
  50642. /** @hidden */
  50643. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50644. /**
  50645. * Update the current camera state depending on the inputs that have been used this frame.
  50646. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50647. */
  50648. checkInputs(): void;
  50649. /**
  50650. * Detach the current controls from the specified dom element.
  50651. */
  50652. detachControl(): void;
  50653. /**
  50654. * Gets the class name of the current intput.
  50655. * @returns the class name
  50656. */
  50657. getClassName(): string;
  50658. /**
  50659. * Get the friendly name associated with the input class.
  50660. * @returns the input friendly name
  50661. */
  50662. getSimpleName(): string;
  50663. }
  50664. }
  50665. declare module BABYLON {
  50666. /**
  50667. * Listen to mouse events to control the camera.
  50668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50669. */
  50670. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50671. /**
  50672. * Defines the camera the input is attached to.
  50673. */
  50674. camera: FlyCamera;
  50675. /**
  50676. * Defines if touch is enabled. (Default is true.)
  50677. */
  50678. touchEnabled: boolean;
  50679. /**
  50680. * Defines the buttons associated with the input to handle camera rotation.
  50681. */
  50682. buttons: number[];
  50683. /**
  50684. * Assign buttons for Yaw control.
  50685. */
  50686. buttonsYaw: number[];
  50687. /**
  50688. * Assign buttons for Pitch control.
  50689. */
  50690. buttonsPitch: number[];
  50691. /**
  50692. * Assign buttons for Roll control.
  50693. */
  50694. buttonsRoll: number[];
  50695. /**
  50696. * Detect if any button is being pressed while mouse is moved.
  50697. * -1 = Mouse locked.
  50698. * 0 = Left button.
  50699. * 1 = Middle Button.
  50700. * 2 = Right Button.
  50701. */
  50702. activeButton: number;
  50703. /**
  50704. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50705. * Higher values reduce its sensitivity.
  50706. */
  50707. angularSensibility: number;
  50708. private _observer;
  50709. private _rollObserver;
  50710. private previousPosition;
  50711. private noPreventDefault;
  50712. private element;
  50713. /**
  50714. * Listen to mouse events to control the camera.
  50715. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50717. */
  50718. constructor(touchEnabled?: boolean);
  50719. /**
  50720. * Attach the mouse control to the HTML DOM element.
  50721. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50722. */
  50723. attachControl(noPreventDefault?: boolean): void;
  50724. /**
  50725. * Detach the current controls from the specified dom element.
  50726. */
  50727. detachControl(): void;
  50728. /**
  50729. * Gets the class name of the current input.
  50730. * @returns the class name.
  50731. */
  50732. getClassName(): string;
  50733. /**
  50734. * Get the friendly name associated with the input class.
  50735. * @returns the input's friendly name.
  50736. */
  50737. getSimpleName(): string;
  50738. private _pointerInput;
  50739. private _onMouseMove;
  50740. /**
  50741. * Rotate camera by mouse offset.
  50742. */
  50743. private rotateCamera;
  50744. }
  50745. }
  50746. declare module BABYLON {
  50747. /**
  50748. * Default Inputs manager for the FlyCamera.
  50749. * It groups all the default supported inputs for ease of use.
  50750. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50751. */
  50752. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50753. /**
  50754. * Instantiates a new FlyCameraInputsManager.
  50755. * @param camera Defines the camera the inputs belong to.
  50756. */
  50757. constructor(camera: FlyCamera);
  50758. /**
  50759. * Add keyboard input support to the input manager.
  50760. * @returns the new FlyCameraKeyboardMoveInput().
  50761. */
  50762. addKeyboard(): FlyCameraInputsManager;
  50763. /**
  50764. * Add mouse input support to the input manager.
  50765. * @param touchEnabled Enable touch screen support.
  50766. * @returns the new FlyCameraMouseInput().
  50767. */
  50768. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50769. }
  50770. }
  50771. declare module BABYLON {
  50772. /**
  50773. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50774. * such as in a 3D Space Shooter or a Flight Simulator.
  50775. */
  50776. export class FlyCamera extends TargetCamera {
  50777. /**
  50778. * Define the collision ellipsoid of the camera.
  50779. * This is helpful for simulating a camera body, like a player's body.
  50780. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50781. */
  50782. ellipsoid: Vector3;
  50783. /**
  50784. * Define an offset for the position of the ellipsoid around the camera.
  50785. * This can be helpful if the camera is attached away from the player's body center,
  50786. * such as at its head.
  50787. */
  50788. ellipsoidOffset: Vector3;
  50789. /**
  50790. * Enable or disable collisions of the camera with the rest of the scene objects.
  50791. */
  50792. checkCollisions: boolean;
  50793. /**
  50794. * Enable or disable gravity on the camera.
  50795. */
  50796. applyGravity: boolean;
  50797. /**
  50798. * Define the current direction the camera is moving to.
  50799. */
  50800. cameraDirection: Vector3;
  50801. /**
  50802. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50803. * This overrides and empties cameraRotation.
  50804. */
  50805. rotationQuaternion: Quaternion;
  50806. /**
  50807. * Track Roll to maintain the wanted Rolling when looking around.
  50808. */
  50809. _trackRoll: number;
  50810. /**
  50811. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50812. */
  50813. rollCorrect: number;
  50814. /**
  50815. * Mimic a banked turn, Rolling the camera when Yawing.
  50816. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50817. */
  50818. bankedTurn: boolean;
  50819. /**
  50820. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50821. */
  50822. bankedTurnLimit: number;
  50823. /**
  50824. * Value of 0 disables the banked Roll.
  50825. * Value of 1 is equal to the Yaw angle in radians.
  50826. */
  50827. bankedTurnMultiplier: number;
  50828. /**
  50829. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50830. */
  50831. inputs: FlyCameraInputsManager;
  50832. /**
  50833. * Gets the input sensibility for mouse input.
  50834. * Higher values reduce sensitivity.
  50835. */
  50836. get angularSensibility(): number;
  50837. /**
  50838. * Sets the input sensibility for a mouse input.
  50839. * Higher values reduce sensitivity.
  50840. */
  50841. set angularSensibility(value: number);
  50842. /**
  50843. * Get the keys for camera movement forward.
  50844. */
  50845. get keysForward(): number[];
  50846. /**
  50847. * Set the keys for camera movement forward.
  50848. */
  50849. set keysForward(value: number[]);
  50850. /**
  50851. * Get the keys for camera movement backward.
  50852. */
  50853. get keysBackward(): number[];
  50854. set keysBackward(value: number[]);
  50855. /**
  50856. * Get the keys for camera movement up.
  50857. */
  50858. get keysUp(): number[];
  50859. /**
  50860. * Set the keys for camera movement up.
  50861. */
  50862. set keysUp(value: number[]);
  50863. /**
  50864. * Get the keys for camera movement down.
  50865. */
  50866. get keysDown(): number[];
  50867. /**
  50868. * Set the keys for camera movement down.
  50869. */
  50870. set keysDown(value: number[]);
  50871. /**
  50872. * Get the keys for camera movement left.
  50873. */
  50874. get keysLeft(): number[];
  50875. /**
  50876. * Set the keys for camera movement left.
  50877. */
  50878. set keysLeft(value: number[]);
  50879. /**
  50880. * Set the keys for camera movement right.
  50881. */
  50882. get keysRight(): number[];
  50883. /**
  50884. * Set the keys for camera movement right.
  50885. */
  50886. set keysRight(value: number[]);
  50887. /**
  50888. * Event raised when the camera collides with a mesh in the scene.
  50889. */
  50890. onCollide: (collidedMesh: AbstractMesh) => void;
  50891. private _collider;
  50892. private _needMoveForGravity;
  50893. private _oldPosition;
  50894. private _diffPosition;
  50895. private _newPosition;
  50896. /** @hidden */
  50897. _localDirection: Vector3;
  50898. /** @hidden */
  50899. _transformedDirection: Vector3;
  50900. /**
  50901. * Instantiates a FlyCamera.
  50902. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50903. * such as in a 3D Space Shooter or a Flight Simulator.
  50904. * @param name Define the name of the camera in the scene.
  50905. * @param position Define the starting position of the camera in the scene.
  50906. * @param scene Define the scene the camera belongs to.
  50907. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50908. */
  50909. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50910. /**
  50911. * Attach the input controls to a specific dom element to get the input from.
  50912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50913. */
  50914. attachControl(noPreventDefault?: boolean): void;
  50915. /**
  50916. * Detach a control from the HTML DOM element.
  50917. * The camera will stop reacting to that input.
  50918. */
  50919. detachControl(): void;
  50920. private _collisionMask;
  50921. /**
  50922. * Get the mask that the camera ignores in collision events.
  50923. */
  50924. get collisionMask(): number;
  50925. /**
  50926. * Set the mask that the camera ignores in collision events.
  50927. */
  50928. set collisionMask(mask: number);
  50929. /** @hidden */
  50930. _collideWithWorld(displacement: Vector3): void;
  50931. /** @hidden */
  50932. private _onCollisionPositionChange;
  50933. /** @hidden */
  50934. _checkInputs(): void;
  50935. /** @hidden */
  50936. _decideIfNeedsToMove(): boolean;
  50937. /** @hidden */
  50938. _updatePosition(): void;
  50939. /**
  50940. * Restore the Roll to its target value at the rate specified.
  50941. * @param rate - Higher means slower restoring.
  50942. * @hidden
  50943. */
  50944. restoreRoll(rate: number): void;
  50945. /**
  50946. * Destroy the camera and release the current resources held by it.
  50947. */
  50948. dispose(): void;
  50949. /**
  50950. * Get the current object class name.
  50951. * @returns the class name.
  50952. */
  50953. getClassName(): string;
  50954. }
  50955. }
  50956. declare module BABYLON {
  50957. /**
  50958. * Listen to keyboard events to control the camera.
  50959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50960. */
  50961. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  50962. /**
  50963. * Defines the camera the input is attached to.
  50964. */
  50965. camera: FlyCamera;
  50966. /**
  50967. * The list of keyboard keys used to control the forward move of the camera.
  50968. */
  50969. keysForward: number[];
  50970. /**
  50971. * The list of keyboard keys used to control the backward move of the camera.
  50972. */
  50973. keysBackward: number[];
  50974. /**
  50975. * The list of keyboard keys used to control the forward move of the camera.
  50976. */
  50977. keysUp: number[];
  50978. /**
  50979. * The list of keyboard keys used to control the backward move of the camera.
  50980. */
  50981. keysDown: number[];
  50982. /**
  50983. * The list of keyboard keys used to control the right strafe move of the camera.
  50984. */
  50985. keysRight: number[];
  50986. /**
  50987. * The list of keyboard keys used to control the left strafe move of the camera.
  50988. */
  50989. keysLeft: number[];
  50990. private _keys;
  50991. private _onCanvasBlurObserver;
  50992. private _onKeyboardObserver;
  50993. private _engine;
  50994. private _scene;
  50995. /**
  50996. * Attach the input controls to a specific dom element to get the input from.
  50997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50998. */
  50999. attachControl(noPreventDefault?: boolean): void;
  51000. /**
  51001. * Detach the current controls from the specified dom element.
  51002. */
  51003. detachControl(): void;
  51004. /**
  51005. * Gets the class name of the current intput.
  51006. * @returns the class name
  51007. */
  51008. getClassName(): string;
  51009. /** @hidden */
  51010. _onLostFocus(e: FocusEvent): void;
  51011. /**
  51012. * Get the friendly name associated with the input class.
  51013. * @returns the input friendly name
  51014. */
  51015. getSimpleName(): string;
  51016. /**
  51017. * Update the current camera state depending on the inputs that have been used this frame.
  51018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51019. */
  51020. checkInputs(): void;
  51021. }
  51022. }
  51023. declare module BABYLON {
  51024. /**
  51025. * Manage the mouse wheel inputs to control a follow camera.
  51026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51027. */
  51028. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51029. /**
  51030. * Defines the camera the input is attached to.
  51031. */
  51032. camera: FollowCamera;
  51033. /**
  51034. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51035. */
  51036. axisControlRadius: boolean;
  51037. /**
  51038. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51039. */
  51040. axisControlHeight: boolean;
  51041. /**
  51042. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51043. */
  51044. axisControlRotation: boolean;
  51045. /**
  51046. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51047. * relation to mouseWheel events.
  51048. */
  51049. wheelPrecision: number;
  51050. /**
  51051. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51052. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51053. */
  51054. wheelDeltaPercentage: number;
  51055. private _wheel;
  51056. private _observer;
  51057. /**
  51058. * Attach the input controls to a specific dom element to get the input from.
  51059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51060. */
  51061. attachControl(noPreventDefault?: boolean): void;
  51062. /**
  51063. * Detach the current controls from the specified dom element.
  51064. */
  51065. detachControl(): void;
  51066. /**
  51067. * Gets the class name of the current intput.
  51068. * @returns the class name
  51069. */
  51070. getClassName(): string;
  51071. /**
  51072. * Get the friendly name associated with the input class.
  51073. * @returns the input friendly name
  51074. */
  51075. getSimpleName(): string;
  51076. }
  51077. }
  51078. declare module BABYLON {
  51079. /**
  51080. * Manage the pointers inputs to control an follow camera.
  51081. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51082. */
  51083. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51084. /**
  51085. * Defines the camera the input is attached to.
  51086. */
  51087. camera: FollowCamera;
  51088. /**
  51089. * Gets the class name of the current input.
  51090. * @returns the class name
  51091. */
  51092. getClassName(): string;
  51093. /**
  51094. * Defines the pointer angular sensibility along the X axis or how fast is
  51095. * the camera rotating.
  51096. * A negative number will reverse the axis direction.
  51097. */
  51098. angularSensibilityX: number;
  51099. /**
  51100. * Defines the pointer angular sensibility along the Y axis or how fast is
  51101. * the camera rotating.
  51102. * A negative number will reverse the axis direction.
  51103. */
  51104. angularSensibilityY: number;
  51105. /**
  51106. * Defines the pointer pinch precision or how fast is the camera zooming.
  51107. * A negative number will reverse the axis direction.
  51108. */
  51109. pinchPrecision: number;
  51110. /**
  51111. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51112. * from 0.
  51113. * It defines the percentage of current camera.radius to use as delta when
  51114. * pinch zoom is used.
  51115. */
  51116. pinchDeltaPercentage: number;
  51117. /**
  51118. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51119. */
  51120. axisXControlRadius: boolean;
  51121. /**
  51122. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51123. */
  51124. axisXControlHeight: boolean;
  51125. /**
  51126. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51127. */
  51128. axisXControlRotation: boolean;
  51129. /**
  51130. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51131. */
  51132. axisYControlRadius: boolean;
  51133. /**
  51134. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51135. */
  51136. axisYControlHeight: boolean;
  51137. /**
  51138. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51139. */
  51140. axisYControlRotation: boolean;
  51141. /**
  51142. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51143. */
  51144. axisPinchControlRadius: boolean;
  51145. /**
  51146. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51147. */
  51148. axisPinchControlHeight: boolean;
  51149. /**
  51150. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51151. */
  51152. axisPinchControlRotation: boolean;
  51153. /**
  51154. * Log error messages if basic misconfiguration has occurred.
  51155. */
  51156. warningEnable: boolean;
  51157. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51158. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51159. private _warningCounter;
  51160. private _warning;
  51161. }
  51162. }
  51163. declare module BABYLON {
  51164. /**
  51165. * Default Inputs manager for the FollowCamera.
  51166. * It groups all the default supported inputs for ease of use.
  51167. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51168. */
  51169. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51170. /**
  51171. * Instantiates a new FollowCameraInputsManager.
  51172. * @param camera Defines the camera the inputs belong to
  51173. */
  51174. constructor(camera: FollowCamera);
  51175. /**
  51176. * Add keyboard input support to the input manager.
  51177. * @returns the current input manager
  51178. */
  51179. addKeyboard(): FollowCameraInputsManager;
  51180. /**
  51181. * Add mouse wheel input support to the input manager.
  51182. * @returns the current input manager
  51183. */
  51184. addMouseWheel(): FollowCameraInputsManager;
  51185. /**
  51186. * Add pointers input support to the input manager.
  51187. * @returns the current input manager
  51188. */
  51189. addPointers(): FollowCameraInputsManager;
  51190. /**
  51191. * Add orientation input support to the input manager.
  51192. * @returns the current input manager
  51193. */
  51194. addVRDeviceOrientation(): FollowCameraInputsManager;
  51195. }
  51196. }
  51197. declare module BABYLON {
  51198. /**
  51199. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51200. * an arc rotate version arcFollowCamera are available.
  51201. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51202. */
  51203. export class FollowCamera extends TargetCamera {
  51204. /**
  51205. * Distance the follow camera should follow an object at
  51206. */
  51207. radius: number;
  51208. /**
  51209. * Minimum allowed distance of the camera to the axis of rotation
  51210. * (The camera can not get closer).
  51211. * This can help limiting how the Camera is able to move in the scene.
  51212. */
  51213. lowerRadiusLimit: Nullable<number>;
  51214. /**
  51215. * Maximum allowed distance of the camera to the axis of rotation
  51216. * (The camera can not get further).
  51217. * This can help limiting how the Camera is able to move in the scene.
  51218. */
  51219. upperRadiusLimit: Nullable<number>;
  51220. /**
  51221. * Define a rotation offset between the camera and the object it follows
  51222. */
  51223. rotationOffset: number;
  51224. /**
  51225. * Minimum allowed angle to camera position relative to target object.
  51226. * This can help limiting how the Camera is able to move in the scene.
  51227. */
  51228. lowerRotationOffsetLimit: Nullable<number>;
  51229. /**
  51230. * Maximum allowed angle to camera position relative to target object.
  51231. * This can help limiting how the Camera is able to move in the scene.
  51232. */
  51233. upperRotationOffsetLimit: Nullable<number>;
  51234. /**
  51235. * Define a height offset between the camera and the object it follows.
  51236. * It can help following an object from the top (like a car chaing a plane)
  51237. */
  51238. heightOffset: number;
  51239. /**
  51240. * Minimum allowed height of camera position relative to target object.
  51241. * This can help limiting how the Camera is able to move in the scene.
  51242. */
  51243. lowerHeightOffsetLimit: Nullable<number>;
  51244. /**
  51245. * Maximum allowed height of camera position relative to target object.
  51246. * This can help limiting how the Camera is able to move in the scene.
  51247. */
  51248. upperHeightOffsetLimit: Nullable<number>;
  51249. /**
  51250. * Define how fast the camera can accelerate to follow it s target.
  51251. */
  51252. cameraAcceleration: number;
  51253. /**
  51254. * Define the speed limit of the camera following an object.
  51255. */
  51256. maxCameraSpeed: number;
  51257. /**
  51258. * Define the target of the camera.
  51259. */
  51260. lockedTarget: Nullable<AbstractMesh>;
  51261. /**
  51262. * Defines the input associated with the camera.
  51263. */
  51264. inputs: FollowCameraInputsManager;
  51265. /**
  51266. * Instantiates the follow camera.
  51267. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51268. * @param name Define the name of the camera in the scene
  51269. * @param position Define the position of the camera
  51270. * @param scene Define the scene the camera belong to
  51271. * @param lockedTarget Define the target of the camera
  51272. */
  51273. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51274. private _follow;
  51275. /**
  51276. * Attach the input controls to a specific dom element to get the input from.
  51277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51278. */
  51279. attachControl(noPreventDefault?: boolean): void;
  51280. /**
  51281. * Detach the current controls from the specified dom element.
  51282. */
  51283. detachControl(): void;
  51284. /** @hidden */
  51285. _checkInputs(): void;
  51286. private _checkLimits;
  51287. /**
  51288. * Gets the camera class name.
  51289. * @returns the class name
  51290. */
  51291. getClassName(): string;
  51292. }
  51293. /**
  51294. * Arc Rotate version of the follow camera.
  51295. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51296. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51297. */
  51298. export class ArcFollowCamera extends TargetCamera {
  51299. /** The longitudinal angle of the camera */
  51300. alpha: number;
  51301. /** The latitudinal angle of the camera */
  51302. beta: number;
  51303. /** The radius of the camera from its target */
  51304. radius: number;
  51305. private _cartesianCoordinates;
  51306. /** Define the camera target (the mesh it should follow) */
  51307. private _meshTarget;
  51308. /**
  51309. * Instantiates a new ArcFollowCamera
  51310. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51311. * @param name Define the name of the camera
  51312. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51313. * @param beta Define the rotation angle of the camera around the elevation axis
  51314. * @param radius Define the radius of the camera from its target point
  51315. * @param target Define the target of the camera
  51316. * @param scene Define the scene the camera belongs to
  51317. */
  51318. constructor(name: string,
  51319. /** The longitudinal angle of the camera */
  51320. alpha: number,
  51321. /** The latitudinal angle of the camera */
  51322. beta: number,
  51323. /** The radius of the camera from its target */
  51324. radius: number,
  51325. /** Define the camera target (the mesh it should follow) */
  51326. target: Nullable<AbstractMesh>, scene: Scene);
  51327. private _follow;
  51328. /** @hidden */
  51329. _checkInputs(): void;
  51330. /**
  51331. * Returns the class name of the object.
  51332. * It is mostly used internally for serialization purposes.
  51333. */
  51334. getClassName(): string;
  51335. }
  51336. }
  51337. declare module BABYLON {
  51338. /**
  51339. * Manage the keyboard inputs to control the movement of a follow camera.
  51340. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51341. */
  51342. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51343. /**
  51344. * Defines the camera the input is attached to.
  51345. */
  51346. camera: FollowCamera;
  51347. /**
  51348. * Defines the list of key codes associated with the up action (increase heightOffset)
  51349. */
  51350. keysHeightOffsetIncr: number[];
  51351. /**
  51352. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51353. */
  51354. keysHeightOffsetDecr: number[];
  51355. /**
  51356. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51357. */
  51358. keysHeightOffsetModifierAlt: boolean;
  51359. /**
  51360. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51361. */
  51362. keysHeightOffsetModifierCtrl: boolean;
  51363. /**
  51364. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51365. */
  51366. keysHeightOffsetModifierShift: boolean;
  51367. /**
  51368. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51369. */
  51370. keysRotationOffsetIncr: number[];
  51371. /**
  51372. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51373. */
  51374. keysRotationOffsetDecr: number[];
  51375. /**
  51376. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51377. */
  51378. keysRotationOffsetModifierAlt: boolean;
  51379. /**
  51380. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51381. */
  51382. keysRotationOffsetModifierCtrl: boolean;
  51383. /**
  51384. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51385. */
  51386. keysRotationOffsetModifierShift: boolean;
  51387. /**
  51388. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51389. */
  51390. keysRadiusIncr: number[];
  51391. /**
  51392. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51393. */
  51394. keysRadiusDecr: number[];
  51395. /**
  51396. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51397. */
  51398. keysRadiusModifierAlt: boolean;
  51399. /**
  51400. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51401. */
  51402. keysRadiusModifierCtrl: boolean;
  51403. /**
  51404. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51405. */
  51406. keysRadiusModifierShift: boolean;
  51407. /**
  51408. * Defines the rate of change of heightOffset.
  51409. */
  51410. heightSensibility: number;
  51411. /**
  51412. * Defines the rate of change of rotationOffset.
  51413. */
  51414. rotationSensibility: number;
  51415. /**
  51416. * Defines the rate of change of radius.
  51417. */
  51418. radiusSensibility: number;
  51419. private _keys;
  51420. private _ctrlPressed;
  51421. private _altPressed;
  51422. private _shiftPressed;
  51423. private _onCanvasBlurObserver;
  51424. private _onKeyboardObserver;
  51425. private _engine;
  51426. private _scene;
  51427. /**
  51428. * Attach the input controls to a specific dom element to get the input from.
  51429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51430. */
  51431. attachControl(noPreventDefault?: boolean): void;
  51432. /**
  51433. * Detach the current controls from the specified dom element.
  51434. */
  51435. detachControl(): void;
  51436. /**
  51437. * Update the current camera state depending on the inputs that have been used this frame.
  51438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51439. */
  51440. checkInputs(): void;
  51441. /**
  51442. * Gets the class name of the current input.
  51443. * @returns the class name
  51444. */
  51445. getClassName(): string;
  51446. /**
  51447. * Get the friendly name associated with the input class.
  51448. * @returns the input friendly name
  51449. */
  51450. getSimpleName(): string;
  51451. /**
  51452. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51453. * allow modification of the heightOffset value.
  51454. */
  51455. private _modifierHeightOffset;
  51456. /**
  51457. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51458. * allow modification of the rotationOffset value.
  51459. */
  51460. private _modifierRotationOffset;
  51461. /**
  51462. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51463. * allow modification of the radius value.
  51464. */
  51465. private _modifierRadius;
  51466. }
  51467. }
  51468. declare module BABYLON {
  51469. interface FreeCameraInputsManager {
  51470. /**
  51471. * @hidden
  51472. */
  51473. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51474. /**
  51475. * Add orientation input support to the input manager.
  51476. * @returns the current input manager
  51477. */
  51478. addDeviceOrientation(): FreeCameraInputsManager;
  51479. }
  51480. /**
  51481. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51482. * Screen rotation is taken into account.
  51483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51484. */
  51485. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51486. private _camera;
  51487. private _screenOrientationAngle;
  51488. private _constantTranform;
  51489. private _screenQuaternion;
  51490. private _alpha;
  51491. private _beta;
  51492. private _gamma;
  51493. /**
  51494. * Can be used to detect if a device orientation sensor is available on a device
  51495. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51496. * @returns a promise that will resolve on orientation change
  51497. */
  51498. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51499. /**
  51500. * @hidden
  51501. */
  51502. _onDeviceOrientationChangedObservable: Observable<void>;
  51503. /**
  51504. * Instantiates a new input
  51505. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51506. */
  51507. constructor();
  51508. /**
  51509. * Define the camera controlled by the input.
  51510. */
  51511. get camera(): FreeCamera;
  51512. set camera(camera: FreeCamera);
  51513. /**
  51514. * Attach the input controls to a specific dom element to get the input from.
  51515. */
  51516. attachControl(): void;
  51517. private _orientationChanged;
  51518. private _deviceOrientation;
  51519. /**
  51520. * Detach the current controls from the specified dom element.
  51521. */
  51522. detachControl(): void;
  51523. /**
  51524. * Update the current camera state depending on the inputs that have been used this frame.
  51525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51526. */
  51527. checkInputs(): void;
  51528. /**
  51529. * Gets the class name of the current intput.
  51530. * @returns the class name
  51531. */
  51532. getClassName(): string;
  51533. /**
  51534. * Get the friendly name associated with the input class.
  51535. * @returns the input friendly name
  51536. */
  51537. getSimpleName(): string;
  51538. }
  51539. }
  51540. declare module BABYLON {
  51541. /**
  51542. * Manage the gamepad inputs to control a free camera.
  51543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51544. */
  51545. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51546. /**
  51547. * Define the camera the input is attached to.
  51548. */
  51549. camera: FreeCamera;
  51550. /**
  51551. * Define the Gamepad controlling the input
  51552. */
  51553. gamepad: Nullable<Gamepad>;
  51554. /**
  51555. * Defines the gamepad rotation sensiblity.
  51556. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51557. */
  51558. gamepadAngularSensibility: number;
  51559. /**
  51560. * Defines the gamepad move sensiblity.
  51561. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51562. */
  51563. gamepadMoveSensibility: number;
  51564. private _yAxisScale;
  51565. /**
  51566. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51567. */
  51568. get invertYAxis(): boolean;
  51569. set invertYAxis(value: boolean);
  51570. private _onGamepadConnectedObserver;
  51571. private _onGamepadDisconnectedObserver;
  51572. private _cameraTransform;
  51573. private _deltaTransform;
  51574. private _vector3;
  51575. private _vector2;
  51576. /**
  51577. * Attach the input controls to a specific dom element to get the input from.
  51578. */
  51579. attachControl(): void;
  51580. /**
  51581. * Detach the current controls from the specified dom element.
  51582. */
  51583. detachControl(): void;
  51584. /**
  51585. * Update the current camera state depending on the inputs that have been used this frame.
  51586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51587. */
  51588. checkInputs(): void;
  51589. /**
  51590. * Gets the class name of the current intput.
  51591. * @returns the class name
  51592. */
  51593. getClassName(): string;
  51594. /**
  51595. * Get the friendly name associated with the input class.
  51596. * @returns the input friendly name
  51597. */
  51598. getSimpleName(): string;
  51599. }
  51600. }
  51601. declare module BABYLON {
  51602. /**
  51603. * Defines the potential axis of a Joystick
  51604. */
  51605. export enum JoystickAxis {
  51606. /** X axis */
  51607. X = 0,
  51608. /** Y axis */
  51609. Y = 1,
  51610. /** Z axis */
  51611. Z = 2
  51612. }
  51613. /**
  51614. * Represents the different customization options available
  51615. * for VirtualJoystick
  51616. */
  51617. interface VirtualJoystickCustomizations {
  51618. /**
  51619. * Size of the joystick's puck
  51620. */
  51621. puckSize: number;
  51622. /**
  51623. * Size of the joystick's container
  51624. */
  51625. containerSize: number;
  51626. /**
  51627. * Color of the joystick && puck
  51628. */
  51629. color: string;
  51630. /**
  51631. * Image URL for the joystick's puck
  51632. */
  51633. puckImage?: string;
  51634. /**
  51635. * Image URL for the joystick's container
  51636. */
  51637. containerImage?: string;
  51638. /**
  51639. * Defines the unmoving position of the joystick container
  51640. */
  51641. position?: {
  51642. x: number;
  51643. y: number;
  51644. };
  51645. /**
  51646. * Defines whether or not the joystick container is always visible
  51647. */
  51648. alwaysVisible: boolean;
  51649. /**
  51650. * Defines whether or not to limit the movement of the puck to the joystick's container
  51651. */
  51652. limitToContainer: boolean;
  51653. }
  51654. /**
  51655. * Class used to define virtual joystick (used in touch mode)
  51656. */
  51657. export class VirtualJoystick {
  51658. /**
  51659. * Gets or sets a boolean indicating that left and right values must be inverted
  51660. */
  51661. reverseLeftRight: boolean;
  51662. /**
  51663. * Gets or sets a boolean indicating that up and down values must be inverted
  51664. */
  51665. reverseUpDown: boolean;
  51666. /**
  51667. * Gets the offset value for the position (ie. the change of the position value)
  51668. */
  51669. deltaPosition: Vector3;
  51670. /**
  51671. * Gets a boolean indicating if the virtual joystick was pressed
  51672. */
  51673. pressed: boolean;
  51674. /**
  51675. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51676. */
  51677. static Canvas: Nullable<HTMLCanvasElement>;
  51678. /**
  51679. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51680. */
  51681. limitToContainer: boolean;
  51682. private static _globalJoystickIndex;
  51683. private static _alwaysVisibleSticks;
  51684. private static vjCanvasContext;
  51685. private static vjCanvasWidth;
  51686. private static vjCanvasHeight;
  51687. private static halfWidth;
  51688. private static _GetDefaultOptions;
  51689. private _action;
  51690. private _axisTargetedByLeftAndRight;
  51691. private _axisTargetedByUpAndDown;
  51692. private _joystickSensibility;
  51693. private _inversedSensibility;
  51694. private _joystickPointerID;
  51695. private _joystickColor;
  51696. private _joystickPointerPos;
  51697. private _joystickPreviousPointerPos;
  51698. private _joystickPointerStartPos;
  51699. private _deltaJoystickVector;
  51700. private _leftJoystick;
  51701. private _touches;
  51702. private _joystickPosition;
  51703. private _alwaysVisible;
  51704. private _puckImage;
  51705. private _containerImage;
  51706. private _joystickPuckSize;
  51707. private _joystickContainerSize;
  51708. private _clearPuckSize;
  51709. private _clearContainerSize;
  51710. private _clearPuckSizeOffset;
  51711. private _clearContainerSizeOffset;
  51712. private _onPointerDownHandlerRef;
  51713. private _onPointerMoveHandlerRef;
  51714. private _onPointerUpHandlerRef;
  51715. private _onResize;
  51716. /**
  51717. * Creates a new virtual joystick
  51718. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51719. * @param customizations Defines the options we want to customize the VirtualJoystick
  51720. */
  51721. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51722. /**
  51723. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51724. * @param newJoystickSensibility defines the new sensibility
  51725. */
  51726. setJoystickSensibility(newJoystickSensibility: number): void;
  51727. private _onPointerDown;
  51728. private _onPointerMove;
  51729. private _onPointerUp;
  51730. /**
  51731. * Change the color of the virtual joystick
  51732. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51733. */
  51734. setJoystickColor(newColor: string): void;
  51735. /**
  51736. * Size of the joystick's container
  51737. */
  51738. set containerSize(newSize: number);
  51739. get containerSize(): number;
  51740. /**
  51741. * Size of the joystick's puck
  51742. */
  51743. set puckSize(newSize: number);
  51744. get puckSize(): number;
  51745. /**
  51746. * Clears the set position of the joystick
  51747. */
  51748. clearPosition(): void;
  51749. /**
  51750. * Defines whether or not the joystick container is always visible
  51751. */
  51752. set alwaysVisible(value: boolean);
  51753. get alwaysVisible(): boolean;
  51754. /**
  51755. * Sets the constant position of the Joystick container
  51756. * @param x X axis coordinate
  51757. * @param y Y axis coordinate
  51758. */
  51759. setPosition(x: number, y: number): void;
  51760. /**
  51761. * Defines a callback to call when the joystick is touched
  51762. * @param action defines the callback
  51763. */
  51764. setActionOnTouch(action: () => any): void;
  51765. /**
  51766. * Defines which axis you'd like to control for left & right
  51767. * @param axis defines the axis to use
  51768. */
  51769. setAxisForLeftRight(axis: JoystickAxis): void;
  51770. /**
  51771. * Defines which axis you'd like to control for up & down
  51772. * @param axis defines the axis to use
  51773. */
  51774. setAxisForUpDown(axis: JoystickAxis): void;
  51775. /**
  51776. * Clears the canvas from the previous puck / container draw
  51777. */
  51778. private _clearPreviousDraw;
  51779. /**
  51780. * Loads `urlPath` to be used for the container's image
  51781. * @param urlPath defines the urlPath of an image to use
  51782. */
  51783. setContainerImage(urlPath: string): void;
  51784. /**
  51785. * Loads `urlPath` to be used for the puck's image
  51786. * @param urlPath defines the urlPath of an image to use
  51787. */
  51788. setPuckImage(urlPath: string): void;
  51789. /**
  51790. * Draws the Virtual Joystick's container
  51791. */
  51792. private _drawContainer;
  51793. /**
  51794. * Draws the Virtual Joystick's puck
  51795. */
  51796. private _drawPuck;
  51797. private _drawVirtualJoystick;
  51798. /**
  51799. * Release internal HTML canvas
  51800. */
  51801. releaseCanvas(): void;
  51802. }
  51803. }
  51804. declare module BABYLON {
  51805. interface FreeCameraInputsManager {
  51806. /**
  51807. * Add virtual joystick input support to the input manager.
  51808. * @returns the current input manager
  51809. */
  51810. addVirtualJoystick(): FreeCameraInputsManager;
  51811. }
  51812. /**
  51813. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51815. */
  51816. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51817. /**
  51818. * Defines the camera the input is attached to.
  51819. */
  51820. camera: FreeCamera;
  51821. private _leftjoystick;
  51822. private _rightjoystick;
  51823. /**
  51824. * Gets the left stick of the virtual joystick.
  51825. * @returns The virtual Joystick
  51826. */
  51827. getLeftJoystick(): VirtualJoystick;
  51828. /**
  51829. * Gets the right stick of the virtual joystick.
  51830. * @returns The virtual Joystick
  51831. */
  51832. getRightJoystick(): VirtualJoystick;
  51833. /**
  51834. * Update the current camera state depending on the inputs that have been used this frame.
  51835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51836. */
  51837. checkInputs(): void;
  51838. /**
  51839. * Attach the input controls to a specific dom element to get the input from.
  51840. */
  51841. attachControl(): void;
  51842. /**
  51843. * Detach the current controls from the specified dom element.
  51844. */
  51845. detachControl(): void;
  51846. /**
  51847. * Gets the class name of the current intput.
  51848. * @returns the class name
  51849. */
  51850. getClassName(): string;
  51851. /**
  51852. * Get the friendly name associated with the input class.
  51853. * @returns the input friendly name
  51854. */
  51855. getSimpleName(): string;
  51856. }
  51857. }
  51858. declare module BABYLON {
  51859. /**
  51860. * This represents a FPS type of camera controlled by touch.
  51861. * This is like a universal camera minus the Gamepad controls.
  51862. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51863. */
  51864. export class TouchCamera extends FreeCamera {
  51865. /**
  51866. * Defines the touch sensibility for rotation.
  51867. * The higher the faster.
  51868. */
  51869. get touchAngularSensibility(): number;
  51870. set touchAngularSensibility(value: number);
  51871. /**
  51872. * Defines the touch sensibility for move.
  51873. * The higher the faster.
  51874. */
  51875. get touchMoveSensibility(): number;
  51876. set touchMoveSensibility(value: number);
  51877. /**
  51878. * Instantiates a new touch camera.
  51879. * This represents a FPS type of camera controlled by touch.
  51880. * This is like a universal camera minus the Gamepad controls.
  51881. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51882. * @param name Define the name of the camera in the scene
  51883. * @param position Define the start position of the camera in the scene
  51884. * @param scene Define the scene the camera belongs to
  51885. */
  51886. constructor(name: string, position: Vector3, scene: Scene);
  51887. /**
  51888. * Gets the current object class name.
  51889. * @return the class name
  51890. */
  51891. getClassName(): string;
  51892. /** @hidden */
  51893. _setupInputs(): void;
  51894. }
  51895. }
  51896. declare module BABYLON {
  51897. /**
  51898. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51899. * being tilted forward or back and left or right.
  51900. */
  51901. export class DeviceOrientationCamera extends FreeCamera {
  51902. private _initialQuaternion;
  51903. private _quaternionCache;
  51904. private _tmpDragQuaternion;
  51905. private _disablePointerInputWhenUsingDeviceOrientation;
  51906. /**
  51907. * Creates a new device orientation camera
  51908. * @param name The name of the camera
  51909. * @param position The start position camera
  51910. * @param scene The scene the camera belongs to
  51911. */
  51912. constructor(name: string, position: Vector3, scene: Scene);
  51913. /**
  51914. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51915. */
  51916. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51917. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51918. private _dragFactor;
  51919. /**
  51920. * Enabled turning on the y axis when the orientation sensor is active
  51921. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51922. */
  51923. enableHorizontalDragging(dragFactor?: number): void;
  51924. /**
  51925. * Gets the current instance class name ("DeviceOrientationCamera").
  51926. * This helps avoiding instanceof at run time.
  51927. * @returns the class name
  51928. */
  51929. getClassName(): string;
  51930. /**
  51931. * @hidden
  51932. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51933. */
  51934. _checkInputs(): void;
  51935. /**
  51936. * Reset the camera to its default orientation on the specified axis only.
  51937. * @param axis The axis to reset
  51938. */
  51939. resetToCurrentRotation(axis?: Axis): void;
  51940. }
  51941. }
  51942. declare module BABYLON {
  51943. /**
  51944. * Defines supported buttons for XBox360 compatible gamepads
  51945. */
  51946. export enum Xbox360Button {
  51947. /** A */
  51948. A = 0,
  51949. /** B */
  51950. B = 1,
  51951. /** X */
  51952. X = 2,
  51953. /** Y */
  51954. Y = 3,
  51955. /** Left button */
  51956. LB = 4,
  51957. /** Right button */
  51958. RB = 5,
  51959. /** Back */
  51960. Back = 8,
  51961. /** Start */
  51962. Start = 9,
  51963. /** Left stick */
  51964. LeftStick = 10,
  51965. /** Right stick */
  51966. RightStick = 11
  51967. }
  51968. /** Defines values for XBox360 DPad */
  51969. export enum Xbox360Dpad {
  51970. /** Up */
  51971. Up = 12,
  51972. /** Down */
  51973. Down = 13,
  51974. /** Left */
  51975. Left = 14,
  51976. /** Right */
  51977. Right = 15
  51978. }
  51979. /**
  51980. * Defines a XBox360 gamepad
  51981. */
  51982. export class Xbox360Pad extends Gamepad {
  51983. private _leftTrigger;
  51984. private _rightTrigger;
  51985. private _onlefttriggerchanged;
  51986. private _onrighttriggerchanged;
  51987. private _onbuttondown;
  51988. private _onbuttonup;
  51989. private _ondpaddown;
  51990. private _ondpadup;
  51991. /** Observable raised when a button is pressed */
  51992. onButtonDownObservable: Observable<Xbox360Button>;
  51993. /** Observable raised when a button is released */
  51994. onButtonUpObservable: Observable<Xbox360Button>;
  51995. /** Observable raised when a pad is pressed */
  51996. onPadDownObservable: Observable<Xbox360Dpad>;
  51997. /** Observable raised when a pad is released */
  51998. onPadUpObservable: Observable<Xbox360Dpad>;
  51999. private _buttonA;
  52000. private _buttonB;
  52001. private _buttonX;
  52002. private _buttonY;
  52003. private _buttonBack;
  52004. private _buttonStart;
  52005. private _buttonLB;
  52006. private _buttonRB;
  52007. private _buttonLeftStick;
  52008. private _buttonRightStick;
  52009. private _dPadUp;
  52010. private _dPadDown;
  52011. private _dPadLeft;
  52012. private _dPadRight;
  52013. private _isXboxOnePad;
  52014. /**
  52015. * Creates a new XBox360 gamepad object
  52016. * @param id defines the id of this gamepad
  52017. * @param index defines its index
  52018. * @param gamepad defines the internal HTML gamepad object
  52019. * @param xboxOne defines if it is a XBox One gamepad
  52020. */
  52021. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52022. /**
  52023. * Defines the callback to call when left trigger is pressed
  52024. * @param callback defines the callback to use
  52025. */
  52026. onlefttriggerchanged(callback: (value: number) => void): void;
  52027. /**
  52028. * Defines the callback to call when right trigger is pressed
  52029. * @param callback defines the callback to use
  52030. */
  52031. onrighttriggerchanged(callback: (value: number) => void): void;
  52032. /**
  52033. * Gets the left trigger value
  52034. */
  52035. get leftTrigger(): number;
  52036. /**
  52037. * Sets the left trigger value
  52038. */
  52039. set leftTrigger(newValue: number);
  52040. /**
  52041. * Gets the right trigger value
  52042. */
  52043. get rightTrigger(): number;
  52044. /**
  52045. * Sets the right trigger value
  52046. */
  52047. set rightTrigger(newValue: number);
  52048. /**
  52049. * Defines the callback to call when a button is pressed
  52050. * @param callback defines the callback to use
  52051. */
  52052. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52053. /**
  52054. * Defines the callback to call when a button is released
  52055. * @param callback defines the callback to use
  52056. */
  52057. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52058. /**
  52059. * Defines the callback to call when a pad is pressed
  52060. * @param callback defines the callback to use
  52061. */
  52062. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52063. /**
  52064. * Defines the callback to call when a pad is released
  52065. * @param callback defines the callback to use
  52066. */
  52067. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52068. private _setButtonValue;
  52069. private _setDPadValue;
  52070. /**
  52071. * Gets the value of the `A` button
  52072. */
  52073. get buttonA(): number;
  52074. /**
  52075. * Sets the value of the `A` button
  52076. */
  52077. set buttonA(value: number);
  52078. /**
  52079. * Gets the value of the `B` button
  52080. */
  52081. get buttonB(): number;
  52082. /**
  52083. * Sets the value of the `B` button
  52084. */
  52085. set buttonB(value: number);
  52086. /**
  52087. * Gets the value of the `X` button
  52088. */
  52089. get buttonX(): number;
  52090. /**
  52091. * Sets the value of the `X` button
  52092. */
  52093. set buttonX(value: number);
  52094. /**
  52095. * Gets the value of the `Y` button
  52096. */
  52097. get buttonY(): number;
  52098. /**
  52099. * Sets the value of the `Y` button
  52100. */
  52101. set buttonY(value: number);
  52102. /**
  52103. * Gets the value of the `Start` button
  52104. */
  52105. get buttonStart(): number;
  52106. /**
  52107. * Sets the value of the `Start` button
  52108. */
  52109. set buttonStart(value: number);
  52110. /**
  52111. * Gets the value of the `Back` button
  52112. */
  52113. get buttonBack(): number;
  52114. /**
  52115. * Sets the value of the `Back` button
  52116. */
  52117. set buttonBack(value: number);
  52118. /**
  52119. * Gets the value of the `Left` button
  52120. */
  52121. get buttonLB(): number;
  52122. /**
  52123. * Sets the value of the `Left` button
  52124. */
  52125. set buttonLB(value: number);
  52126. /**
  52127. * Gets the value of the `Right` button
  52128. */
  52129. get buttonRB(): number;
  52130. /**
  52131. * Sets the value of the `Right` button
  52132. */
  52133. set buttonRB(value: number);
  52134. /**
  52135. * Gets the value of the Left joystick
  52136. */
  52137. get buttonLeftStick(): number;
  52138. /**
  52139. * Sets the value of the Left joystick
  52140. */
  52141. set buttonLeftStick(value: number);
  52142. /**
  52143. * Gets the value of the Right joystick
  52144. */
  52145. get buttonRightStick(): number;
  52146. /**
  52147. * Sets the value of the Right joystick
  52148. */
  52149. set buttonRightStick(value: number);
  52150. /**
  52151. * Gets the value of D-pad up
  52152. */
  52153. get dPadUp(): number;
  52154. /**
  52155. * Sets the value of D-pad up
  52156. */
  52157. set dPadUp(value: number);
  52158. /**
  52159. * Gets the value of D-pad down
  52160. */
  52161. get dPadDown(): number;
  52162. /**
  52163. * Sets the value of D-pad down
  52164. */
  52165. set dPadDown(value: number);
  52166. /**
  52167. * Gets the value of D-pad left
  52168. */
  52169. get dPadLeft(): number;
  52170. /**
  52171. * Sets the value of D-pad left
  52172. */
  52173. set dPadLeft(value: number);
  52174. /**
  52175. * Gets the value of D-pad right
  52176. */
  52177. get dPadRight(): number;
  52178. /**
  52179. * Sets the value of D-pad right
  52180. */
  52181. set dPadRight(value: number);
  52182. /**
  52183. * Force the gamepad to synchronize with device values
  52184. */
  52185. update(): void;
  52186. /**
  52187. * Disposes the gamepad
  52188. */
  52189. dispose(): void;
  52190. }
  52191. }
  52192. declare module BABYLON {
  52193. /**
  52194. * Defines supported buttons for DualShock compatible gamepads
  52195. */
  52196. export enum DualShockButton {
  52197. /** Cross */
  52198. Cross = 0,
  52199. /** Circle */
  52200. Circle = 1,
  52201. /** Square */
  52202. Square = 2,
  52203. /** Triangle */
  52204. Triangle = 3,
  52205. /** L1 */
  52206. L1 = 4,
  52207. /** R1 */
  52208. R1 = 5,
  52209. /** Share */
  52210. Share = 8,
  52211. /** Options */
  52212. Options = 9,
  52213. /** Left stick */
  52214. LeftStick = 10,
  52215. /** Right stick */
  52216. RightStick = 11
  52217. }
  52218. /** Defines values for DualShock DPad */
  52219. export enum DualShockDpad {
  52220. /** Up */
  52221. Up = 12,
  52222. /** Down */
  52223. Down = 13,
  52224. /** Left */
  52225. Left = 14,
  52226. /** Right */
  52227. Right = 15
  52228. }
  52229. /**
  52230. * Defines a DualShock gamepad
  52231. */
  52232. export class DualShockPad extends Gamepad {
  52233. private _leftTrigger;
  52234. private _rightTrigger;
  52235. private _onlefttriggerchanged;
  52236. private _onrighttriggerchanged;
  52237. private _onbuttondown;
  52238. private _onbuttonup;
  52239. private _ondpaddown;
  52240. private _ondpadup;
  52241. /** Observable raised when a button is pressed */
  52242. onButtonDownObservable: Observable<DualShockButton>;
  52243. /** Observable raised when a button is released */
  52244. onButtonUpObservable: Observable<DualShockButton>;
  52245. /** Observable raised when a pad is pressed */
  52246. onPadDownObservable: Observable<DualShockDpad>;
  52247. /** Observable raised when a pad is released */
  52248. onPadUpObservable: Observable<DualShockDpad>;
  52249. private _buttonCross;
  52250. private _buttonCircle;
  52251. private _buttonSquare;
  52252. private _buttonTriangle;
  52253. private _buttonShare;
  52254. private _buttonOptions;
  52255. private _buttonL1;
  52256. private _buttonR1;
  52257. private _buttonLeftStick;
  52258. private _buttonRightStick;
  52259. private _dPadUp;
  52260. private _dPadDown;
  52261. private _dPadLeft;
  52262. private _dPadRight;
  52263. /**
  52264. * Creates a new DualShock gamepad object
  52265. * @param id defines the id of this gamepad
  52266. * @param index defines its index
  52267. * @param gamepad defines the internal HTML gamepad object
  52268. */
  52269. constructor(id: string, index: number, gamepad: any);
  52270. /**
  52271. * Defines the callback to call when left trigger is pressed
  52272. * @param callback defines the callback to use
  52273. */
  52274. onlefttriggerchanged(callback: (value: number) => void): void;
  52275. /**
  52276. * Defines the callback to call when right trigger is pressed
  52277. * @param callback defines the callback to use
  52278. */
  52279. onrighttriggerchanged(callback: (value: number) => void): void;
  52280. /**
  52281. * Gets the left trigger value
  52282. */
  52283. get leftTrigger(): number;
  52284. /**
  52285. * Sets the left trigger value
  52286. */
  52287. set leftTrigger(newValue: number);
  52288. /**
  52289. * Gets the right trigger value
  52290. */
  52291. get rightTrigger(): number;
  52292. /**
  52293. * Sets the right trigger value
  52294. */
  52295. set rightTrigger(newValue: number);
  52296. /**
  52297. * Defines the callback to call when a button is pressed
  52298. * @param callback defines the callback to use
  52299. */
  52300. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52301. /**
  52302. * Defines the callback to call when a button is released
  52303. * @param callback defines the callback to use
  52304. */
  52305. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52306. /**
  52307. * Defines the callback to call when a pad is pressed
  52308. * @param callback defines the callback to use
  52309. */
  52310. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52311. /**
  52312. * Defines the callback to call when a pad is released
  52313. * @param callback defines the callback to use
  52314. */
  52315. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52316. private _setButtonValue;
  52317. private _setDPadValue;
  52318. /**
  52319. * Gets the value of the `Cross` button
  52320. */
  52321. get buttonCross(): number;
  52322. /**
  52323. * Sets the value of the `Cross` button
  52324. */
  52325. set buttonCross(value: number);
  52326. /**
  52327. * Gets the value of the `Circle` button
  52328. */
  52329. get buttonCircle(): number;
  52330. /**
  52331. * Sets the value of the `Circle` button
  52332. */
  52333. set buttonCircle(value: number);
  52334. /**
  52335. * Gets the value of the `Square` button
  52336. */
  52337. get buttonSquare(): number;
  52338. /**
  52339. * Sets the value of the `Square` button
  52340. */
  52341. set buttonSquare(value: number);
  52342. /**
  52343. * Gets the value of the `Triangle` button
  52344. */
  52345. get buttonTriangle(): number;
  52346. /**
  52347. * Sets the value of the `Triangle` button
  52348. */
  52349. set buttonTriangle(value: number);
  52350. /**
  52351. * Gets the value of the `Options` button
  52352. */
  52353. get buttonOptions(): number;
  52354. /**
  52355. * Sets the value of the `Options` button
  52356. */
  52357. set buttonOptions(value: number);
  52358. /**
  52359. * Gets the value of the `Share` button
  52360. */
  52361. get buttonShare(): number;
  52362. /**
  52363. * Sets the value of the `Share` button
  52364. */
  52365. set buttonShare(value: number);
  52366. /**
  52367. * Gets the value of the `L1` button
  52368. */
  52369. get buttonL1(): number;
  52370. /**
  52371. * Sets the value of the `L1` button
  52372. */
  52373. set buttonL1(value: number);
  52374. /**
  52375. * Gets the value of the `R1` button
  52376. */
  52377. get buttonR1(): number;
  52378. /**
  52379. * Sets the value of the `R1` button
  52380. */
  52381. set buttonR1(value: number);
  52382. /**
  52383. * Gets the value of the Left joystick
  52384. */
  52385. get buttonLeftStick(): number;
  52386. /**
  52387. * Sets the value of the Left joystick
  52388. */
  52389. set buttonLeftStick(value: number);
  52390. /**
  52391. * Gets the value of the Right joystick
  52392. */
  52393. get buttonRightStick(): number;
  52394. /**
  52395. * Sets the value of the Right joystick
  52396. */
  52397. set buttonRightStick(value: number);
  52398. /**
  52399. * Gets the value of D-pad up
  52400. */
  52401. get dPadUp(): number;
  52402. /**
  52403. * Sets the value of D-pad up
  52404. */
  52405. set dPadUp(value: number);
  52406. /**
  52407. * Gets the value of D-pad down
  52408. */
  52409. get dPadDown(): number;
  52410. /**
  52411. * Sets the value of D-pad down
  52412. */
  52413. set dPadDown(value: number);
  52414. /**
  52415. * Gets the value of D-pad left
  52416. */
  52417. get dPadLeft(): number;
  52418. /**
  52419. * Sets the value of D-pad left
  52420. */
  52421. set dPadLeft(value: number);
  52422. /**
  52423. * Gets the value of D-pad right
  52424. */
  52425. get dPadRight(): number;
  52426. /**
  52427. * Sets the value of D-pad right
  52428. */
  52429. set dPadRight(value: number);
  52430. /**
  52431. * Force the gamepad to synchronize with device values
  52432. */
  52433. update(): void;
  52434. /**
  52435. * Disposes the gamepad
  52436. */
  52437. dispose(): void;
  52438. }
  52439. }
  52440. declare module BABYLON {
  52441. /**
  52442. * Manager for handling gamepads
  52443. */
  52444. export class GamepadManager {
  52445. private _scene?;
  52446. private _babylonGamepads;
  52447. private _oneGamepadConnected;
  52448. /** @hidden */
  52449. _isMonitoring: boolean;
  52450. private _gamepadEventSupported;
  52451. private _gamepadSupport?;
  52452. /**
  52453. * observable to be triggered when the gamepad controller has been connected
  52454. */
  52455. onGamepadConnectedObservable: Observable<Gamepad>;
  52456. /**
  52457. * observable to be triggered when the gamepad controller has been disconnected
  52458. */
  52459. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52460. private _onGamepadConnectedEvent;
  52461. private _onGamepadDisconnectedEvent;
  52462. /**
  52463. * Initializes the gamepad manager
  52464. * @param _scene BabylonJS scene
  52465. */
  52466. constructor(_scene?: Scene | undefined);
  52467. /**
  52468. * The gamepads in the game pad manager
  52469. */
  52470. get gamepads(): Gamepad[];
  52471. /**
  52472. * Get the gamepad controllers based on type
  52473. * @param type The type of gamepad controller
  52474. * @returns Nullable gamepad
  52475. */
  52476. getGamepadByType(type?: number): Nullable<Gamepad>;
  52477. /**
  52478. * Disposes the gamepad manager
  52479. */
  52480. dispose(): void;
  52481. private _addNewGamepad;
  52482. private _startMonitoringGamepads;
  52483. private _stopMonitoringGamepads;
  52484. /** @hidden */
  52485. _checkGamepadsStatus(): void;
  52486. private _updateGamepadObjects;
  52487. }
  52488. }
  52489. declare module BABYLON {
  52490. interface Scene {
  52491. /** @hidden */
  52492. _gamepadManager: Nullable<GamepadManager>;
  52493. /**
  52494. * Gets the gamepad manager associated with the scene
  52495. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52496. */
  52497. gamepadManager: GamepadManager;
  52498. }
  52499. /**
  52500. * Interface representing a free camera inputs manager
  52501. */
  52502. interface FreeCameraInputsManager {
  52503. /**
  52504. * Adds gamepad input support to the FreeCameraInputsManager.
  52505. * @returns the FreeCameraInputsManager
  52506. */
  52507. addGamepad(): FreeCameraInputsManager;
  52508. }
  52509. /**
  52510. * Interface representing an arc rotate camera inputs manager
  52511. */
  52512. interface ArcRotateCameraInputsManager {
  52513. /**
  52514. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52515. * @returns the camera inputs manager
  52516. */
  52517. addGamepad(): ArcRotateCameraInputsManager;
  52518. }
  52519. /**
  52520. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52521. */
  52522. export class GamepadSystemSceneComponent implements ISceneComponent {
  52523. /**
  52524. * The component name helpfull to identify the component in the list of scene components.
  52525. */
  52526. readonly name: string;
  52527. /**
  52528. * The scene the component belongs to.
  52529. */
  52530. scene: Scene;
  52531. /**
  52532. * Creates a new instance of the component for the given scene
  52533. * @param scene Defines the scene to register the component in
  52534. */
  52535. constructor(scene: Scene);
  52536. /**
  52537. * Registers the component in a given scene
  52538. */
  52539. register(): void;
  52540. /**
  52541. * Rebuilds the elements related to this component in case of
  52542. * context lost for instance.
  52543. */
  52544. rebuild(): void;
  52545. /**
  52546. * Disposes the component and the associated ressources
  52547. */
  52548. dispose(): void;
  52549. private _beforeCameraUpdate;
  52550. }
  52551. }
  52552. declare module BABYLON {
  52553. /**
  52554. * 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,
  52555. * which still works and will still be found in many Playgrounds.
  52556. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52557. */
  52558. export class UniversalCamera extends TouchCamera {
  52559. /**
  52560. * Defines the gamepad rotation sensiblity.
  52561. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52562. */
  52563. get gamepadAngularSensibility(): number;
  52564. set gamepadAngularSensibility(value: number);
  52565. /**
  52566. * Defines the gamepad move sensiblity.
  52567. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52568. */
  52569. get gamepadMoveSensibility(): number;
  52570. set gamepadMoveSensibility(value: number);
  52571. /**
  52572. * 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,
  52573. * which still works and will still be found in many Playgrounds.
  52574. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52575. * @param name Define the name of the camera in the scene
  52576. * @param position Define the start position of the camera in the scene
  52577. * @param scene Define the scene the camera belongs to
  52578. */
  52579. constructor(name: string, position: Vector3, scene: Scene);
  52580. /**
  52581. * Gets the current object class name.
  52582. * @return the class name
  52583. */
  52584. getClassName(): string;
  52585. }
  52586. }
  52587. declare module BABYLON {
  52588. /**
  52589. * This represents a FPS type of camera. This is only here for back compat purpose.
  52590. * Please use the UniversalCamera instead as both are identical.
  52591. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52592. */
  52593. export class GamepadCamera extends UniversalCamera {
  52594. /**
  52595. * Instantiates a new Gamepad Camera
  52596. * This represents a FPS type of camera. This is only here for back compat purpose.
  52597. * Please use the UniversalCamera instead as both are identical.
  52598. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52599. * @param name Define the name of the camera in the scene
  52600. * @param position Define the start position of the camera in the scene
  52601. * @param scene Define the scene the camera belongs to
  52602. */
  52603. constructor(name: string, position: Vector3, scene: Scene);
  52604. /**
  52605. * Gets the current object class name.
  52606. * @return the class name
  52607. */
  52608. getClassName(): string;
  52609. }
  52610. }
  52611. declare module BABYLON {
  52612. /** @hidden */
  52613. export var anaglyphPixelShader: {
  52614. name: string;
  52615. shader: string;
  52616. };
  52617. }
  52618. declare module BABYLON {
  52619. /**
  52620. * Postprocess used to generate anaglyphic rendering
  52621. */
  52622. export class AnaglyphPostProcess extends PostProcess {
  52623. private _passedProcess;
  52624. /**
  52625. * Gets a string identifying the name of the class
  52626. * @returns "AnaglyphPostProcess" string
  52627. */
  52628. getClassName(): string;
  52629. /**
  52630. * Creates a new AnaglyphPostProcess
  52631. * @param name defines postprocess name
  52632. * @param options defines creation options or target ratio scale
  52633. * @param rigCameras defines cameras using this postprocess
  52634. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52635. * @param engine defines hosting engine
  52636. * @param reusable defines if the postprocess will be reused multiple times per frame
  52637. */
  52638. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52639. }
  52640. }
  52641. declare module BABYLON {
  52642. /**
  52643. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52644. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52645. */
  52646. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52647. /**
  52648. * Creates a new AnaglyphArcRotateCamera
  52649. * @param name defines camera name
  52650. * @param alpha defines alpha angle (in radians)
  52651. * @param beta defines beta angle (in radians)
  52652. * @param radius defines radius
  52653. * @param target defines camera target
  52654. * @param interaxialDistance defines distance between each color axis
  52655. * @param scene defines the hosting scene
  52656. */
  52657. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52658. /**
  52659. * Gets camera class name
  52660. * @returns AnaglyphArcRotateCamera
  52661. */
  52662. getClassName(): string;
  52663. }
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52668. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52669. */
  52670. export class AnaglyphFreeCamera extends FreeCamera {
  52671. /**
  52672. * Creates a new AnaglyphFreeCamera
  52673. * @param name defines camera name
  52674. * @param position defines initial position
  52675. * @param interaxialDistance defines distance between each color axis
  52676. * @param scene defines the hosting scene
  52677. */
  52678. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52679. /**
  52680. * Gets camera class name
  52681. * @returns AnaglyphFreeCamera
  52682. */
  52683. getClassName(): string;
  52684. }
  52685. }
  52686. declare module BABYLON {
  52687. /**
  52688. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52689. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52690. */
  52691. export class AnaglyphGamepadCamera extends GamepadCamera {
  52692. /**
  52693. * Creates a new AnaglyphGamepadCamera
  52694. * @param name defines camera name
  52695. * @param position defines initial position
  52696. * @param interaxialDistance defines distance between each color axis
  52697. * @param scene defines the hosting scene
  52698. */
  52699. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52700. /**
  52701. * Gets camera class name
  52702. * @returns AnaglyphGamepadCamera
  52703. */
  52704. getClassName(): string;
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /**
  52709. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52710. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52711. */
  52712. export class AnaglyphUniversalCamera extends UniversalCamera {
  52713. /**
  52714. * Creates a new AnaglyphUniversalCamera
  52715. * @param name defines camera name
  52716. * @param position defines initial position
  52717. * @param interaxialDistance defines distance between each color axis
  52718. * @param scene defines the hosting scene
  52719. */
  52720. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52721. /**
  52722. * Gets camera class name
  52723. * @returns AnaglyphUniversalCamera
  52724. */
  52725. getClassName(): string;
  52726. }
  52727. }
  52728. declare module BABYLON {
  52729. /** @hidden */
  52730. export var stereoscopicInterlacePixelShader: {
  52731. name: string;
  52732. shader: string;
  52733. };
  52734. }
  52735. declare module BABYLON {
  52736. /**
  52737. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  52738. */
  52739. export class StereoscopicInterlacePostProcessI extends PostProcess {
  52740. private _stepSize;
  52741. private _passedProcess;
  52742. /**
  52743. * Gets a string identifying the name of the class
  52744. * @returns "StereoscopicInterlacePostProcessI" string
  52745. */
  52746. getClassName(): string;
  52747. /**
  52748. * Initializes a StereoscopicInterlacePostProcessI
  52749. * @param name The name of the effect.
  52750. * @param rigCameras The rig cameras to be appled to the post process
  52751. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  52752. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  52753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52754. * @param engine The engine which the post process will be applied. (default: current engine)
  52755. * @param reusable If the post process can be reused on the same frame. (default: false)
  52756. */
  52757. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52758. }
  52759. /**
  52760. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  52761. */
  52762. export class StereoscopicInterlacePostProcess extends PostProcess {
  52763. private _stepSize;
  52764. private _passedProcess;
  52765. /**
  52766. * Gets a string identifying the name of the class
  52767. * @returns "StereoscopicInterlacePostProcess" string
  52768. */
  52769. getClassName(): string;
  52770. /**
  52771. * Initializes a StereoscopicInterlacePostProcess
  52772. * @param name The name of the effect.
  52773. * @param rigCameras The rig cameras to be appled to the post process
  52774. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  52775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52776. * @param engine The engine which the post process will be applied. (default: current engine)
  52777. * @param reusable If the post process can be reused on the same frame. (default: false)
  52778. */
  52779. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /**
  52784. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52785. * @see https://doc.babylonjs.com/features/cameras
  52786. */
  52787. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52788. /**
  52789. * Creates a new StereoscopicArcRotateCamera
  52790. * @param name defines camera name
  52791. * @param alpha defines alpha angle (in radians)
  52792. * @param beta defines beta angle (in radians)
  52793. * @param radius defines radius
  52794. * @param target defines camera target
  52795. * @param interaxialDistance defines distance between each color axis
  52796. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52797. * @param scene defines the hosting scene
  52798. */
  52799. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52800. /**
  52801. * Gets camera class name
  52802. * @returns StereoscopicArcRotateCamera
  52803. */
  52804. getClassName(): string;
  52805. }
  52806. }
  52807. declare module BABYLON {
  52808. /**
  52809. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52810. * @see https://doc.babylonjs.com/features/cameras
  52811. */
  52812. export class StereoscopicFreeCamera extends FreeCamera {
  52813. /**
  52814. * Creates a new StereoscopicFreeCamera
  52815. * @param name defines camera name
  52816. * @param position defines initial position
  52817. * @param interaxialDistance defines distance between each color axis
  52818. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52819. * @param scene defines the hosting scene
  52820. */
  52821. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52822. /**
  52823. * Gets camera class name
  52824. * @returns StereoscopicFreeCamera
  52825. */
  52826. getClassName(): string;
  52827. }
  52828. }
  52829. declare module BABYLON {
  52830. /**
  52831. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52832. * @see https://doc.babylonjs.com/features/cameras
  52833. */
  52834. export class StereoscopicGamepadCamera extends GamepadCamera {
  52835. /**
  52836. * Creates a new StereoscopicGamepadCamera
  52837. * @param name defines camera name
  52838. * @param position defines initial position
  52839. * @param interaxialDistance defines distance between each color axis
  52840. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52841. * @param scene defines the hosting scene
  52842. */
  52843. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52844. /**
  52845. * Gets camera class name
  52846. * @returns StereoscopicGamepadCamera
  52847. */
  52848. getClassName(): string;
  52849. }
  52850. }
  52851. declare module BABYLON {
  52852. /**
  52853. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52854. * @see https://doc.babylonjs.com/features/cameras
  52855. */
  52856. export class StereoscopicUniversalCamera extends UniversalCamera {
  52857. /**
  52858. * Creates a new StereoscopicUniversalCamera
  52859. * @param name defines camera name
  52860. * @param position defines initial position
  52861. * @param interaxialDistance defines distance between each color axis
  52862. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52863. * @param scene defines the hosting scene
  52864. */
  52865. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52866. /**
  52867. * Gets camera class name
  52868. * @returns StereoscopicUniversalCamera
  52869. */
  52870. getClassName(): string;
  52871. }
  52872. }
  52873. declare module BABYLON {
  52874. /**
  52875. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52876. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52877. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52878. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52879. */
  52880. export class VirtualJoysticksCamera extends FreeCamera {
  52881. /**
  52882. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52883. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52884. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52885. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52886. * @param name Define the name of the camera in the scene
  52887. * @param position Define the start position of the camera in the scene
  52888. * @param scene Define the scene the camera belongs to
  52889. */
  52890. constructor(name: string, position: Vector3, scene: Scene);
  52891. /**
  52892. * Gets the current object class name.
  52893. * @return the class name
  52894. */
  52895. getClassName(): string;
  52896. }
  52897. }
  52898. declare module BABYLON {
  52899. /**
  52900. * This represents all the required metrics to create a VR camera.
  52901. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52902. */
  52903. export class VRCameraMetrics {
  52904. /**
  52905. * Define the horizontal resolution off the screen.
  52906. */
  52907. hResolution: number;
  52908. /**
  52909. * Define the vertical resolution off the screen.
  52910. */
  52911. vResolution: number;
  52912. /**
  52913. * Define the horizontal screen size.
  52914. */
  52915. hScreenSize: number;
  52916. /**
  52917. * Define the vertical screen size.
  52918. */
  52919. vScreenSize: number;
  52920. /**
  52921. * Define the vertical screen center position.
  52922. */
  52923. vScreenCenter: number;
  52924. /**
  52925. * Define the distance of the eyes to the screen.
  52926. */
  52927. eyeToScreenDistance: number;
  52928. /**
  52929. * Define the distance between both lenses
  52930. */
  52931. lensSeparationDistance: number;
  52932. /**
  52933. * Define the distance between both viewer's eyes.
  52934. */
  52935. interpupillaryDistance: number;
  52936. /**
  52937. * Define the distortion factor of the VR postprocess.
  52938. * Please, touch with care.
  52939. */
  52940. distortionK: number[];
  52941. /**
  52942. * Define the chromatic aberration correction factors for the VR post process.
  52943. */
  52944. chromaAbCorrection: number[];
  52945. /**
  52946. * Define the scale factor of the post process.
  52947. * The smaller the better but the slower.
  52948. */
  52949. postProcessScaleFactor: number;
  52950. /**
  52951. * Define an offset for the lens center.
  52952. */
  52953. lensCenterOffset: number;
  52954. /**
  52955. * Define if the current vr camera should compensate the distortion of the lense or not.
  52956. */
  52957. compensateDistortion: boolean;
  52958. /**
  52959. * Defines if multiview should be enabled when rendering (Default: false)
  52960. */
  52961. multiviewEnabled: boolean;
  52962. /**
  52963. * Gets the rendering aspect ratio based on the provided resolutions.
  52964. */
  52965. get aspectRatio(): number;
  52966. /**
  52967. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52968. */
  52969. get aspectRatioFov(): number;
  52970. /**
  52971. * @hidden
  52972. */
  52973. get leftHMatrix(): Matrix;
  52974. /**
  52975. * @hidden
  52976. */
  52977. get rightHMatrix(): Matrix;
  52978. /**
  52979. * @hidden
  52980. */
  52981. get leftPreViewMatrix(): Matrix;
  52982. /**
  52983. * @hidden
  52984. */
  52985. get rightPreViewMatrix(): Matrix;
  52986. /**
  52987. * Get the default VRMetrics based on the most generic setup.
  52988. * @returns the default vr metrics
  52989. */
  52990. static GetDefault(): VRCameraMetrics;
  52991. }
  52992. }
  52993. declare module BABYLON {
  52994. /** @hidden */
  52995. export var vrDistortionCorrectionPixelShader: {
  52996. name: string;
  52997. shader: string;
  52998. };
  52999. }
  53000. declare module BABYLON {
  53001. /**
  53002. * VRDistortionCorrectionPostProcess used for mobile VR
  53003. */
  53004. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53005. private _isRightEye;
  53006. private _distortionFactors;
  53007. private _postProcessScaleFactor;
  53008. private _lensCenterOffset;
  53009. private _scaleIn;
  53010. private _scaleFactor;
  53011. private _lensCenter;
  53012. /**
  53013. * Gets a string identifying the name of the class
  53014. * @returns "VRDistortionCorrectionPostProcess" string
  53015. */
  53016. getClassName(): string;
  53017. /**
  53018. * Initializes the VRDistortionCorrectionPostProcess
  53019. * @param name The name of the effect.
  53020. * @param camera The camera to apply the render pass to.
  53021. * @param isRightEye If this is for the right eye distortion
  53022. * @param vrMetrics All the required metrics for the VR camera
  53023. */
  53024. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53025. }
  53026. }
  53027. declare module BABYLON {
  53028. /**
  53029. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53030. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53031. */
  53032. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53033. /**
  53034. * Creates a new VRDeviceOrientationArcRotateCamera
  53035. * @param name defines camera name
  53036. * @param alpha defines the camera rotation along the logitudinal axis
  53037. * @param beta defines the camera rotation along the latitudinal axis
  53038. * @param radius defines the camera distance from its target
  53039. * @param target defines the camera target
  53040. * @param scene defines the scene the camera belongs to
  53041. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53042. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53043. */
  53044. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53045. /**
  53046. * Gets camera class name
  53047. * @returns VRDeviceOrientationArcRotateCamera
  53048. */
  53049. getClassName(): string;
  53050. }
  53051. }
  53052. declare module BABYLON {
  53053. /**
  53054. * Camera used to simulate VR rendering (based on FreeCamera)
  53055. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53056. */
  53057. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53058. /**
  53059. * Creates a new VRDeviceOrientationFreeCamera
  53060. * @param name defines camera name
  53061. * @param position defines the start position of the camera
  53062. * @param scene defines the scene the camera belongs to
  53063. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53064. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53065. */
  53066. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53067. /**
  53068. * Gets camera class name
  53069. * @returns VRDeviceOrientationFreeCamera
  53070. */
  53071. getClassName(): string;
  53072. }
  53073. }
  53074. declare module BABYLON {
  53075. /**
  53076. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53077. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53078. */
  53079. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53080. /**
  53081. * Creates a new VRDeviceOrientationGamepadCamera
  53082. * @param name defines camera name
  53083. * @param position defines the start position of the camera
  53084. * @param scene defines the scene the camera belongs to
  53085. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53086. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53087. */
  53088. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53089. /**
  53090. * Gets camera class name
  53091. * @returns VRDeviceOrientationGamepadCamera
  53092. */
  53093. getClassName(): string;
  53094. }
  53095. }
  53096. declare module BABYLON {
  53097. /**
  53098. * A class extending Texture allowing drawing on a texture
  53099. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53100. */
  53101. export class DynamicTexture extends Texture {
  53102. private _generateMipMaps;
  53103. private _canvas;
  53104. private _context;
  53105. /**
  53106. * Creates a DynamicTexture
  53107. * @param name defines the name of the texture
  53108. * @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
  53109. * @param scene defines the scene where you want the texture
  53110. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53111. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53112. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53113. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53114. */
  53115. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53116. /**
  53117. * Get the current class name of the texture useful for serialization or dynamic coding.
  53118. * @returns "DynamicTexture"
  53119. */
  53120. getClassName(): string;
  53121. /**
  53122. * Gets the current state of canRescale
  53123. */
  53124. get canRescale(): boolean;
  53125. private _recreate;
  53126. /**
  53127. * Scales the texture
  53128. * @param ratio the scale factor to apply to both width and height
  53129. */
  53130. scale(ratio: number): void;
  53131. /**
  53132. * Resizes the texture
  53133. * @param width the new width
  53134. * @param height the new height
  53135. */
  53136. scaleTo(width: number, height: number): void;
  53137. /**
  53138. * Gets the context of the canvas used by the texture
  53139. * @returns the canvas context of the dynamic texture
  53140. */
  53141. getContext(): CanvasRenderingContext2D;
  53142. /**
  53143. * Clears the texture
  53144. */
  53145. clear(): void;
  53146. /**
  53147. * Updates the texture
  53148. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53149. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53150. */
  53151. update(invertY?: boolean, premulAlpha?: boolean): void;
  53152. /**
  53153. * Draws text onto the texture
  53154. * @param text defines the text to be drawn
  53155. * @param x defines the placement of the text from the left
  53156. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53157. * @param font defines the font to be used with font-style, font-size, font-name
  53158. * @param color defines the color used for the text
  53159. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53160. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53161. * @param update defines whether texture is immediately update (default is true)
  53162. */
  53163. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53164. /**
  53165. * Clones the texture
  53166. * @returns the clone of the texture.
  53167. */
  53168. clone(): DynamicTexture;
  53169. /**
  53170. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53171. * @returns a serialized dynamic texture object
  53172. */
  53173. serialize(): any;
  53174. private _IsCanvasElement;
  53175. /** @hidden */
  53176. _rebuild(): void;
  53177. }
  53178. }
  53179. declare module BABYLON {
  53180. /**
  53181. * Class containing static functions to help procedurally build meshes
  53182. */
  53183. export class GroundBuilder {
  53184. /**
  53185. * Creates a ground mesh
  53186. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53187. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53189. * @param name defines the name of the mesh
  53190. * @param options defines the options used to create the mesh
  53191. * @param scene defines the hosting scene
  53192. * @returns the ground mesh
  53193. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53194. */
  53195. static CreateGround(name: string, options: {
  53196. width?: number;
  53197. height?: number;
  53198. subdivisions?: number;
  53199. subdivisionsX?: number;
  53200. subdivisionsY?: number;
  53201. updatable?: boolean;
  53202. }, scene: any): Mesh;
  53203. /**
  53204. * Creates a tiled ground mesh
  53205. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53206. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53207. * * 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
  53208. * * 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
  53209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53210. * @param name defines the name of the mesh
  53211. * @param options defines the options used to create the mesh
  53212. * @param scene defines the hosting scene
  53213. * @returns the tiled ground mesh
  53214. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53215. */
  53216. static CreateTiledGround(name: string, options: {
  53217. xmin: number;
  53218. zmin: number;
  53219. xmax: number;
  53220. zmax: number;
  53221. subdivisions?: {
  53222. w: number;
  53223. h: number;
  53224. };
  53225. precision?: {
  53226. w: number;
  53227. h: number;
  53228. };
  53229. updatable?: boolean;
  53230. }, scene?: Nullable<Scene>): Mesh;
  53231. /**
  53232. * Creates a ground mesh from a height map
  53233. * * The parameter `url` sets the URL of the height map image resource.
  53234. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53235. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53236. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53237. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53238. * * 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.
  53239. * * 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).
  53240. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53242. * @param name defines the name of the mesh
  53243. * @param url defines the url to the height map
  53244. * @param options defines the options used to create the mesh
  53245. * @param scene defines the hosting scene
  53246. * @returns the ground mesh
  53247. * @see https://doc.babylonjs.com/babylon101/height_map
  53248. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53249. */
  53250. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53251. width?: number;
  53252. height?: number;
  53253. subdivisions?: number;
  53254. minHeight?: number;
  53255. maxHeight?: number;
  53256. colorFilter?: Color3;
  53257. alphaFilter?: number;
  53258. updatable?: boolean;
  53259. onReady?: (mesh: GroundMesh) => void;
  53260. }, scene?: Nullable<Scene>): GroundMesh;
  53261. }
  53262. }
  53263. declare module BABYLON {
  53264. /**
  53265. * Class containing static functions to help procedurally build meshes
  53266. */
  53267. export class TorusBuilder {
  53268. /**
  53269. * Creates a torus mesh
  53270. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53271. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53272. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53274. * * 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
  53275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53276. * @param name defines the name of the mesh
  53277. * @param options defines the options used to create the mesh
  53278. * @param scene defines the hosting scene
  53279. * @returns the torus mesh
  53280. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53281. */
  53282. static CreateTorus(name: string, options: {
  53283. diameter?: number;
  53284. thickness?: number;
  53285. tessellation?: number;
  53286. updatable?: boolean;
  53287. sideOrientation?: number;
  53288. frontUVs?: Vector4;
  53289. backUVs?: Vector4;
  53290. }, scene: any): Mesh;
  53291. }
  53292. }
  53293. declare module BABYLON {
  53294. /**
  53295. * Class containing static functions to help procedurally build meshes
  53296. */
  53297. export class CylinderBuilder {
  53298. /**
  53299. * Creates a cylinder or a cone mesh
  53300. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53301. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53302. * * 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.
  53303. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53304. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53305. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53306. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53307. * * 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).
  53308. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53309. * * 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).
  53310. * * 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
  53311. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53312. * * 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
  53313. * * 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.
  53314. * * If `enclose` is false, a ring surface is one element.
  53315. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53316. * * 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
  53317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53318. * * 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
  53319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53320. * @param name defines the name of the mesh
  53321. * @param options defines the options used to create the mesh
  53322. * @param scene defines the hosting scene
  53323. * @returns the cylinder mesh
  53324. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53325. */
  53326. static CreateCylinder(name: string, options: {
  53327. height?: number;
  53328. diameterTop?: number;
  53329. diameterBottom?: number;
  53330. diameter?: number;
  53331. tessellation?: number;
  53332. subdivisions?: number;
  53333. arc?: number;
  53334. faceColors?: Color4[];
  53335. faceUV?: Vector4[];
  53336. updatable?: boolean;
  53337. hasRings?: boolean;
  53338. enclose?: boolean;
  53339. cap?: number;
  53340. sideOrientation?: number;
  53341. frontUVs?: Vector4;
  53342. backUVs?: Vector4;
  53343. }, scene: any): Mesh;
  53344. }
  53345. }
  53346. declare module BABYLON {
  53347. /**
  53348. * States of the webXR experience
  53349. */
  53350. export enum WebXRState {
  53351. /**
  53352. * Transitioning to being in XR mode
  53353. */
  53354. ENTERING_XR = 0,
  53355. /**
  53356. * Transitioning to non XR mode
  53357. */
  53358. EXITING_XR = 1,
  53359. /**
  53360. * In XR mode and presenting
  53361. */
  53362. IN_XR = 2,
  53363. /**
  53364. * Not entered XR mode
  53365. */
  53366. NOT_IN_XR = 3
  53367. }
  53368. /**
  53369. * The state of the XR camera's tracking
  53370. */
  53371. export enum WebXRTrackingState {
  53372. /**
  53373. * No transformation received, device is not being tracked
  53374. */
  53375. NOT_TRACKING = 0,
  53376. /**
  53377. * Tracking lost - using emulated position
  53378. */
  53379. TRACKING_LOST = 1,
  53380. /**
  53381. * Transformation tracking works normally
  53382. */
  53383. TRACKING = 2
  53384. }
  53385. /**
  53386. * Abstraction of the XR render target
  53387. */
  53388. export interface WebXRRenderTarget extends IDisposable {
  53389. /**
  53390. * xrpresent context of the canvas which can be used to display/mirror xr content
  53391. */
  53392. canvasContext: WebGLRenderingContext;
  53393. /**
  53394. * xr layer for the canvas
  53395. */
  53396. xrLayer: Nullable<XRWebGLLayer>;
  53397. /**
  53398. * Initializes the xr layer for the session
  53399. * @param xrSession xr session
  53400. * @returns a promise that will resolve once the XR Layer has been created
  53401. */
  53402. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53403. }
  53404. }
  53405. declare module BABYLON {
  53406. /**
  53407. * COnfiguration object for WebXR output canvas
  53408. */
  53409. export class WebXRManagedOutputCanvasOptions {
  53410. /**
  53411. * An optional canvas in case you wish to create it yourself and provide it here.
  53412. * If not provided, a new canvas will be created
  53413. */
  53414. canvasElement?: HTMLCanvasElement;
  53415. /**
  53416. * Options for this XR Layer output
  53417. */
  53418. canvasOptions?: XRWebGLLayerInit;
  53419. /**
  53420. * CSS styling for a newly created canvas (if not provided)
  53421. */
  53422. newCanvasCssStyle?: string;
  53423. /**
  53424. * Get the default values of the configuration object
  53425. * @param engine defines the engine to use (can be null)
  53426. * @returns default values of this configuration object
  53427. */
  53428. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53429. }
  53430. /**
  53431. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53432. */
  53433. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53434. private _options;
  53435. private _canvas;
  53436. private _engine;
  53437. private _originalCanvasSize;
  53438. /**
  53439. * Rendering context of the canvas which can be used to display/mirror xr content
  53440. */
  53441. canvasContext: WebGLRenderingContext;
  53442. /**
  53443. * xr layer for the canvas
  53444. */
  53445. xrLayer: Nullable<XRWebGLLayer>;
  53446. /**
  53447. * Obseervers registered here will be triggered when the xr layer was initialized
  53448. */
  53449. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53450. /**
  53451. * Initializes the canvas to be added/removed upon entering/exiting xr
  53452. * @param _xrSessionManager The XR Session manager
  53453. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53454. */
  53455. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53456. /**
  53457. * Disposes of the object
  53458. */
  53459. dispose(): void;
  53460. /**
  53461. * Initializes the xr layer for the session
  53462. * @param xrSession xr session
  53463. * @returns a promise that will resolve once the XR Layer has been created
  53464. */
  53465. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53466. private _addCanvas;
  53467. private _removeCanvas;
  53468. private _setCanvasSize;
  53469. private _setManagedOutputCanvas;
  53470. }
  53471. }
  53472. declare module BABYLON {
  53473. /**
  53474. * Manages an XRSession to work with Babylon's engine
  53475. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53476. */
  53477. export class WebXRSessionManager implements IDisposable {
  53478. /** The scene which the session should be created for */
  53479. scene: Scene;
  53480. private _referenceSpace;
  53481. private _rttProvider;
  53482. private _sessionEnded;
  53483. private _xrNavigator;
  53484. private baseLayer;
  53485. /**
  53486. * The base reference space from which the session started. good if you want to reset your
  53487. * reference space
  53488. */
  53489. baseReferenceSpace: XRReferenceSpace;
  53490. /**
  53491. * Current XR frame
  53492. */
  53493. currentFrame: Nullable<XRFrame>;
  53494. /** WebXR timestamp updated every frame */
  53495. currentTimestamp: number;
  53496. /**
  53497. * Used just in case of a failure to initialize an immersive session.
  53498. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53499. */
  53500. defaultHeightCompensation: number;
  53501. /**
  53502. * Fires every time a new xrFrame arrives which can be used to update the camera
  53503. */
  53504. onXRFrameObservable: Observable<XRFrame>;
  53505. /**
  53506. * Fires when the reference space changed
  53507. */
  53508. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53509. /**
  53510. * Fires when the xr session is ended either by the device or manually done
  53511. */
  53512. onXRSessionEnded: Observable<any>;
  53513. /**
  53514. * Fires when the xr session is ended either by the device or manually done
  53515. */
  53516. onXRSessionInit: Observable<XRSession>;
  53517. /**
  53518. * Underlying xr session
  53519. */
  53520. session: XRSession;
  53521. /**
  53522. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53523. * or get the offset the player is currently at.
  53524. */
  53525. viewerReferenceSpace: XRReferenceSpace;
  53526. /**
  53527. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53528. * @param scene The scene which the session should be created for
  53529. */
  53530. constructor(
  53531. /** The scene which the session should be created for */
  53532. scene: Scene);
  53533. /**
  53534. * The current reference space used in this session. This reference space can constantly change!
  53535. * It is mainly used to offset the camera's position.
  53536. */
  53537. get referenceSpace(): XRReferenceSpace;
  53538. /**
  53539. * Set a new reference space and triggers the observable
  53540. */
  53541. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53542. /**
  53543. * Disposes of the session manager
  53544. */
  53545. dispose(): void;
  53546. /**
  53547. * Stops the xrSession and restores the render loop
  53548. * @returns Promise which resolves after it exits XR
  53549. */
  53550. exitXRAsync(): Promise<void>;
  53551. /**
  53552. * Gets the correct render target texture to be rendered this frame for this eye
  53553. * @param eye the eye for which to get the render target
  53554. * @returns the render target for the specified eye
  53555. */
  53556. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53557. /**
  53558. * Creates a WebXRRenderTarget object for the XR session
  53559. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53560. * @param options optional options to provide when creating a new render target
  53561. * @returns a WebXR render target to which the session can render
  53562. */
  53563. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53564. /**
  53565. * Initializes the manager
  53566. * After initialization enterXR can be called to start an XR session
  53567. * @returns Promise which resolves after it is initialized
  53568. */
  53569. initializeAsync(): Promise<void>;
  53570. /**
  53571. * Initializes an xr session
  53572. * @param xrSessionMode mode to initialize
  53573. * @param xrSessionInit defines optional and required values to pass to the session builder
  53574. * @returns a promise which will resolve once the session has been initialized
  53575. */
  53576. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53577. /**
  53578. * Checks if a session would be supported for the creation options specified
  53579. * @param sessionMode session mode to check if supported eg. immersive-vr
  53580. * @returns A Promise that resolves to true if supported and false if not
  53581. */
  53582. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53583. /**
  53584. * Resets the reference space to the one started the session
  53585. */
  53586. resetReferenceSpace(): void;
  53587. /**
  53588. * Starts rendering to the xr layer
  53589. */
  53590. runXRRenderLoop(): void;
  53591. /**
  53592. * Sets the reference space on the xr session
  53593. * @param referenceSpaceType space to set
  53594. * @returns a promise that will resolve once the reference space has been set
  53595. */
  53596. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53597. /**
  53598. * Updates the render state of the session
  53599. * @param state state to set
  53600. * @returns a promise that resolves once the render state has been updated
  53601. */
  53602. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53603. /**
  53604. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53605. * @param sessionMode defines the session to test
  53606. * @returns a promise with boolean as final value
  53607. */
  53608. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53609. /**
  53610. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53611. */
  53612. get isNative(): boolean;
  53613. private _createRenderTargetTexture;
  53614. }
  53615. }
  53616. declare module BABYLON {
  53617. /**
  53618. * WebXR Camera which holds the views for the xrSession
  53619. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53620. */
  53621. export class WebXRCamera extends FreeCamera {
  53622. private _xrSessionManager;
  53623. private _firstFrame;
  53624. private _referenceQuaternion;
  53625. private _referencedPosition;
  53626. private _xrInvPositionCache;
  53627. private _xrInvQuaternionCache;
  53628. private _trackingState;
  53629. /**
  53630. * Observable raised before camera teleportation
  53631. */
  53632. onBeforeCameraTeleport: Observable<Vector3>;
  53633. /**
  53634. * Observable raised after camera teleportation
  53635. */
  53636. onAfterCameraTeleport: Observable<Vector3>;
  53637. /**
  53638. * Notifies when the camera's tracking state has changed.
  53639. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53640. */
  53641. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53642. /**
  53643. * Should position compensation execute on first frame.
  53644. * This is used when copying the position from a native (non XR) camera
  53645. */
  53646. compensateOnFirstFrame: boolean;
  53647. /**
  53648. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53649. * @param name the name of the camera
  53650. * @param scene the scene to add the camera to
  53651. * @param _xrSessionManager a constructed xr session manager
  53652. */
  53653. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53654. /**
  53655. * Get the current XR tracking state of the camera
  53656. */
  53657. get trackingState(): WebXRTrackingState;
  53658. private _setTrackingState;
  53659. /**
  53660. * Return the user's height, unrelated to the current ground.
  53661. * This will be the y position of this camera, when ground level is 0.
  53662. */
  53663. get realWorldHeight(): number;
  53664. /** @hidden */
  53665. _updateForDualEyeDebugging(): void;
  53666. /**
  53667. * Sets this camera's transformation based on a non-vr camera
  53668. * @param otherCamera the non-vr camera to copy the transformation from
  53669. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53670. */
  53671. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53672. /**
  53673. * Gets the current instance class name ("WebXRCamera").
  53674. * @returns the class name
  53675. */
  53676. getClassName(): string;
  53677. private _rotate180;
  53678. private _updateFromXRSession;
  53679. private _updateNumberOfRigCameras;
  53680. private _updateReferenceSpace;
  53681. private _updateReferenceSpaceOffset;
  53682. }
  53683. }
  53684. declare module BABYLON {
  53685. /**
  53686. * Defining the interface required for a (webxr) feature
  53687. */
  53688. export interface IWebXRFeature extends IDisposable {
  53689. /**
  53690. * Is this feature attached
  53691. */
  53692. attached: boolean;
  53693. /**
  53694. * Should auto-attach be disabled?
  53695. */
  53696. disableAutoAttach: boolean;
  53697. /**
  53698. * Attach the feature to the session
  53699. * Will usually be called by the features manager
  53700. *
  53701. * @param force should attachment be forced (even when already attached)
  53702. * @returns true if successful.
  53703. */
  53704. attach(force?: boolean): boolean;
  53705. /**
  53706. * Detach the feature from the session
  53707. * Will usually be called by the features manager
  53708. *
  53709. * @returns true if successful.
  53710. */
  53711. detach(): boolean;
  53712. /**
  53713. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53714. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53715. *
  53716. * @returns whether or not the feature is compatible in this environment
  53717. */
  53718. isCompatible(): boolean;
  53719. /**
  53720. * Was this feature disposed;
  53721. */
  53722. isDisposed: boolean;
  53723. /**
  53724. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53725. */
  53726. xrNativeFeatureName?: string;
  53727. /**
  53728. * A list of (Babylon WebXR) features this feature depends on
  53729. */
  53730. dependsOn?: string[];
  53731. /**
  53732. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  53733. */
  53734. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  53735. }
  53736. /**
  53737. * A list of the currently available features without referencing them
  53738. */
  53739. export class WebXRFeatureName {
  53740. /**
  53741. * The name of the anchor system feature
  53742. */
  53743. static readonly ANCHOR_SYSTEM: string;
  53744. /**
  53745. * The name of the background remover feature
  53746. */
  53747. static readonly BACKGROUND_REMOVER: string;
  53748. /**
  53749. * The name of the hit test feature
  53750. */
  53751. static readonly HIT_TEST: string;
  53752. /**
  53753. * The name of the mesh detection feature
  53754. */
  53755. static readonly MESH_DETECTION: string;
  53756. /**
  53757. * physics impostors for xr controllers feature
  53758. */
  53759. static readonly PHYSICS_CONTROLLERS: string;
  53760. /**
  53761. * The name of the plane detection feature
  53762. */
  53763. static readonly PLANE_DETECTION: string;
  53764. /**
  53765. * The name of the pointer selection feature
  53766. */
  53767. static readonly POINTER_SELECTION: string;
  53768. /**
  53769. * The name of the teleportation feature
  53770. */
  53771. static readonly TELEPORTATION: string;
  53772. /**
  53773. * The name of the feature points feature.
  53774. */
  53775. static readonly FEATURE_POINTS: string;
  53776. /**
  53777. * The name of the hand tracking feature.
  53778. */
  53779. static readonly HAND_TRACKING: string;
  53780. /**
  53781. * The name of the image tracking feature
  53782. */
  53783. static readonly IMAGE_TRACKING: string;
  53784. }
  53785. /**
  53786. * Defining the constructor of a feature. Used to register the modules.
  53787. */
  53788. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53789. /**
  53790. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53791. * It is mainly used in AR sessions.
  53792. *
  53793. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53794. */
  53795. export class WebXRFeaturesManager implements IDisposable {
  53796. private _xrSessionManager;
  53797. private static readonly _AvailableFeatures;
  53798. private _features;
  53799. /**
  53800. * constructs a new features manages.
  53801. *
  53802. * @param _xrSessionManager an instance of WebXRSessionManager
  53803. */
  53804. constructor(_xrSessionManager: WebXRSessionManager);
  53805. /**
  53806. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53807. * Mainly used internally.
  53808. *
  53809. * @param featureName the name of the feature to register
  53810. * @param constructorFunction the function used to construct the module
  53811. * @param version the (babylon) version of the module
  53812. * @param stable is that a stable version of this module
  53813. */
  53814. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53815. /**
  53816. * Returns a constructor of a specific feature.
  53817. *
  53818. * @param featureName the name of the feature to construct
  53819. * @param version the version of the feature to load
  53820. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53821. * @param options optional options provided to the module.
  53822. * @returns a function that, when called, will return a new instance of this feature
  53823. */
  53824. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53825. /**
  53826. * Can be used to return the list of features currently registered
  53827. *
  53828. * @returns an Array of available features
  53829. */
  53830. static GetAvailableFeatures(): string[];
  53831. /**
  53832. * Gets the versions available for a specific feature
  53833. * @param featureName the name of the feature
  53834. * @returns an array with the available versions
  53835. */
  53836. static GetAvailableVersions(featureName: string): string[];
  53837. /**
  53838. * Return the latest unstable version of this feature
  53839. * @param featureName the name of the feature to search
  53840. * @returns the version number. if not found will return -1
  53841. */
  53842. static GetLatestVersionOfFeature(featureName: string): number;
  53843. /**
  53844. * Return the latest stable version of this feature
  53845. * @param featureName the name of the feature to search
  53846. * @returns the version number. if not found will return -1
  53847. */
  53848. static GetStableVersionOfFeature(featureName: string): number;
  53849. /**
  53850. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53851. * Can be used during a session to start a feature
  53852. * @param featureName the name of feature to attach
  53853. */
  53854. attachFeature(featureName: string): void;
  53855. /**
  53856. * Can be used inside a session or when the session ends to detach a specific feature
  53857. * @param featureName the name of the feature to detach
  53858. */
  53859. detachFeature(featureName: string): void;
  53860. /**
  53861. * Used to disable an already-enabled feature
  53862. * The feature will be disposed and will be recreated once enabled.
  53863. * @param featureName the feature to disable
  53864. * @returns true if disable was successful
  53865. */
  53866. disableFeature(featureName: string | {
  53867. Name: string;
  53868. }): boolean;
  53869. /**
  53870. * dispose this features manager
  53871. */
  53872. dispose(): void;
  53873. /**
  53874. * 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.
  53875. * 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.
  53876. *
  53877. * @param featureName the name of the feature to load or the class of the feature
  53878. * @param version optional version to load. if not provided the latest version will be enabled
  53879. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53880. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53881. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53882. * @returns a new constructed feature or throws an error if feature not found.
  53883. */
  53884. enableFeature(featureName: string | {
  53885. Name: string;
  53886. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53887. /**
  53888. * get the implementation of an enabled feature.
  53889. * @param featureName the name of the feature to load
  53890. * @returns the feature class, if found
  53891. */
  53892. getEnabledFeature(featureName: string): IWebXRFeature;
  53893. /**
  53894. * Get the list of enabled features
  53895. * @returns an array of enabled features
  53896. */
  53897. getEnabledFeatures(): string[];
  53898. /**
  53899. * This function will extend the session creation configuration object with enabled features.
  53900. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53901. * according to the defined "required" variable, provided during enableFeature call
  53902. * @param xrSessionInit the xr Session init object to extend
  53903. *
  53904. * @returns an extended XRSessionInit object
  53905. */
  53906. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  53907. }
  53908. }
  53909. declare module BABYLON {
  53910. /**
  53911. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53912. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53913. */
  53914. export class WebXRExperienceHelper implements IDisposable {
  53915. private scene;
  53916. private _nonVRCamera;
  53917. private _originalSceneAutoClear;
  53918. private _supported;
  53919. /**
  53920. * Camera used to render xr content
  53921. */
  53922. camera: WebXRCamera;
  53923. /** A features manager for this xr session */
  53924. featuresManager: WebXRFeaturesManager;
  53925. /**
  53926. * Observers registered here will be triggered after the camera's initial transformation is set
  53927. * This can be used to set a different ground level or an extra rotation.
  53928. *
  53929. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53930. * to the position set after this observable is done executing.
  53931. */
  53932. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53933. /**
  53934. * Fires when the state of the experience helper has changed
  53935. */
  53936. onStateChangedObservable: Observable<WebXRState>;
  53937. /** Session manager used to keep track of xr session */
  53938. sessionManager: WebXRSessionManager;
  53939. /**
  53940. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53941. */
  53942. state: WebXRState;
  53943. /**
  53944. * Creates a WebXRExperienceHelper
  53945. * @param scene The scene the helper should be created in
  53946. */
  53947. private constructor();
  53948. /**
  53949. * Creates the experience helper
  53950. * @param scene the scene to attach the experience helper to
  53951. * @returns a promise for the experience helper
  53952. */
  53953. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53954. /**
  53955. * Disposes of the experience helper
  53956. */
  53957. dispose(): void;
  53958. /**
  53959. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53960. * @param sessionMode options for the XR session
  53961. * @param referenceSpaceType frame of reference of the XR session
  53962. * @param renderTarget the output canvas that will be used to enter XR mode
  53963. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53964. * @returns promise that resolves after xr mode has entered
  53965. */
  53966. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53967. /**
  53968. * Exits XR mode and returns the scene to its original state
  53969. * @returns promise that resolves after xr mode has exited
  53970. */
  53971. exitXRAsync(): Promise<void>;
  53972. private _nonXRToXRCamera;
  53973. private _setState;
  53974. }
  53975. }
  53976. declare module BABYLON {
  53977. /**
  53978. * X-Y values for axes in WebXR
  53979. */
  53980. export interface IWebXRMotionControllerAxesValue {
  53981. /**
  53982. * The value of the x axis
  53983. */
  53984. x: number;
  53985. /**
  53986. * The value of the y-axis
  53987. */
  53988. y: number;
  53989. }
  53990. /**
  53991. * changed / previous values for the values of this component
  53992. */
  53993. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53994. /**
  53995. * current (this frame) value
  53996. */
  53997. current: T;
  53998. /**
  53999. * previous (last change) value
  54000. */
  54001. previous: T;
  54002. }
  54003. /**
  54004. * Represents changes in the component between current frame and last values recorded
  54005. */
  54006. export interface IWebXRMotionControllerComponentChanges {
  54007. /**
  54008. * will be populated with previous and current values if axes changed
  54009. */
  54010. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54011. /**
  54012. * will be populated with previous and current values if pressed changed
  54013. */
  54014. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54015. /**
  54016. * will be populated with previous and current values if touched changed
  54017. */
  54018. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54019. /**
  54020. * will be populated with previous and current values if value changed
  54021. */
  54022. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54023. }
  54024. /**
  54025. * This class represents a single component (for example button or thumbstick) of a motion controller
  54026. */
  54027. export class WebXRControllerComponent implements IDisposable {
  54028. /**
  54029. * the id of this component
  54030. */
  54031. id: string;
  54032. /**
  54033. * the type of the component
  54034. */
  54035. type: MotionControllerComponentType;
  54036. private _buttonIndex;
  54037. private _axesIndices;
  54038. private _axes;
  54039. private _changes;
  54040. private _currentValue;
  54041. private _hasChanges;
  54042. private _pressed;
  54043. private _touched;
  54044. /**
  54045. * button component type
  54046. */
  54047. static BUTTON_TYPE: MotionControllerComponentType;
  54048. /**
  54049. * squeeze component type
  54050. */
  54051. static SQUEEZE_TYPE: MotionControllerComponentType;
  54052. /**
  54053. * Thumbstick component type
  54054. */
  54055. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54056. /**
  54057. * Touchpad component type
  54058. */
  54059. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54060. /**
  54061. * trigger component type
  54062. */
  54063. static TRIGGER_TYPE: MotionControllerComponentType;
  54064. /**
  54065. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54066. * the axes data changes
  54067. */
  54068. onAxisValueChangedObservable: Observable<{
  54069. x: number;
  54070. y: number;
  54071. }>;
  54072. /**
  54073. * Observers registered here will be triggered when the state of a button changes
  54074. * State change is either pressed / touched / value
  54075. */
  54076. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54077. /**
  54078. * Creates a new component for a motion controller.
  54079. * It is created by the motion controller itself
  54080. *
  54081. * @param id the id of this component
  54082. * @param type the type of the component
  54083. * @param _buttonIndex index in the buttons array of the gamepad
  54084. * @param _axesIndices indices of the values in the axes array of the gamepad
  54085. */
  54086. constructor(
  54087. /**
  54088. * the id of this component
  54089. */
  54090. id: string,
  54091. /**
  54092. * the type of the component
  54093. */
  54094. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54095. /**
  54096. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54097. */
  54098. get axes(): IWebXRMotionControllerAxesValue;
  54099. /**
  54100. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54101. */
  54102. get changes(): IWebXRMotionControllerComponentChanges;
  54103. /**
  54104. * Return whether or not the component changed the last frame
  54105. */
  54106. get hasChanges(): boolean;
  54107. /**
  54108. * is the button currently pressed
  54109. */
  54110. get pressed(): boolean;
  54111. /**
  54112. * is the button currently touched
  54113. */
  54114. get touched(): boolean;
  54115. /**
  54116. * Get the current value of this component
  54117. */
  54118. get value(): number;
  54119. /**
  54120. * Dispose this component
  54121. */
  54122. dispose(): void;
  54123. /**
  54124. * Are there axes correlating to this component
  54125. * @return true is axes data is available
  54126. */
  54127. isAxes(): boolean;
  54128. /**
  54129. * Is this component a button (hence - pressable)
  54130. * @returns true if can be pressed
  54131. */
  54132. isButton(): boolean;
  54133. /**
  54134. * update this component using the gamepad object it is in. Called on every frame
  54135. * @param nativeController the native gamepad controller object
  54136. */
  54137. update(nativeController: IMinimalMotionControllerObject): void;
  54138. }
  54139. }
  54140. declare module BABYLON {
  54141. /**
  54142. * Type used for the success callback of ImportMesh
  54143. */
  54144. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54145. /**
  54146. * Interface used for the result of ImportMeshAsync
  54147. */
  54148. export interface ISceneLoaderAsyncResult {
  54149. /**
  54150. * The array of loaded meshes
  54151. */
  54152. readonly meshes: AbstractMesh[];
  54153. /**
  54154. * The array of loaded particle systems
  54155. */
  54156. readonly particleSystems: IParticleSystem[];
  54157. /**
  54158. * The array of loaded skeletons
  54159. */
  54160. readonly skeletons: Skeleton[];
  54161. /**
  54162. * The array of loaded animation groups
  54163. */
  54164. readonly animationGroups: AnimationGroup[];
  54165. /**
  54166. * The array of loaded transform nodes
  54167. */
  54168. readonly transformNodes: TransformNode[];
  54169. /**
  54170. * The array of loaded geometries
  54171. */
  54172. readonly geometries: Geometry[];
  54173. /**
  54174. * The array of loaded lights
  54175. */
  54176. readonly lights: Light[];
  54177. }
  54178. /**
  54179. * Interface used to represent data loading progression
  54180. */
  54181. export interface ISceneLoaderProgressEvent {
  54182. /**
  54183. * Defines if data length to load can be evaluated
  54184. */
  54185. readonly lengthComputable: boolean;
  54186. /**
  54187. * Defines the loaded data length
  54188. */
  54189. readonly loaded: number;
  54190. /**
  54191. * Defines the data length to load
  54192. */
  54193. readonly total: number;
  54194. }
  54195. /**
  54196. * Interface used by SceneLoader plugins to define supported file extensions
  54197. */
  54198. export interface ISceneLoaderPluginExtensions {
  54199. /**
  54200. * Defines the list of supported extensions
  54201. */
  54202. [extension: string]: {
  54203. isBinary: boolean;
  54204. };
  54205. }
  54206. /**
  54207. * Interface used by SceneLoader plugin factory
  54208. */
  54209. export interface ISceneLoaderPluginFactory {
  54210. /**
  54211. * Defines the name of the factory
  54212. */
  54213. name: string;
  54214. /**
  54215. * Function called to create a new plugin
  54216. * @return the new plugin
  54217. */
  54218. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54219. /**
  54220. * The callback that returns true if the data can be directly loaded.
  54221. * @param data string containing the file data
  54222. * @returns if the data can be loaded directly
  54223. */
  54224. canDirectLoad?(data: string): boolean;
  54225. }
  54226. /**
  54227. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54228. */
  54229. export interface ISceneLoaderPluginBase {
  54230. /**
  54231. * The friendly name of this plugin.
  54232. */
  54233. name: string;
  54234. /**
  54235. * The file extensions supported by this plugin.
  54236. */
  54237. extensions: string | ISceneLoaderPluginExtensions;
  54238. /**
  54239. * The callback called when loading from a url.
  54240. * @param scene scene loading this url
  54241. * @param url url to load
  54242. * @param onSuccess callback called when the file successfully loads
  54243. * @param onProgress callback called while file is loading (if the server supports this mode)
  54244. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54245. * @param onError callback called when the file fails to load
  54246. * @returns a file request object
  54247. */
  54248. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54249. /**
  54250. * The callback called when loading from a file object.
  54251. * @param scene scene loading this file
  54252. * @param file defines the file to load
  54253. * @param onSuccess defines the callback to call when data is loaded
  54254. * @param onProgress defines the callback to call during loading process
  54255. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54256. * @param onError defines the callback to call when an error occurs
  54257. * @returns a file request object
  54258. */
  54259. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54260. /**
  54261. * The callback that returns true if the data can be directly loaded.
  54262. * @param data string containing the file data
  54263. * @returns if the data can be loaded directly
  54264. */
  54265. canDirectLoad?(data: string): boolean;
  54266. /**
  54267. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54268. * @param scene scene loading this data
  54269. * @param data string containing the data
  54270. * @returns data to pass to the plugin
  54271. */
  54272. directLoad?(scene: Scene, data: string): any;
  54273. /**
  54274. * The callback that allows custom handling of the root url based on the response url.
  54275. * @param rootUrl the original root url
  54276. * @param responseURL the response url if available
  54277. * @returns the new root url
  54278. */
  54279. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54280. }
  54281. /**
  54282. * Interface used to define a SceneLoader plugin
  54283. */
  54284. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54285. /**
  54286. * Import meshes into a scene.
  54287. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54288. * @param scene The scene to import into
  54289. * @param data The data to import
  54290. * @param rootUrl The root url for scene and resources
  54291. * @param meshes The meshes array to import into
  54292. * @param particleSystems The particle systems array to import into
  54293. * @param skeletons The skeletons array to import into
  54294. * @param onError The callback when import fails
  54295. * @returns True if successful or false otherwise
  54296. */
  54297. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54298. /**
  54299. * Load into a scene.
  54300. * @param scene The scene to load into
  54301. * @param data The data to import
  54302. * @param rootUrl The root url for scene and resources
  54303. * @param onError The callback when import fails
  54304. * @returns True if successful or false otherwise
  54305. */
  54306. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54307. /**
  54308. * Load into an asset container.
  54309. * @param scene The scene to load into
  54310. * @param data The data to import
  54311. * @param rootUrl The root url for scene and resources
  54312. * @param onError The callback when import fails
  54313. * @returns The loaded asset container
  54314. */
  54315. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54316. }
  54317. /**
  54318. * Interface used to define an async SceneLoader plugin
  54319. */
  54320. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54321. /**
  54322. * Import meshes into a scene.
  54323. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54324. * @param scene The scene to import into
  54325. * @param data The data to import
  54326. * @param rootUrl The root url for scene and resources
  54327. * @param onProgress The callback when the load progresses
  54328. * @param fileName Defines the name of the file to load
  54329. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54330. */
  54331. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54332. /**
  54333. * Load into a scene.
  54334. * @param scene The scene to load into
  54335. * @param data The data to import
  54336. * @param rootUrl The root url for scene and resources
  54337. * @param onProgress The callback when the load progresses
  54338. * @param fileName Defines the name of the file to load
  54339. * @returns Nothing
  54340. */
  54341. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54342. /**
  54343. * Load into an asset container.
  54344. * @param scene The scene to load into
  54345. * @param data The data to import
  54346. * @param rootUrl The root url for scene and resources
  54347. * @param onProgress The callback when the load progresses
  54348. * @param fileName Defines the name of the file to load
  54349. * @returns The loaded asset container
  54350. */
  54351. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54352. }
  54353. /**
  54354. * Mode that determines how to handle old animation groups before loading new ones.
  54355. */
  54356. export enum SceneLoaderAnimationGroupLoadingMode {
  54357. /**
  54358. * Reset all old animations to initial state then dispose them.
  54359. */
  54360. Clean = 0,
  54361. /**
  54362. * Stop all old animations.
  54363. */
  54364. Stop = 1,
  54365. /**
  54366. * Restart old animations from first frame.
  54367. */
  54368. Sync = 2,
  54369. /**
  54370. * Old animations remains untouched.
  54371. */
  54372. NoSync = 3
  54373. }
  54374. /**
  54375. * Defines a plugin registered by the SceneLoader
  54376. */
  54377. interface IRegisteredPlugin {
  54378. /**
  54379. * Defines the plugin to use
  54380. */
  54381. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54382. /**
  54383. * Defines if the plugin supports binary data
  54384. */
  54385. isBinary: boolean;
  54386. }
  54387. /**
  54388. * Class used to load scene from various file formats using registered plugins
  54389. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54390. */
  54391. export class SceneLoader {
  54392. /**
  54393. * No logging while loading
  54394. */
  54395. static readonly NO_LOGGING: number;
  54396. /**
  54397. * Minimal logging while loading
  54398. */
  54399. static readonly MINIMAL_LOGGING: number;
  54400. /**
  54401. * Summary logging while loading
  54402. */
  54403. static readonly SUMMARY_LOGGING: number;
  54404. /**
  54405. * Detailled logging while loading
  54406. */
  54407. static readonly DETAILED_LOGGING: number;
  54408. /**
  54409. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54410. */
  54411. static get ForceFullSceneLoadingForIncremental(): boolean;
  54412. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54413. /**
  54414. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54415. */
  54416. static get ShowLoadingScreen(): boolean;
  54417. static set ShowLoadingScreen(value: boolean);
  54418. /**
  54419. * Defines the current logging level (while loading the scene)
  54420. * @ignorenaming
  54421. */
  54422. static get loggingLevel(): number;
  54423. static set loggingLevel(value: number);
  54424. /**
  54425. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54426. */
  54427. static get CleanBoneMatrixWeights(): boolean;
  54428. static set CleanBoneMatrixWeights(value: boolean);
  54429. /**
  54430. * Event raised when a plugin is used to load a scene
  54431. */
  54432. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54433. private static _registeredPlugins;
  54434. private static _showingLoadingScreen;
  54435. /**
  54436. * Gets the default plugin (used to load Babylon files)
  54437. * @returns the .babylon plugin
  54438. */
  54439. static GetDefaultPlugin(): IRegisteredPlugin;
  54440. private static _GetPluginForExtension;
  54441. private static _GetPluginForDirectLoad;
  54442. private static _GetPluginForFilename;
  54443. private static _GetDirectLoad;
  54444. private static _LoadData;
  54445. private static _GetFileInfo;
  54446. /**
  54447. * Gets a plugin that can load the given extension
  54448. * @param extension defines the extension to load
  54449. * @returns a plugin or null if none works
  54450. */
  54451. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54452. /**
  54453. * Gets a boolean indicating that the given extension can be loaded
  54454. * @param extension defines the extension to load
  54455. * @returns true if the extension is supported
  54456. */
  54457. static IsPluginForExtensionAvailable(extension: string): boolean;
  54458. /**
  54459. * Adds a new plugin to the list of registered plugins
  54460. * @param plugin defines the plugin to add
  54461. */
  54462. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54463. /**
  54464. * Import meshes into a scene
  54465. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54466. * @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)
  54467. * @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)
  54468. * @param scene the instance of BABYLON.Scene to append to
  54469. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54470. * @param onProgress a callback with a progress event for each file being loaded
  54471. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54472. * @param pluginExtension the extension used to determine the plugin
  54473. * @returns The loaded plugin
  54474. */
  54475. 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>;
  54476. /**
  54477. * Import meshes into a scene
  54478. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54479. * @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)
  54480. * @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)
  54481. * @param scene the instance of BABYLON.Scene to append to
  54482. * @param onProgress a callback with a progress event for each file being loaded
  54483. * @param pluginExtension the extension used to determine the plugin
  54484. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54485. */
  54486. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54487. /**
  54488. * Load a scene
  54489. * @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)
  54490. * @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)
  54491. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54492. * @param onSuccess a callback with the scene when import succeeds
  54493. * @param onProgress a callback with a progress event for each file being loaded
  54494. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54495. * @param pluginExtension the extension used to determine the plugin
  54496. * @returns The loaded plugin
  54497. */
  54498. 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>;
  54499. /**
  54500. * Load a scene
  54501. * @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)
  54502. * @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)
  54503. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54504. * @param onProgress a callback with a progress event for each file being loaded
  54505. * @param pluginExtension the extension used to determine the plugin
  54506. * @returns The loaded scene
  54507. */
  54508. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54509. /**
  54510. * Append a scene
  54511. * @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)
  54512. * @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)
  54513. * @param scene is the instance of BABYLON.Scene to append to
  54514. * @param onSuccess a callback with the scene when import succeeds
  54515. * @param onProgress a callback with a progress event for each file being loaded
  54516. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54517. * @param pluginExtension the extension used to determine the plugin
  54518. * @returns The loaded plugin
  54519. */
  54520. 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>;
  54521. /**
  54522. * Append a scene
  54523. * @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)
  54524. * @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)
  54525. * @param scene is the instance of BABYLON.Scene to append to
  54526. * @param onProgress a callback with a progress event for each file being loaded
  54527. * @param pluginExtension the extension used to determine the plugin
  54528. * @returns The given scene
  54529. */
  54530. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54531. /**
  54532. * Load a scene into an asset container
  54533. * @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)
  54534. * @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)
  54535. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54536. * @param onSuccess a callback with the scene when import succeeds
  54537. * @param onProgress a callback with a progress event for each file being loaded
  54538. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54539. * @param pluginExtension the extension used to determine the plugin
  54540. * @returns The loaded plugin
  54541. */
  54542. 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>;
  54543. /**
  54544. * Load a scene into an asset container
  54545. * @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)
  54546. * @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)
  54547. * @param scene is the instance of Scene to append to
  54548. * @param onProgress a callback with a progress event for each file being loaded
  54549. * @param pluginExtension the extension used to determine the plugin
  54550. * @returns The loaded asset container
  54551. */
  54552. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54553. /**
  54554. * Import animations from a file into a scene
  54555. * @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)
  54556. * @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)
  54557. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54558. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54559. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54560. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54561. * @param onSuccess a callback with the scene when import succeeds
  54562. * @param onProgress a callback with a progress event for each file being loaded
  54563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54564. * @param pluginExtension the extension used to determine the plugin
  54565. */
  54566. 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;
  54567. /**
  54568. * Import animations from a file into a scene
  54569. * @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)
  54570. * @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)
  54571. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54572. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54573. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54574. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54575. * @param onSuccess a callback with the scene when import succeeds
  54576. * @param onProgress a callback with a progress event for each file being loaded
  54577. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54578. * @param pluginExtension the extension used to determine the plugin
  54579. * @returns the updated scene with imported animations
  54580. */
  54581. 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>;
  54582. }
  54583. }
  54584. declare module BABYLON {
  54585. /**
  54586. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54587. */
  54588. export type MotionControllerHandedness = "none" | "left" | "right";
  54589. /**
  54590. * The type of components available in motion controllers.
  54591. * This is not the name of the component.
  54592. */
  54593. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54594. /**
  54595. * The state of a controller component
  54596. */
  54597. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54598. /**
  54599. * The schema of motion controller layout.
  54600. * No object will be initialized using this interface
  54601. * This is used just to define the profile.
  54602. */
  54603. export interface IMotionControllerLayout {
  54604. /**
  54605. * Path to load the assets. Usually relative to the base path
  54606. */
  54607. assetPath: string;
  54608. /**
  54609. * Available components (unsorted)
  54610. */
  54611. components: {
  54612. /**
  54613. * A map of component Ids
  54614. */
  54615. [componentId: string]: {
  54616. /**
  54617. * The type of input the component outputs
  54618. */
  54619. type: MotionControllerComponentType;
  54620. /**
  54621. * The indices of this component in the gamepad object
  54622. */
  54623. gamepadIndices: {
  54624. /**
  54625. * Index of button
  54626. */
  54627. button?: number;
  54628. /**
  54629. * If available, index of x-axis
  54630. */
  54631. xAxis?: number;
  54632. /**
  54633. * If available, index of y-axis
  54634. */
  54635. yAxis?: number;
  54636. };
  54637. /**
  54638. * The mesh's root node name
  54639. */
  54640. rootNodeName: string;
  54641. /**
  54642. * Animation definitions for this model
  54643. */
  54644. visualResponses: {
  54645. [stateKey: string]: {
  54646. /**
  54647. * What property will be animated
  54648. */
  54649. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54650. /**
  54651. * What states influence this visual response
  54652. */
  54653. states: MotionControllerComponentStateType[];
  54654. /**
  54655. * Type of animation - movement or visibility
  54656. */
  54657. valueNodeProperty: "transform" | "visibility";
  54658. /**
  54659. * Base node name to move. Its position will be calculated according to the min and max nodes
  54660. */
  54661. valueNodeName?: string;
  54662. /**
  54663. * Minimum movement node
  54664. */
  54665. minNodeName?: string;
  54666. /**
  54667. * Max movement node
  54668. */
  54669. maxNodeName?: string;
  54670. };
  54671. };
  54672. /**
  54673. * If touch enabled, what is the name of node to display user feedback
  54674. */
  54675. touchPointNodeName?: string;
  54676. };
  54677. };
  54678. /**
  54679. * Is it xr standard mapping or not
  54680. */
  54681. gamepadMapping: "" | "xr-standard";
  54682. /**
  54683. * Base root node of this entire model
  54684. */
  54685. rootNodeName: string;
  54686. /**
  54687. * Defines the main button component id
  54688. */
  54689. selectComponentId: string;
  54690. }
  54691. /**
  54692. * A definition for the layout map in the input profile
  54693. */
  54694. export interface IMotionControllerLayoutMap {
  54695. /**
  54696. * Layouts with handedness type as a key
  54697. */
  54698. [handedness: string]: IMotionControllerLayout;
  54699. }
  54700. /**
  54701. * The XR Input profile schema
  54702. * Profiles can be found here:
  54703. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54704. */
  54705. export interface IMotionControllerProfile {
  54706. /**
  54707. * fallback profiles for this profileId
  54708. */
  54709. fallbackProfileIds: string[];
  54710. /**
  54711. * The layout map, with handedness as key
  54712. */
  54713. layouts: IMotionControllerLayoutMap;
  54714. /**
  54715. * The id of this profile
  54716. * correlates to the profile(s) in the xrInput.profiles array
  54717. */
  54718. profileId: string;
  54719. }
  54720. /**
  54721. * A helper-interface for the 3 meshes needed for controller button animation
  54722. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54723. */
  54724. export interface IMotionControllerButtonMeshMap {
  54725. /**
  54726. * the mesh that defines the pressed value mesh position.
  54727. * This is used to find the max-position of this button
  54728. */
  54729. pressedMesh: AbstractMesh;
  54730. /**
  54731. * the mesh that defines the unpressed value mesh position.
  54732. * This is used to find the min (or initial) position of this button
  54733. */
  54734. unpressedMesh: AbstractMesh;
  54735. /**
  54736. * The mesh that will be changed when value changes
  54737. */
  54738. valueMesh: AbstractMesh;
  54739. }
  54740. /**
  54741. * A helper-interface for the 3 meshes needed for controller axis animation.
  54742. * This will be expanded when touchpad animations are fully supported
  54743. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54744. */
  54745. export interface IMotionControllerMeshMap {
  54746. /**
  54747. * the mesh that defines the maximum value mesh position.
  54748. */
  54749. maxMesh?: AbstractMesh;
  54750. /**
  54751. * the mesh that defines the minimum value mesh position.
  54752. */
  54753. minMesh?: AbstractMesh;
  54754. /**
  54755. * The mesh that will be changed when axis value changes
  54756. */
  54757. valueMesh?: AbstractMesh;
  54758. }
  54759. /**
  54760. * The elements needed for change-detection of the gamepad objects in motion controllers
  54761. */
  54762. export interface IMinimalMotionControllerObject {
  54763. /**
  54764. * Available axes of this controller
  54765. */
  54766. axes: number[];
  54767. /**
  54768. * An array of available buttons
  54769. */
  54770. buttons: Array<{
  54771. /**
  54772. * Value of the button/trigger
  54773. */
  54774. value: number;
  54775. /**
  54776. * If the button/trigger is currently touched
  54777. */
  54778. touched: boolean;
  54779. /**
  54780. * If the button/trigger is currently pressed
  54781. */
  54782. pressed: boolean;
  54783. }>;
  54784. /**
  54785. * EXPERIMENTAL haptic support.
  54786. */
  54787. hapticActuators?: Array<{
  54788. pulse: (value: number, duration: number) => Promise<boolean>;
  54789. }>;
  54790. }
  54791. /**
  54792. * An Abstract Motion controller
  54793. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54794. * Each component has an observable to check for changes in value and state
  54795. */
  54796. export abstract class WebXRAbstractMotionController implements IDisposable {
  54797. protected scene: Scene;
  54798. protected layout: IMotionControllerLayout;
  54799. /**
  54800. * The gamepad object correlating to this controller
  54801. */
  54802. gamepadObject: IMinimalMotionControllerObject;
  54803. /**
  54804. * handedness (left/right/none) of this controller
  54805. */
  54806. handedness: MotionControllerHandedness;
  54807. private _initComponent;
  54808. private _modelReady;
  54809. /**
  54810. * A map of components (WebXRControllerComponent) in this motion controller
  54811. * Components have a ComponentType and can also have both button and axis definitions
  54812. */
  54813. readonly components: {
  54814. [id: string]: WebXRControllerComponent;
  54815. };
  54816. /**
  54817. * Disable the model's animation. Can be set at any time.
  54818. */
  54819. disableAnimation: boolean;
  54820. /**
  54821. * Observers registered here will be triggered when the model of this controller is done loading
  54822. */
  54823. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54824. /**
  54825. * The profile id of this motion controller
  54826. */
  54827. abstract profileId: string;
  54828. /**
  54829. * The root mesh of the model. It is null if the model was not yet initialized
  54830. */
  54831. rootMesh: Nullable<AbstractMesh>;
  54832. /**
  54833. * constructs a new abstract motion controller
  54834. * @param scene the scene to which the model of the controller will be added
  54835. * @param layout The profile layout to load
  54836. * @param gamepadObject The gamepad object correlating to this controller
  54837. * @param handedness handedness (left/right/none) of this controller
  54838. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54839. */
  54840. constructor(scene: Scene, layout: IMotionControllerLayout,
  54841. /**
  54842. * The gamepad object correlating to this controller
  54843. */
  54844. gamepadObject: IMinimalMotionControllerObject,
  54845. /**
  54846. * handedness (left/right/none) of this controller
  54847. */
  54848. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54849. /**
  54850. * Dispose this controller, the model mesh and all its components
  54851. */
  54852. dispose(): void;
  54853. /**
  54854. * Returns all components of specific type
  54855. * @param type the type to search for
  54856. * @return an array of components with this type
  54857. */
  54858. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54859. /**
  54860. * get a component based an its component id as defined in layout.components
  54861. * @param id the id of the component
  54862. * @returns the component correlates to the id or undefined if not found
  54863. */
  54864. getComponent(id: string): WebXRControllerComponent;
  54865. /**
  54866. * Get the list of components available in this motion controller
  54867. * @returns an array of strings correlating to available components
  54868. */
  54869. getComponentIds(): string[];
  54870. /**
  54871. * Get the first component of specific type
  54872. * @param type type of component to find
  54873. * @return a controller component or null if not found
  54874. */
  54875. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54876. /**
  54877. * Get the main (Select) component of this controller as defined in the layout
  54878. * @returns the main component of this controller
  54879. */
  54880. getMainComponent(): WebXRControllerComponent;
  54881. /**
  54882. * Loads the model correlating to this controller
  54883. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54884. * @returns A promise fulfilled with the result of the model loading
  54885. */
  54886. loadModel(): Promise<boolean>;
  54887. /**
  54888. * Update this model using the current XRFrame
  54889. * @param xrFrame the current xr frame to use and update the model
  54890. */
  54891. updateFromXRFrame(xrFrame: XRFrame): void;
  54892. /**
  54893. * Backwards compatibility due to a deeply-integrated typo
  54894. */
  54895. get handness(): XREye;
  54896. /**
  54897. * Pulse (vibrate) this controller
  54898. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54899. * Consecutive calls to this function will cancel the last pulse call
  54900. *
  54901. * @param value the strength of the pulse in 0.0...1.0 range
  54902. * @param duration Duration of the pulse in milliseconds
  54903. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54904. * @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
  54905. */
  54906. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54907. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54908. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54909. /**
  54910. * Moves the axis on the controller mesh based on its current state
  54911. * @param axis the index of the axis
  54912. * @param axisValue the value of the axis which determines the meshes new position
  54913. * @hidden
  54914. */
  54915. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54916. /**
  54917. * Update the model itself with the current frame data
  54918. * @param xrFrame the frame to use for updating the model mesh
  54919. */
  54920. protected updateModel(xrFrame: XRFrame): void;
  54921. /**
  54922. * Get the filename and path for this controller's model
  54923. * @returns a map of filename and path
  54924. */
  54925. protected abstract _getFilenameAndPath(): {
  54926. filename: string;
  54927. path: string;
  54928. };
  54929. /**
  54930. * This function is called before the mesh is loaded. It checks for loading constraints.
  54931. * For example, this function can check if the GLB loader is available
  54932. * If this function returns false, the generic controller will be loaded instead
  54933. * @returns Is the client ready to load the mesh
  54934. */
  54935. protected abstract _getModelLoadingConstraints(): boolean;
  54936. /**
  54937. * This function will be called after the model was successfully loaded and can be used
  54938. * for mesh transformations before it is available for the user
  54939. * @param meshes the loaded meshes
  54940. */
  54941. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54942. /**
  54943. * Set the root mesh for this controller. Important for the WebXR controller class
  54944. * @param meshes the loaded meshes
  54945. */
  54946. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54947. /**
  54948. * A function executed each frame that updates the mesh (if needed)
  54949. * @param xrFrame the current xrFrame
  54950. */
  54951. protected abstract _updateModel(xrFrame: XRFrame): void;
  54952. private _getGenericFilenameAndPath;
  54953. private _getGenericParentMesh;
  54954. }
  54955. }
  54956. declare module BABYLON {
  54957. /**
  54958. * A generic trigger-only motion controller for WebXR
  54959. */
  54960. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54961. /**
  54962. * Static version of the profile id of this controller
  54963. */
  54964. static ProfileId: string;
  54965. profileId: string;
  54966. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54967. protected _getFilenameAndPath(): {
  54968. filename: string;
  54969. path: string;
  54970. };
  54971. protected _getModelLoadingConstraints(): boolean;
  54972. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54973. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54974. protected _updateModel(): void;
  54975. }
  54976. }
  54977. declare module BABYLON {
  54978. /**
  54979. * Class containing static functions to help procedurally build meshes
  54980. */
  54981. export class SphereBuilder {
  54982. /**
  54983. * Creates a sphere mesh
  54984. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54985. * * 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`)
  54986. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54987. * * 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
  54988. * * 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)
  54989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54990. * * 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
  54991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54992. * @param name defines the name of the mesh
  54993. * @param options defines the options used to create the mesh
  54994. * @param scene defines the hosting scene
  54995. * @returns the sphere mesh
  54996. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54997. */
  54998. static CreateSphere(name: string, options: {
  54999. segments?: number;
  55000. diameter?: number;
  55001. diameterX?: number;
  55002. diameterY?: number;
  55003. diameterZ?: number;
  55004. arc?: number;
  55005. slice?: number;
  55006. sideOrientation?: number;
  55007. frontUVs?: Vector4;
  55008. backUVs?: Vector4;
  55009. updatable?: boolean;
  55010. }, scene?: Nullable<Scene>): Mesh;
  55011. }
  55012. }
  55013. declare module BABYLON {
  55014. /**
  55015. * A profiled motion controller has its profile loaded from an online repository.
  55016. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55017. */
  55018. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55019. private _repositoryUrl;
  55020. private _buttonMeshMapping;
  55021. private _touchDots;
  55022. /**
  55023. * The profile ID of this controller. Will be populated when the controller initializes.
  55024. */
  55025. profileId: string;
  55026. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55027. dispose(): void;
  55028. protected _getFilenameAndPath(): {
  55029. filename: string;
  55030. path: string;
  55031. };
  55032. protected _getModelLoadingConstraints(): boolean;
  55033. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55034. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55035. protected _updateModel(_xrFrame: XRFrame): void;
  55036. }
  55037. }
  55038. declare module BABYLON {
  55039. /**
  55040. * A construction function type to create a new controller based on an xrInput object
  55041. */
  55042. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55043. /**
  55044. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55045. *
  55046. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55047. * it should be replaced with auto-loaded controllers.
  55048. *
  55049. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55050. */
  55051. export class WebXRMotionControllerManager {
  55052. private static _AvailableControllers;
  55053. private static _Fallbacks;
  55054. private static _ProfileLoadingPromises;
  55055. private static _ProfilesList;
  55056. /**
  55057. * The base URL of the online controller repository. Can be changed at any time.
  55058. */
  55059. static BaseRepositoryUrl: string;
  55060. /**
  55061. * Which repository gets priority - local or online
  55062. */
  55063. static PrioritizeOnlineRepository: boolean;
  55064. /**
  55065. * Use the online repository, or use only locally-defined controllers
  55066. */
  55067. static UseOnlineRepository: boolean;
  55068. /**
  55069. * Clear the cache used for profile loading and reload when requested again
  55070. */
  55071. static ClearProfilesCache(): void;
  55072. /**
  55073. * Register the default fallbacks.
  55074. * This function is called automatically when this file is imported.
  55075. */
  55076. static DefaultFallbacks(): void;
  55077. /**
  55078. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55079. * @param profileId the profile to which a fallback needs to be found
  55080. * @return an array with corresponding fallback profiles
  55081. */
  55082. static FindFallbackWithProfileId(profileId: string): string[];
  55083. /**
  55084. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55085. * The order of search:
  55086. *
  55087. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55088. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55089. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55090. * 4) return the generic trigger controller if none were found
  55091. *
  55092. * @param xrInput the xrInput to which a new controller is initialized
  55093. * @param scene the scene to which the model will be added
  55094. * @param forceProfile force a certain profile for this controller
  55095. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55096. */
  55097. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55098. /**
  55099. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55100. *
  55101. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55102. *
  55103. * @param type the profile type to register
  55104. * @param constructFunction the function to be called when loading this profile
  55105. */
  55106. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55107. /**
  55108. * Register a fallback to a specific profile.
  55109. * @param profileId the profileId that will receive the fallbacks
  55110. * @param fallbacks A list of fallback profiles
  55111. */
  55112. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55113. /**
  55114. * Will update the list of profiles available in the repository
  55115. * @return a promise that resolves to a map of profiles available online
  55116. */
  55117. static UpdateProfilesList(): Promise<{
  55118. [profile: string]: string;
  55119. }>;
  55120. private static _LoadProfileFromRepository;
  55121. private static _LoadProfilesFromAvailableControllers;
  55122. }
  55123. }
  55124. declare module BABYLON {
  55125. /**
  55126. * Configuration options for the WebXR controller creation
  55127. */
  55128. export interface IWebXRControllerOptions {
  55129. /**
  55130. * Should the controller mesh be animated when a user interacts with it
  55131. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55132. */
  55133. disableMotionControllerAnimation?: boolean;
  55134. /**
  55135. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55136. */
  55137. doNotLoadControllerMesh?: boolean;
  55138. /**
  55139. * Force a specific controller type for this controller.
  55140. * This can be used when creating your own profile or when testing different controllers
  55141. */
  55142. forceControllerProfile?: string;
  55143. /**
  55144. * Defines a rendering group ID for meshes that will be loaded.
  55145. * This is for the default controllers only.
  55146. */
  55147. renderingGroupId?: number;
  55148. }
  55149. /**
  55150. * Represents an XR controller
  55151. */
  55152. export class WebXRInputSource {
  55153. private _scene;
  55154. /** The underlying input source for the controller */
  55155. inputSource: XRInputSource;
  55156. private _options;
  55157. private _tmpVector;
  55158. private _uniqueId;
  55159. private _disposed;
  55160. /**
  55161. * 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
  55162. */
  55163. grip?: AbstractMesh;
  55164. /**
  55165. * If available, this is the gamepad object related to this controller.
  55166. * Using this object it is possible to get click events and trackpad changes of the
  55167. * webxr controller that is currently being used.
  55168. */
  55169. motionController?: WebXRAbstractMotionController;
  55170. /**
  55171. * Event that fires when the controller is removed/disposed.
  55172. * The object provided as event data is this controller, after associated assets were disposed.
  55173. * uniqueId is still available.
  55174. */
  55175. onDisposeObservable: Observable<WebXRInputSource>;
  55176. /**
  55177. * Will be triggered when the mesh associated with the motion controller is done loading.
  55178. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55179. * A shortened version of controller -> motion controller -> on mesh loaded.
  55180. */
  55181. onMeshLoadedObservable: Observable<AbstractMesh>;
  55182. /**
  55183. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55184. */
  55185. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55186. /**
  55187. * Pointer which can be used to select objects or attach a visible laser to
  55188. */
  55189. pointer: AbstractMesh;
  55190. /**
  55191. * Creates the input source object
  55192. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55193. * @param _scene the scene which the controller should be associated to
  55194. * @param inputSource the underlying input source for the controller
  55195. * @param _options options for this controller creation
  55196. */
  55197. constructor(_scene: Scene,
  55198. /** The underlying input source for the controller */
  55199. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55200. /**
  55201. * Get this controllers unique id
  55202. */
  55203. get uniqueId(): string;
  55204. /**
  55205. * Disposes of the object
  55206. */
  55207. dispose(): void;
  55208. /**
  55209. * Gets a world space ray coming from the pointer or grip
  55210. * @param result the resulting ray
  55211. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55212. */
  55213. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55214. /**
  55215. * Updates the controller pose based on the given XRFrame
  55216. * @param xrFrame xr frame to update the pose with
  55217. * @param referenceSpace reference space to use
  55218. */
  55219. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55220. }
  55221. }
  55222. declare module BABYLON {
  55223. /**
  55224. * The schema for initialization options of the XR Input class
  55225. */
  55226. export interface IWebXRInputOptions {
  55227. /**
  55228. * If set to true no model will be automatically loaded
  55229. */
  55230. doNotLoadControllerMeshes?: boolean;
  55231. /**
  55232. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55233. * If not found, the xr input profile data will be used.
  55234. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55235. */
  55236. forceInputProfile?: string;
  55237. /**
  55238. * Do not send a request to the controller repository to load the profile.
  55239. *
  55240. * Instead, use the controllers available in babylon itself.
  55241. */
  55242. disableOnlineControllerRepository?: boolean;
  55243. /**
  55244. * A custom URL for the controllers repository
  55245. */
  55246. customControllersRepositoryURL?: string;
  55247. /**
  55248. * Should the controller model's components not move according to the user input
  55249. */
  55250. disableControllerAnimation?: boolean;
  55251. /**
  55252. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55253. */
  55254. controllerOptions?: IWebXRControllerOptions;
  55255. }
  55256. /**
  55257. * XR input used to track XR inputs such as controllers/rays
  55258. */
  55259. export class WebXRInput implements IDisposable {
  55260. /**
  55261. * the xr session manager for this session
  55262. */
  55263. xrSessionManager: WebXRSessionManager;
  55264. /**
  55265. * the WebXR camera for this session. Mainly used for teleportation
  55266. */
  55267. xrCamera: WebXRCamera;
  55268. private readonly options;
  55269. /**
  55270. * XR controllers being tracked
  55271. */
  55272. controllers: Array<WebXRInputSource>;
  55273. private _frameObserver;
  55274. private _sessionEndedObserver;
  55275. private _sessionInitObserver;
  55276. /**
  55277. * Event when a controller has been connected/added
  55278. */
  55279. onControllerAddedObservable: Observable<WebXRInputSource>;
  55280. /**
  55281. * Event when a controller has been removed/disconnected
  55282. */
  55283. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55284. /**
  55285. * Initializes the WebXRInput
  55286. * @param xrSessionManager the xr session manager for this session
  55287. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55288. * @param options = initialization options for this xr input
  55289. */
  55290. constructor(
  55291. /**
  55292. * the xr session manager for this session
  55293. */
  55294. xrSessionManager: WebXRSessionManager,
  55295. /**
  55296. * the WebXR camera for this session. Mainly used for teleportation
  55297. */
  55298. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55299. private _onInputSourcesChange;
  55300. private _addAndRemoveControllers;
  55301. /**
  55302. * Disposes of the object
  55303. */
  55304. dispose(): void;
  55305. }
  55306. }
  55307. declare module BABYLON {
  55308. /**
  55309. * This is the base class for all WebXR features.
  55310. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55311. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55312. */
  55313. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55314. protected _xrSessionManager: WebXRSessionManager;
  55315. private _attached;
  55316. private _removeOnDetach;
  55317. /**
  55318. * Is this feature disposed?
  55319. */
  55320. isDisposed: boolean;
  55321. /**
  55322. * Should auto-attach be disabled?
  55323. */
  55324. disableAutoAttach: boolean;
  55325. /**
  55326. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55327. */
  55328. xrNativeFeatureName: string;
  55329. /**
  55330. * Construct a new (abstract) WebXR feature
  55331. * @param _xrSessionManager the xr session manager for this feature
  55332. */
  55333. constructor(_xrSessionManager: WebXRSessionManager);
  55334. /**
  55335. * Is this feature attached
  55336. */
  55337. get attached(): boolean;
  55338. /**
  55339. * attach this feature
  55340. *
  55341. * @param force should attachment be forced (even when already attached)
  55342. * @returns true if successful, false is failed or already attached
  55343. */
  55344. attach(force?: boolean): boolean;
  55345. /**
  55346. * detach this feature.
  55347. *
  55348. * @returns true if successful, false if failed or already detached
  55349. */
  55350. detach(): boolean;
  55351. /**
  55352. * Dispose this feature and all of the resources attached
  55353. */
  55354. dispose(): void;
  55355. /**
  55356. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55357. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55358. *
  55359. * @returns whether or not the feature is compatible in this environment
  55360. */
  55361. isCompatible(): boolean;
  55362. /**
  55363. * This is used to register callbacks that will automatically be removed when detach is called.
  55364. * @param observable the observable to which the observer will be attached
  55365. * @param callback the callback to register
  55366. */
  55367. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55368. /**
  55369. * Code in this function will be executed on each xrFrame received from the browser.
  55370. * This function will not execute after the feature is detached.
  55371. * @param _xrFrame the current frame
  55372. */
  55373. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55374. }
  55375. }
  55376. declare module BABYLON {
  55377. /**
  55378. * Renders a layer on top of an existing scene
  55379. */
  55380. export class UtilityLayerRenderer implements IDisposable {
  55381. /** the original scene that will be rendered on top of */
  55382. originalScene: Scene;
  55383. private _pointerCaptures;
  55384. private _lastPointerEvents;
  55385. private static _DefaultUtilityLayer;
  55386. private static _DefaultKeepDepthUtilityLayer;
  55387. private _sharedGizmoLight;
  55388. private _renderCamera;
  55389. /**
  55390. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55391. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55392. * @returns the camera that is used when rendering the utility layer
  55393. */
  55394. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55395. /**
  55396. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55397. * @param cam the camera that should be used when rendering the utility layer
  55398. */
  55399. setRenderCamera(cam: Nullable<Camera>): void;
  55400. /**
  55401. * @hidden
  55402. * Light which used by gizmos to get light shading
  55403. */
  55404. _getSharedGizmoLight(): HemisphericLight;
  55405. /**
  55406. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55407. */
  55408. pickUtilitySceneFirst: boolean;
  55409. /**
  55410. * 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)
  55411. */
  55412. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55413. /**
  55414. * 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)
  55415. */
  55416. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55417. /**
  55418. * The scene that is rendered on top of the original scene
  55419. */
  55420. utilityLayerScene: Scene;
  55421. /**
  55422. * If the utility layer should automatically be rendered on top of existing scene
  55423. */
  55424. shouldRender: boolean;
  55425. /**
  55426. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55427. */
  55428. onlyCheckPointerDownEvents: boolean;
  55429. /**
  55430. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55431. */
  55432. processAllEvents: boolean;
  55433. /**
  55434. * Observable raised when the pointer move from the utility layer scene to the main scene
  55435. */
  55436. onPointerOutObservable: Observable<number>;
  55437. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55438. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55439. private _afterRenderObserver;
  55440. private _sceneDisposeObserver;
  55441. private _originalPointerObserver;
  55442. /**
  55443. * Instantiates a UtilityLayerRenderer
  55444. * @param originalScene the original scene that will be rendered on top of
  55445. * @param handleEvents boolean indicating if the utility layer should handle events
  55446. */
  55447. constructor(
  55448. /** the original scene that will be rendered on top of */
  55449. originalScene: Scene, handleEvents?: boolean);
  55450. private _notifyObservers;
  55451. /**
  55452. * Renders the utility layers scene on top of the original scene
  55453. */
  55454. render(): void;
  55455. /**
  55456. * Disposes of the renderer
  55457. */
  55458. dispose(): void;
  55459. private _updateCamera;
  55460. }
  55461. }
  55462. declare module BABYLON {
  55463. /**
  55464. * Options interface for the pointer selection module
  55465. */
  55466. export interface IWebXRControllerPointerSelectionOptions {
  55467. /**
  55468. * if provided, this scene will be used to render meshes.
  55469. */
  55470. customUtilityLayerScene?: Scene;
  55471. /**
  55472. * 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)
  55473. * If not disabled, the last picked point will be used to execute a pointer up event
  55474. * If disabled, pointer up event will be triggered right after the pointer down event.
  55475. * Used in screen and gaze target ray mode only
  55476. */
  55477. disablePointerUpOnTouchOut: boolean;
  55478. /**
  55479. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55480. */
  55481. forceGazeMode: boolean;
  55482. /**
  55483. * 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
  55484. * to start a new countdown to the pointer down event.
  55485. * Defaults to 1.
  55486. */
  55487. gazeModePointerMovedFactor?: number;
  55488. /**
  55489. * Different button type to use instead of the main component
  55490. */
  55491. overrideButtonId?: string;
  55492. /**
  55493. * use this rendering group id for the meshes (optional)
  55494. */
  55495. renderingGroupId?: number;
  55496. /**
  55497. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55498. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55499. * 3000 means 3 seconds between pointing at something and selecting it
  55500. */
  55501. timeToSelect?: number;
  55502. /**
  55503. * Should meshes created here be added to a utility layer or the main scene
  55504. */
  55505. useUtilityLayer?: boolean;
  55506. /**
  55507. * Optional WebXR camera to be used for gaze selection
  55508. */
  55509. gazeCamera?: WebXRCamera;
  55510. /**
  55511. * the xr input to use with this pointer selection
  55512. */
  55513. xrInput: WebXRInput;
  55514. /**
  55515. * Should the scene pointerX and pointerY update be disabled
  55516. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55517. * Disable in VR, if not needed.
  55518. * The first rig camera (left eye) will be used to calculate the projection
  55519. */
  55520. disableScenePointerVectorUpdate: boolean;
  55521. /**
  55522. * Enable pointer selection on all controllers instead of switching between them
  55523. */
  55524. enablePointerSelectionOnAllControllers?: boolean;
  55525. /**
  55526. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55527. * If switch is enabled, it will still allow the user to switch between the different controllers
  55528. */
  55529. preferredHandedness?: XRHandedness;
  55530. /**
  55531. * Disable switching the pointer selection from one controller to the other.
  55532. * 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
  55533. */
  55534. disableSwitchOnClick?: boolean;
  55535. /**
  55536. * The maximum distance of the pointer selection feature. Defaults to 100.
  55537. */
  55538. maxPointerDistance?: number;
  55539. }
  55540. /**
  55541. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55542. */
  55543. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55544. private readonly _options;
  55545. private static _idCounter;
  55546. private _attachController;
  55547. private _controllers;
  55548. private _scene;
  55549. private _tmpVectorForPickCompare;
  55550. private _attachedController;
  55551. /**
  55552. * The module's name
  55553. */
  55554. static readonly Name: string;
  55555. /**
  55556. * The (Babylon) version of this module.
  55557. * This is an integer representing the implementation version.
  55558. * This number does not correspond to the WebXR specs version
  55559. */
  55560. static readonly Version: number;
  55561. /**
  55562. * Disable lighting on the laser pointer (so it will always be visible)
  55563. */
  55564. disablePointerLighting: boolean;
  55565. /**
  55566. * Disable lighting on the selection mesh (so it will always be visible)
  55567. */
  55568. disableSelectionMeshLighting: boolean;
  55569. /**
  55570. * Should the laser pointer be displayed
  55571. */
  55572. displayLaserPointer: boolean;
  55573. /**
  55574. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55575. */
  55576. displaySelectionMesh: boolean;
  55577. /**
  55578. * This color will be set to the laser pointer when selection is triggered
  55579. */
  55580. laserPointerPickedColor: Color3;
  55581. /**
  55582. * Default color of the laser pointer
  55583. */
  55584. laserPointerDefaultColor: Color3;
  55585. /**
  55586. * default color of the selection ring
  55587. */
  55588. selectionMeshDefaultColor: Color3;
  55589. /**
  55590. * This color will be applied to the selection ring when selection is triggered
  55591. */
  55592. selectionMeshPickedColor: Color3;
  55593. /**
  55594. * Optional filter to be used for ray selection. This predicate shares behavior with
  55595. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55596. */
  55597. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55598. /**
  55599. * constructs a new background remover module
  55600. * @param _xrSessionManager the session manager for this module
  55601. * @param _options read-only options to be used in this module
  55602. */
  55603. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55604. /**
  55605. * attach this feature
  55606. * Will usually be called by the features manager
  55607. *
  55608. * @returns true if successful.
  55609. */
  55610. attach(): boolean;
  55611. /**
  55612. * detach this feature.
  55613. * Will usually be called by the features manager
  55614. *
  55615. * @returns true if successful.
  55616. */
  55617. detach(): boolean;
  55618. /**
  55619. * Will get the mesh under a specific pointer.
  55620. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55621. * @param controllerId the controllerId to check
  55622. * @returns The mesh under pointer or null if no mesh is under the pointer
  55623. */
  55624. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55625. /**
  55626. * Get the xr controller that correlates to the pointer id in the pointer event
  55627. *
  55628. * @param id the pointer id to search for
  55629. * @returns the controller that correlates to this id or null if not found
  55630. */
  55631. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55632. private _identityMatrix;
  55633. private _screenCoordinatesRef;
  55634. private _viewportRef;
  55635. protected _onXRFrame(_xrFrame: XRFrame): void;
  55636. private _attachGazeMode;
  55637. private _attachScreenRayMode;
  55638. private _attachTrackedPointerRayMode;
  55639. private _convertNormalToDirectionOfRay;
  55640. private _detachController;
  55641. private _generateNewMeshPair;
  55642. private _pickingMoved;
  55643. private _updatePointerDistance;
  55644. /** @hidden */
  55645. get lasterPointerDefaultColor(): Color3;
  55646. }
  55647. }
  55648. declare module BABYLON {
  55649. /**
  55650. * Button which can be used to enter a different mode of XR
  55651. */
  55652. export class WebXREnterExitUIButton {
  55653. /** button element */
  55654. element: HTMLElement;
  55655. /** XR initialization options for the button */
  55656. sessionMode: XRSessionMode;
  55657. /** Reference space type */
  55658. referenceSpaceType: XRReferenceSpaceType;
  55659. /**
  55660. * Creates a WebXREnterExitUIButton
  55661. * @param element button element
  55662. * @param sessionMode XR initialization session mode
  55663. * @param referenceSpaceType the type of reference space to be used
  55664. */
  55665. constructor(
  55666. /** button element */
  55667. element: HTMLElement,
  55668. /** XR initialization options for the button */
  55669. sessionMode: XRSessionMode,
  55670. /** Reference space type */
  55671. referenceSpaceType: XRReferenceSpaceType);
  55672. /**
  55673. * Extendable function which can be used to update the button's visuals when the state changes
  55674. * @param activeButton the current active button in the UI
  55675. */
  55676. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55677. }
  55678. /**
  55679. * Options to create the webXR UI
  55680. */
  55681. export class WebXREnterExitUIOptions {
  55682. /**
  55683. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55684. */
  55685. customButtons?: Array<WebXREnterExitUIButton>;
  55686. /**
  55687. * A reference space type to use when creating the default button.
  55688. * Default is local-floor
  55689. */
  55690. referenceSpaceType?: XRReferenceSpaceType;
  55691. /**
  55692. * Context to enter xr with
  55693. */
  55694. renderTarget?: Nullable<WebXRRenderTarget>;
  55695. /**
  55696. * A session mode to use when creating the default button.
  55697. * Default is immersive-vr
  55698. */
  55699. sessionMode?: XRSessionMode;
  55700. /**
  55701. * A list of optional features to init the session with
  55702. */
  55703. optionalFeatures?: string[];
  55704. /**
  55705. * A list of optional features to init the session with
  55706. */
  55707. requiredFeatures?: string[];
  55708. /**
  55709. * If defined, this function will be executed if the UI encounters an error when entering XR
  55710. */
  55711. onError?: (error: any) => void;
  55712. }
  55713. /**
  55714. * UI to allow the user to enter/exit XR mode
  55715. */
  55716. export class WebXREnterExitUI implements IDisposable {
  55717. private scene;
  55718. /** version of the options passed to this UI */
  55719. options: WebXREnterExitUIOptions;
  55720. private _activeButton;
  55721. private _buttons;
  55722. /**
  55723. * The HTML Div Element to which buttons are added.
  55724. */
  55725. readonly overlay: HTMLDivElement;
  55726. /**
  55727. * Fired every time the active button is changed.
  55728. *
  55729. * When xr is entered via a button that launches xr that button will be the callback parameter
  55730. *
  55731. * When exiting xr the callback parameter will be null)
  55732. */
  55733. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55734. /**
  55735. *
  55736. * @param scene babylon scene object to use
  55737. * @param options (read-only) version of the options passed to this UI
  55738. */
  55739. private constructor();
  55740. /**
  55741. * Creates UI to allow the user to enter/exit XR mode
  55742. * @param scene the scene to add the ui to
  55743. * @param helper the xr experience helper to enter/exit xr with
  55744. * @param options options to configure the UI
  55745. * @returns the created ui
  55746. */
  55747. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55748. /**
  55749. * Disposes of the XR UI component
  55750. */
  55751. dispose(): void;
  55752. private _updateButtons;
  55753. }
  55754. }
  55755. declare module BABYLON {
  55756. /**
  55757. * Class containing static functions to help procedurally build meshes
  55758. */
  55759. export class LinesBuilder {
  55760. /**
  55761. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55762. * * 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
  55763. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55764. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55765. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55766. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55767. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55768. * * 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
  55769. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55772. * @param name defines the name of the new line system
  55773. * @param options defines the options used to create the line system
  55774. * @param scene defines the hosting scene
  55775. * @returns a new line system mesh
  55776. */
  55777. static CreateLineSystem(name: string, options: {
  55778. lines: Vector3[][];
  55779. updatable?: boolean;
  55780. instance?: Nullable<LinesMesh>;
  55781. colors?: Nullable<Color4[][]>;
  55782. useVertexAlpha?: boolean;
  55783. }, scene: Nullable<Scene>): LinesMesh;
  55784. /**
  55785. * Creates a line mesh
  55786. * 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
  55787. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55788. * * The parameter `points` is an array successive Vector3
  55789. * * 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
  55790. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55791. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55792. * * When updating an instance, remember that only point positions can change, not the number of points
  55793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55795. * @param name defines the name of the new line system
  55796. * @param options defines the options used to create the line system
  55797. * @param scene defines the hosting scene
  55798. * @returns a new line mesh
  55799. */
  55800. static CreateLines(name: string, options: {
  55801. points: Vector3[];
  55802. updatable?: boolean;
  55803. instance?: Nullable<LinesMesh>;
  55804. colors?: Color4[];
  55805. useVertexAlpha?: boolean;
  55806. }, scene?: Nullable<Scene>): LinesMesh;
  55807. /**
  55808. * Creates a dashed line mesh
  55809. * * 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
  55810. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55811. * * The parameter `points` is an array successive Vector3
  55812. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55813. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55814. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55815. * * 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
  55816. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55817. * * When updating an instance, remember that only point positions can change, not the number of points
  55818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55819. * @param name defines the name of the mesh
  55820. * @param options defines the options used to create the mesh
  55821. * @param scene defines the hosting scene
  55822. * @returns the dashed line mesh
  55823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55824. */
  55825. static CreateDashedLines(name: string, options: {
  55826. points: Vector3[];
  55827. dashSize?: number;
  55828. gapSize?: number;
  55829. dashNb?: number;
  55830. updatable?: boolean;
  55831. instance?: LinesMesh;
  55832. useVertexAlpha?: boolean;
  55833. }, scene?: Nullable<Scene>): LinesMesh;
  55834. }
  55835. }
  55836. declare module BABYLON {
  55837. /**
  55838. * Construction options for a timer
  55839. */
  55840. export interface ITimerOptions<T> {
  55841. /**
  55842. * Time-to-end
  55843. */
  55844. timeout: number;
  55845. /**
  55846. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55847. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55848. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55849. */
  55850. contextObservable: Observable<T>;
  55851. /**
  55852. * Optional parameters when adding an observer to the observable
  55853. */
  55854. observableParameters?: {
  55855. mask?: number;
  55856. insertFirst?: boolean;
  55857. scope?: any;
  55858. };
  55859. /**
  55860. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55861. */
  55862. breakCondition?: (data?: ITimerData<T>) => boolean;
  55863. /**
  55864. * Will be triggered when the time condition has met
  55865. */
  55866. onEnded?: (data: ITimerData<any>) => void;
  55867. /**
  55868. * Will be triggered when the break condition has met (prematurely ended)
  55869. */
  55870. onAborted?: (data: ITimerData<any>) => void;
  55871. /**
  55872. * Optional function to execute on each tick (or count)
  55873. */
  55874. onTick?: (data: ITimerData<any>) => void;
  55875. }
  55876. /**
  55877. * An interface defining the data sent by the timer
  55878. */
  55879. export interface ITimerData<T> {
  55880. /**
  55881. * When did it start
  55882. */
  55883. startTime: number;
  55884. /**
  55885. * Time now
  55886. */
  55887. currentTime: number;
  55888. /**
  55889. * Time passed since started
  55890. */
  55891. deltaTime: number;
  55892. /**
  55893. * How much is completed, in [0.0...1.0].
  55894. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55895. */
  55896. completeRate: number;
  55897. /**
  55898. * What the registered observable sent in the last count
  55899. */
  55900. payload: T;
  55901. }
  55902. /**
  55903. * The current state of the timer
  55904. */
  55905. export enum TimerState {
  55906. /**
  55907. * Timer initialized, not yet started
  55908. */
  55909. INIT = 0,
  55910. /**
  55911. * Timer started and counting
  55912. */
  55913. STARTED = 1,
  55914. /**
  55915. * Timer ended (whether aborted or time reached)
  55916. */
  55917. ENDED = 2
  55918. }
  55919. /**
  55920. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55921. *
  55922. * @param options options with which to initialize this timer
  55923. */
  55924. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55925. /**
  55926. * An advanced implementation of a timer class
  55927. */
  55928. export class AdvancedTimer<T = any> implements IDisposable {
  55929. /**
  55930. * Will notify each time the timer calculates the remaining time
  55931. */
  55932. onEachCountObservable: Observable<ITimerData<T>>;
  55933. /**
  55934. * Will trigger when the timer was aborted due to the break condition
  55935. */
  55936. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55937. /**
  55938. * Will trigger when the timer ended successfully
  55939. */
  55940. onTimerEndedObservable: Observable<ITimerData<T>>;
  55941. /**
  55942. * Will trigger when the timer state has changed
  55943. */
  55944. onStateChangedObservable: Observable<TimerState>;
  55945. private _observer;
  55946. private _contextObservable;
  55947. private _observableParameters;
  55948. private _startTime;
  55949. private _timer;
  55950. private _state;
  55951. private _breakCondition;
  55952. private _timeToEnd;
  55953. private _breakOnNextTick;
  55954. /**
  55955. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55956. * @param options construction options for this advanced timer
  55957. */
  55958. constructor(options: ITimerOptions<T>);
  55959. /**
  55960. * set a breaking condition for this timer. Default is to never break during count
  55961. * @param predicate the new break condition. Returns true to break, false otherwise
  55962. */
  55963. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55964. /**
  55965. * Reset ALL associated observables in this advanced timer
  55966. */
  55967. clearObservables(): void;
  55968. /**
  55969. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55970. *
  55971. * @param timeToEnd how much time to measure until timer ended
  55972. */
  55973. start(timeToEnd?: number): void;
  55974. /**
  55975. * Will force a stop on the next tick.
  55976. */
  55977. stop(): void;
  55978. /**
  55979. * Dispose this timer, clearing all resources
  55980. */
  55981. dispose(): void;
  55982. private _setState;
  55983. private _tick;
  55984. private _stop;
  55985. }
  55986. }
  55987. declare module BABYLON {
  55988. /**
  55989. * The options container for the teleportation module
  55990. */
  55991. export interface IWebXRTeleportationOptions {
  55992. /**
  55993. * if provided, this scene will be used to render meshes.
  55994. */
  55995. customUtilityLayerScene?: Scene;
  55996. /**
  55997. * Values to configure the default target mesh
  55998. */
  55999. defaultTargetMeshOptions?: {
  56000. /**
  56001. * Fill color of the teleportation area
  56002. */
  56003. teleportationFillColor?: string;
  56004. /**
  56005. * Border color for the teleportation area
  56006. */
  56007. teleportationBorderColor?: string;
  56008. /**
  56009. * Disable the mesh's animation sequence
  56010. */
  56011. disableAnimation?: boolean;
  56012. /**
  56013. * Disable lighting on the material or the ring and arrow
  56014. */
  56015. disableLighting?: boolean;
  56016. /**
  56017. * Override the default material of the torus and arrow
  56018. */
  56019. torusArrowMaterial?: Material;
  56020. };
  56021. /**
  56022. * A list of meshes to use as floor meshes.
  56023. * Meshes can be added and removed after initializing the feature using the
  56024. * addFloorMesh and removeFloorMesh functions
  56025. * If empty, rotation will still work
  56026. */
  56027. floorMeshes?: AbstractMesh[];
  56028. /**
  56029. * use this rendering group id for the meshes (optional)
  56030. */
  56031. renderingGroupId?: number;
  56032. /**
  56033. * Should teleportation move only to snap points
  56034. */
  56035. snapPointsOnly?: boolean;
  56036. /**
  56037. * An array of points to which the teleportation will snap to.
  56038. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56039. */
  56040. snapPositions?: Vector3[];
  56041. /**
  56042. * How close should the teleportation ray be in order to snap to position.
  56043. * Default to 0.8 units (meters)
  56044. */
  56045. snapToPositionRadius?: number;
  56046. /**
  56047. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56048. * If you want to support rotation, make sure your mesh has a direction indicator.
  56049. *
  56050. * When left untouched, the default mesh will be initialized.
  56051. */
  56052. teleportationTargetMesh?: AbstractMesh;
  56053. /**
  56054. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56055. */
  56056. timeToTeleport?: number;
  56057. /**
  56058. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56059. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56060. */
  56061. useMainComponentOnly?: boolean;
  56062. /**
  56063. * Should meshes created here be added to a utility layer or the main scene
  56064. */
  56065. useUtilityLayer?: boolean;
  56066. /**
  56067. * Babylon XR Input class for controller
  56068. */
  56069. xrInput: WebXRInput;
  56070. /**
  56071. * Meshes that the teleportation ray cannot go through
  56072. */
  56073. pickBlockerMeshes?: AbstractMesh[];
  56074. /**
  56075. * Should teleport work only on a specific hand?
  56076. */
  56077. forceHandedness?: XRHandedness;
  56078. /**
  56079. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56080. */
  56081. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56082. }
  56083. /**
  56084. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56085. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56086. * the input of the attached controllers.
  56087. */
  56088. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56089. private _options;
  56090. private _controllers;
  56091. private _currentTeleportationControllerId;
  56092. private _floorMeshes;
  56093. private _quadraticBezierCurve;
  56094. private _selectionFeature;
  56095. private _snapToPositions;
  56096. private _snappedToPoint;
  56097. private _teleportationRingMaterial?;
  56098. private _tmpRay;
  56099. private _tmpVector;
  56100. private _tmpQuaternion;
  56101. /**
  56102. * The module's name
  56103. */
  56104. static readonly Name: string;
  56105. /**
  56106. * The (Babylon) version of this module.
  56107. * This is an integer representing the implementation version.
  56108. * This number does not correspond to the webxr specs version
  56109. */
  56110. static readonly Version: number;
  56111. /**
  56112. * Is movement backwards enabled
  56113. */
  56114. backwardsMovementEnabled: boolean;
  56115. /**
  56116. * Distance to travel when moving backwards
  56117. */
  56118. backwardsTeleportationDistance: number;
  56119. /**
  56120. * The distance from the user to the inspection point in the direction of the controller
  56121. * A higher number will allow the user to move further
  56122. * defaults to 5 (meters, in xr units)
  56123. */
  56124. parabolicCheckRadius: number;
  56125. /**
  56126. * Should the module support parabolic ray on top of direct ray
  56127. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56128. * Very helpful when moving between floors / different heights
  56129. */
  56130. parabolicRayEnabled: boolean;
  56131. /**
  56132. * The second type of ray - straight line.
  56133. * Should it be enabled or should the parabolic line be the only one.
  56134. */
  56135. straightRayEnabled: boolean;
  56136. /**
  56137. * How much rotation should be applied when rotating right and left
  56138. */
  56139. rotationAngle: number;
  56140. private _rotationEnabled;
  56141. /**
  56142. * Is rotation enabled when moving forward?
  56143. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56144. */
  56145. get rotationEnabled(): boolean;
  56146. /**
  56147. * Sets wether rotation is enabled or not
  56148. * @param enabled is rotation enabled when teleportation is shown
  56149. */
  56150. set rotationEnabled(enabled: boolean);
  56151. /**
  56152. * Exposes the currently set teleportation target mesh.
  56153. */
  56154. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56155. /**
  56156. * constructs a new anchor system
  56157. * @param _xrSessionManager an instance of WebXRSessionManager
  56158. * @param _options configuration object for this feature
  56159. */
  56160. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56161. /**
  56162. * Get the snapPointsOnly flag
  56163. */
  56164. get snapPointsOnly(): boolean;
  56165. /**
  56166. * Sets the snapPointsOnly flag
  56167. * @param snapToPoints should teleportation be exclusively to snap points
  56168. */
  56169. set snapPointsOnly(snapToPoints: boolean);
  56170. /**
  56171. * Add a new mesh to the floor meshes array
  56172. * @param mesh the mesh to use as floor mesh
  56173. */
  56174. addFloorMesh(mesh: AbstractMesh): void;
  56175. /**
  56176. * Add a new snap-to point to fix teleportation to this position
  56177. * @param newSnapPoint The new Snap-To point
  56178. */
  56179. addSnapPoint(newSnapPoint: Vector3): void;
  56180. attach(): boolean;
  56181. detach(): boolean;
  56182. dispose(): void;
  56183. /**
  56184. * Remove a mesh from the floor meshes array
  56185. * @param mesh the mesh to remove
  56186. */
  56187. removeFloorMesh(mesh: AbstractMesh): void;
  56188. /**
  56189. * Remove a mesh from the floor meshes array using its name
  56190. * @param name the mesh name to remove
  56191. */
  56192. removeFloorMeshByName(name: string): void;
  56193. /**
  56194. * 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
  56195. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56196. * @returns was the point found and removed or not
  56197. */
  56198. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56199. /**
  56200. * This function sets a selection feature that will be disabled when
  56201. * the forward ray is shown and will be reattached when hidden.
  56202. * This is used to remove the selection rays when moving.
  56203. * @param selectionFeature the feature to disable when forward movement is enabled
  56204. */
  56205. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56206. protected _onXRFrame(_xrFrame: XRFrame): void;
  56207. private _attachController;
  56208. private _createDefaultTargetMesh;
  56209. private _detachController;
  56210. private _findClosestSnapPointWithRadius;
  56211. private _setTargetMeshPosition;
  56212. private _setTargetMeshVisibility;
  56213. private _showParabolicPath;
  56214. private _teleportForward;
  56215. }
  56216. }
  56217. declare module BABYLON {
  56218. /**
  56219. * Options for the default xr helper
  56220. */
  56221. export class WebXRDefaultExperienceOptions {
  56222. /**
  56223. * Enable or disable default UI to enter XR
  56224. */
  56225. disableDefaultUI?: boolean;
  56226. /**
  56227. * Should teleportation not initialize. defaults to false.
  56228. */
  56229. disableTeleportation?: boolean;
  56230. /**
  56231. * Floor meshes that will be used for teleport
  56232. */
  56233. floorMeshes?: Array<AbstractMesh>;
  56234. /**
  56235. * If set to true, the first frame will not be used to reset position
  56236. * The first frame is mainly used when copying transformation from the old camera
  56237. * Mainly used in AR
  56238. */
  56239. ignoreNativeCameraTransformation?: boolean;
  56240. /**
  56241. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56242. */
  56243. inputOptions?: IWebXRInputOptions;
  56244. /**
  56245. * optional configuration for the output canvas
  56246. */
  56247. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56248. /**
  56249. * optional UI options. This can be used among other to change session mode and reference space type
  56250. */
  56251. uiOptions?: WebXREnterExitUIOptions;
  56252. /**
  56253. * When loading teleportation and pointer select, use stable versions instead of latest.
  56254. */
  56255. useStablePlugins?: boolean;
  56256. /**
  56257. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56258. */
  56259. renderingGroupId?: number;
  56260. /**
  56261. * A list of optional features to init the session with
  56262. * If set to true, all features we support will be added
  56263. */
  56264. optionalFeatures?: boolean | string[];
  56265. }
  56266. /**
  56267. * Default experience which provides a similar setup to the previous webVRExperience
  56268. */
  56269. export class WebXRDefaultExperience {
  56270. /**
  56271. * Base experience
  56272. */
  56273. baseExperience: WebXRExperienceHelper;
  56274. /**
  56275. * Enables ui for entering/exiting xr
  56276. */
  56277. enterExitUI: WebXREnterExitUI;
  56278. /**
  56279. * Input experience extension
  56280. */
  56281. input: WebXRInput;
  56282. /**
  56283. * Enables laser pointer and selection
  56284. */
  56285. pointerSelection: WebXRControllerPointerSelection;
  56286. /**
  56287. * Default target xr should render to
  56288. */
  56289. renderTarget: WebXRRenderTarget;
  56290. /**
  56291. * Enables teleportation
  56292. */
  56293. teleportation: WebXRMotionControllerTeleportation;
  56294. private constructor();
  56295. /**
  56296. * Creates the default xr experience
  56297. * @param scene scene
  56298. * @param options options for basic configuration
  56299. * @returns resulting WebXRDefaultExperience
  56300. */
  56301. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56302. /**
  56303. * DIsposes of the experience helper
  56304. */
  56305. dispose(): void;
  56306. }
  56307. }
  56308. declare module BABYLON {
  56309. /**
  56310. * Options to modify the vr teleportation behavior.
  56311. */
  56312. export interface VRTeleportationOptions {
  56313. /**
  56314. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56315. */
  56316. floorMeshName?: string;
  56317. /**
  56318. * A list of meshes to be used as the teleportation floor. (default: empty)
  56319. */
  56320. floorMeshes?: Mesh[];
  56321. /**
  56322. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56323. */
  56324. teleportationMode?: number;
  56325. /**
  56326. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56327. */
  56328. teleportationTime?: number;
  56329. /**
  56330. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56331. */
  56332. teleportationSpeed?: number;
  56333. /**
  56334. * The easing function used in the animation or null for Linear. (default CircleEase)
  56335. */
  56336. easingFunction?: EasingFunction;
  56337. }
  56338. /**
  56339. * Options to modify the vr experience helper's behavior.
  56340. */
  56341. export interface VRExperienceHelperOptions extends WebVROptions {
  56342. /**
  56343. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56344. */
  56345. createDeviceOrientationCamera?: boolean;
  56346. /**
  56347. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56348. */
  56349. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56350. /**
  56351. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56352. */
  56353. laserToggle?: boolean;
  56354. /**
  56355. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56356. */
  56357. floorMeshes?: Mesh[];
  56358. /**
  56359. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56360. */
  56361. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56362. /**
  56363. * Defines if WebXR should be used instead of WebVR (if available)
  56364. */
  56365. useXR?: boolean;
  56366. }
  56367. /**
  56368. * Event containing information after VR has been entered
  56369. */
  56370. export class OnAfterEnteringVRObservableEvent {
  56371. /**
  56372. * If entering vr was successful
  56373. */
  56374. success: boolean;
  56375. }
  56376. /**
  56377. * Helps to quickly add VR support to an existing scene.
  56378. * See https://doc.babylonjs.com/how_to/webvr_helper
  56379. */
  56380. export class VRExperienceHelper {
  56381. /** Options to modify the vr experience helper's behavior. */
  56382. webVROptions: VRExperienceHelperOptions;
  56383. private _scene;
  56384. private _position;
  56385. private _btnVR;
  56386. private _btnVRDisplayed;
  56387. private _webVRsupported;
  56388. private _webVRready;
  56389. private _webVRrequesting;
  56390. private _webVRpresenting;
  56391. private _hasEnteredVR;
  56392. private _fullscreenVRpresenting;
  56393. private _inputElement;
  56394. private _webVRCamera;
  56395. private _vrDeviceOrientationCamera;
  56396. private _deviceOrientationCamera;
  56397. private _existingCamera;
  56398. private _onKeyDown;
  56399. private _onVrDisplayPresentChange;
  56400. private _onVRDisplayChanged;
  56401. private _onVRRequestPresentStart;
  56402. private _onVRRequestPresentComplete;
  56403. /**
  56404. * 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)
  56405. */
  56406. enableGazeEvenWhenNoPointerLock: boolean;
  56407. /**
  56408. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56409. */
  56410. exitVROnDoubleTap: boolean;
  56411. /**
  56412. * Observable raised right before entering VR.
  56413. */
  56414. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56415. /**
  56416. * Observable raised when entering VR has completed.
  56417. */
  56418. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56419. /**
  56420. * Observable raised when exiting VR.
  56421. */
  56422. onExitingVRObservable: Observable<VRExperienceHelper>;
  56423. /**
  56424. * Observable raised when controller mesh is loaded.
  56425. */
  56426. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56427. /** Return this.onEnteringVRObservable
  56428. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56429. */
  56430. get onEnteringVR(): Observable<VRExperienceHelper>;
  56431. /** Return this.onExitingVRObservable
  56432. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56433. */
  56434. get onExitingVR(): Observable<VRExperienceHelper>;
  56435. /** Return this.onControllerMeshLoadedObservable
  56436. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56437. */
  56438. get onControllerMeshLoaded(): Observable<WebVRController>;
  56439. private _rayLength;
  56440. private _useCustomVRButton;
  56441. private _teleportationRequested;
  56442. private _teleportActive;
  56443. private _floorMeshName;
  56444. private _floorMeshesCollection;
  56445. private _teleportationMode;
  56446. private _teleportationTime;
  56447. private _teleportationSpeed;
  56448. private _teleportationEasing;
  56449. private _rotationAllowed;
  56450. private _teleportBackwardsVector;
  56451. private _teleportationTarget;
  56452. private _isDefaultTeleportationTarget;
  56453. private _postProcessMove;
  56454. private _teleportationFillColor;
  56455. private _teleportationBorderColor;
  56456. private _rotationAngle;
  56457. private _haloCenter;
  56458. private _cameraGazer;
  56459. private _padSensibilityUp;
  56460. private _padSensibilityDown;
  56461. private _leftController;
  56462. private _rightController;
  56463. private _gazeColor;
  56464. private _laserColor;
  56465. private _pickedLaserColor;
  56466. private _pickedGazeColor;
  56467. /**
  56468. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56469. */
  56470. onNewMeshSelected: Observable<AbstractMesh>;
  56471. /**
  56472. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56473. * This observable will provide the mesh and the controller used to select the mesh
  56474. */
  56475. onMeshSelectedWithController: Observable<{
  56476. mesh: AbstractMesh;
  56477. controller: WebVRController;
  56478. }>;
  56479. /**
  56480. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56481. */
  56482. onNewMeshPicked: Observable<PickingInfo>;
  56483. private _circleEase;
  56484. /**
  56485. * Observable raised before camera teleportation
  56486. */
  56487. onBeforeCameraTeleport: Observable<Vector3>;
  56488. /**
  56489. * Observable raised after camera teleportation
  56490. */
  56491. onAfterCameraTeleport: Observable<Vector3>;
  56492. /**
  56493. * Observable raised when current selected mesh gets unselected
  56494. */
  56495. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56496. private _raySelectionPredicate;
  56497. /**
  56498. * To be optionaly changed by user to define custom ray selection
  56499. */
  56500. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56501. /**
  56502. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56503. */
  56504. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56505. /**
  56506. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56507. */
  56508. teleportationEnabled: boolean;
  56509. private _defaultHeight;
  56510. private _teleportationInitialized;
  56511. private _interactionsEnabled;
  56512. private _interactionsRequested;
  56513. private _displayGaze;
  56514. private _displayLaserPointer;
  56515. /**
  56516. * The mesh used to display where the user is going to teleport.
  56517. */
  56518. get teleportationTarget(): Mesh;
  56519. /**
  56520. * Sets the mesh to be used to display where the user is going to teleport.
  56521. */
  56522. set teleportationTarget(value: Mesh);
  56523. /**
  56524. * 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
  56525. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56526. * See https://doc.babylonjs.com/resources/baking_transformations
  56527. */
  56528. get gazeTrackerMesh(): Mesh;
  56529. set gazeTrackerMesh(value: Mesh);
  56530. /**
  56531. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56532. */
  56533. updateGazeTrackerScale: boolean;
  56534. /**
  56535. * If the gaze trackers color should be updated when selecting meshes
  56536. */
  56537. updateGazeTrackerColor: boolean;
  56538. /**
  56539. * If the controller laser color should be updated when selecting meshes
  56540. */
  56541. updateControllerLaserColor: boolean;
  56542. /**
  56543. * The gaze tracking mesh corresponding to the left controller
  56544. */
  56545. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56546. /**
  56547. * The gaze tracking mesh corresponding to the right controller
  56548. */
  56549. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56550. /**
  56551. * If the ray of the gaze should be displayed.
  56552. */
  56553. get displayGaze(): boolean;
  56554. /**
  56555. * Sets if the ray of the gaze should be displayed.
  56556. */
  56557. set displayGaze(value: boolean);
  56558. /**
  56559. * If the ray of the LaserPointer should be displayed.
  56560. */
  56561. get displayLaserPointer(): boolean;
  56562. /**
  56563. * Sets if the ray of the LaserPointer should be displayed.
  56564. */
  56565. set displayLaserPointer(value: boolean);
  56566. /**
  56567. * The deviceOrientationCamera used as the camera when not in VR.
  56568. */
  56569. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56570. /**
  56571. * Based on the current WebVR support, returns the current VR camera used.
  56572. */
  56573. get currentVRCamera(): Nullable<Camera>;
  56574. /**
  56575. * The webVRCamera which is used when in VR.
  56576. */
  56577. get webVRCamera(): WebVRFreeCamera;
  56578. /**
  56579. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56580. */
  56581. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56582. /**
  56583. * The html button that is used to trigger entering into VR.
  56584. */
  56585. get vrButton(): Nullable<HTMLButtonElement>;
  56586. private get _teleportationRequestInitiated();
  56587. /**
  56588. * Defines whether or not Pointer lock should be requested when switching to
  56589. * full screen.
  56590. */
  56591. requestPointerLockOnFullScreen: boolean;
  56592. /**
  56593. * If asking to force XR, this will be populated with the default xr experience
  56594. */
  56595. xr: WebXRDefaultExperience;
  56596. /**
  56597. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56598. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56599. */
  56600. xrTestDone: boolean;
  56601. /**
  56602. * Instantiates a VRExperienceHelper.
  56603. * Helps to quickly add VR support to an existing scene.
  56604. * @param scene The scene the VRExperienceHelper belongs to.
  56605. * @param webVROptions Options to modify the vr experience helper's behavior.
  56606. */
  56607. constructor(scene: Scene,
  56608. /** Options to modify the vr experience helper's behavior. */
  56609. webVROptions?: VRExperienceHelperOptions);
  56610. private completeVRInit;
  56611. private _onDefaultMeshLoaded;
  56612. private _onResize;
  56613. private _onFullscreenChange;
  56614. /**
  56615. * Gets a value indicating if we are currently in VR mode.
  56616. */
  56617. get isInVRMode(): boolean;
  56618. private onVrDisplayPresentChange;
  56619. private onVRDisplayChanged;
  56620. private moveButtonToBottomRight;
  56621. private displayVRButton;
  56622. private updateButtonVisibility;
  56623. private _cachedAngularSensibility;
  56624. /**
  56625. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56626. * Otherwise, will use the fullscreen API.
  56627. */
  56628. enterVR(): void;
  56629. /**
  56630. * Attempt to exit VR, or fullscreen.
  56631. */
  56632. exitVR(): void;
  56633. /**
  56634. * The position of the vr experience helper.
  56635. */
  56636. get position(): Vector3;
  56637. /**
  56638. * Sets the position of the vr experience helper.
  56639. */
  56640. set position(value: Vector3);
  56641. /**
  56642. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56643. */
  56644. enableInteractions(): void;
  56645. private get _noControllerIsActive();
  56646. private beforeRender;
  56647. private _isTeleportationFloor;
  56648. /**
  56649. * Adds a floor mesh to be used for teleportation.
  56650. * @param floorMesh the mesh to be used for teleportation.
  56651. */
  56652. addFloorMesh(floorMesh: Mesh): void;
  56653. /**
  56654. * Removes a floor mesh from being used for teleportation.
  56655. * @param floorMesh the mesh to be removed.
  56656. */
  56657. removeFloorMesh(floorMesh: Mesh): void;
  56658. /**
  56659. * Enables interactions and teleportation using the VR controllers and gaze.
  56660. * @param vrTeleportationOptions options to modify teleportation behavior.
  56661. */
  56662. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56663. private _onNewGamepadConnected;
  56664. private _tryEnableInteractionOnController;
  56665. private _onNewGamepadDisconnected;
  56666. private _enableInteractionOnController;
  56667. private _checkTeleportWithRay;
  56668. private _checkRotate;
  56669. private _checkTeleportBackwards;
  56670. private _enableTeleportationOnController;
  56671. private _createTeleportationCircles;
  56672. private _displayTeleportationTarget;
  56673. private _hideTeleportationTarget;
  56674. private _rotateCamera;
  56675. private _moveTeleportationSelectorTo;
  56676. private _workingVector;
  56677. private _workingQuaternion;
  56678. private _workingMatrix;
  56679. /**
  56680. * Time Constant Teleportation Mode
  56681. */
  56682. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56683. /**
  56684. * Speed Constant Teleportation Mode
  56685. */
  56686. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56687. /**
  56688. * Teleports the users feet to the desired location
  56689. * @param location The location where the user's feet should be placed
  56690. */
  56691. teleportCamera(location: Vector3): void;
  56692. private _convertNormalToDirectionOfRay;
  56693. private _castRayAndSelectObject;
  56694. private _notifySelectedMeshUnselected;
  56695. /**
  56696. * Permanently set new colors for the laser pointer
  56697. * @param color the new laser color
  56698. * @param pickedColor the new laser color when picked mesh detected
  56699. */
  56700. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56701. /**
  56702. * Set lighting enabled / disabled on the laser pointer of both controllers
  56703. * @param enabled should the lighting be enabled on the laser pointer
  56704. */
  56705. setLaserLightingState(enabled?: boolean): void;
  56706. /**
  56707. * Permanently set new colors for the gaze pointer
  56708. * @param color the new gaze color
  56709. * @param pickedColor the new gaze color when picked mesh detected
  56710. */
  56711. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56712. /**
  56713. * Sets the color of the laser ray from the vr controllers.
  56714. * @param color new color for the ray.
  56715. */
  56716. changeLaserColor(color: Color3): void;
  56717. /**
  56718. * Sets the color of the ray from the vr headsets gaze.
  56719. * @param color new color for the ray.
  56720. */
  56721. changeGazeColor(color: Color3): void;
  56722. /**
  56723. * Exits VR and disposes of the vr experience helper
  56724. */
  56725. dispose(): void;
  56726. /**
  56727. * Gets the name of the VRExperienceHelper class
  56728. * @returns "VRExperienceHelper"
  56729. */
  56730. getClassName(): string;
  56731. }
  56732. }
  56733. declare module BABYLON {
  56734. /**
  56735. * Contains an array of blocks representing the octree
  56736. */
  56737. export interface IOctreeContainer<T> {
  56738. /**
  56739. * Blocks within the octree
  56740. */
  56741. blocks: Array<OctreeBlock<T>>;
  56742. }
  56743. /**
  56744. * Class used to store a cell in an octree
  56745. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56746. */
  56747. export class OctreeBlock<T> {
  56748. /**
  56749. * Gets the content of the current block
  56750. */
  56751. entries: T[];
  56752. /**
  56753. * Gets the list of block children
  56754. */
  56755. blocks: Array<OctreeBlock<T>>;
  56756. private _depth;
  56757. private _maxDepth;
  56758. private _capacity;
  56759. private _minPoint;
  56760. private _maxPoint;
  56761. private _boundingVectors;
  56762. private _creationFunc;
  56763. /**
  56764. * Creates a new block
  56765. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56766. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56767. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56768. * @param depth defines the current depth of this block in the octree
  56769. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56770. * @param creationFunc defines a callback to call when an element is added to the block
  56771. */
  56772. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56773. /**
  56774. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56775. */
  56776. get capacity(): number;
  56777. /**
  56778. * Gets the minimum vector (in world space) of the block's bounding box
  56779. */
  56780. get minPoint(): Vector3;
  56781. /**
  56782. * Gets the maximum vector (in world space) of the block's bounding box
  56783. */
  56784. get maxPoint(): Vector3;
  56785. /**
  56786. * Add a new element to this block
  56787. * @param entry defines the element to add
  56788. */
  56789. addEntry(entry: T): void;
  56790. /**
  56791. * Remove an element from this block
  56792. * @param entry defines the element to remove
  56793. */
  56794. removeEntry(entry: T): void;
  56795. /**
  56796. * Add an array of elements to this block
  56797. * @param entries defines the array of elements to add
  56798. */
  56799. addEntries(entries: T[]): void;
  56800. /**
  56801. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56802. * @param frustumPlanes defines the frustum planes to test
  56803. * @param selection defines the array to store current content if selection is positive
  56804. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56805. */
  56806. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56807. /**
  56808. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56809. * @param sphereCenter defines the bounding sphere center
  56810. * @param sphereRadius defines the bounding sphere radius
  56811. * @param selection defines the array to store current content if selection is positive
  56812. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56813. */
  56814. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56815. /**
  56816. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56817. * @param ray defines the ray to test with
  56818. * @param selection defines the array to store current content if selection is positive
  56819. */
  56820. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56821. /**
  56822. * Subdivide the content into child blocks (this block will then be empty)
  56823. */
  56824. createInnerBlocks(): void;
  56825. /**
  56826. * @hidden
  56827. */
  56828. 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;
  56829. }
  56830. }
  56831. declare module BABYLON {
  56832. /**
  56833. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56835. */
  56836. export class Octree<T> {
  56837. /** 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.) */
  56838. maxDepth: number;
  56839. /**
  56840. * Blocks within the octree containing objects
  56841. */
  56842. blocks: Array<OctreeBlock<T>>;
  56843. /**
  56844. * Content stored in the octree
  56845. */
  56846. dynamicContent: T[];
  56847. private _maxBlockCapacity;
  56848. private _selectionContent;
  56849. private _creationFunc;
  56850. /**
  56851. * Creates a octree
  56852. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56853. * @param creationFunc function to be used to instatiate the octree
  56854. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56855. * @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.)
  56856. */
  56857. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56858. /** 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.) */
  56859. maxDepth?: number);
  56860. /**
  56861. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56862. * @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);
  56863. * @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);
  56864. * @param entries meshes to be added to the octree blocks
  56865. */
  56866. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56867. /**
  56868. * Adds a mesh to the octree
  56869. * @param entry Mesh to add to the octree
  56870. */
  56871. addMesh(entry: T): void;
  56872. /**
  56873. * Remove an element from the octree
  56874. * @param entry defines the element to remove
  56875. */
  56876. removeMesh(entry: T): void;
  56877. /**
  56878. * Selects an array of meshes within the frustum
  56879. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56880. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56881. * @returns array of meshes within the frustum
  56882. */
  56883. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56884. /**
  56885. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56886. * @param sphereCenter defines the bounding sphere center
  56887. * @param sphereRadius defines the bounding sphere radius
  56888. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56889. * @returns an array of objects that intersect the sphere
  56890. */
  56891. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56892. /**
  56893. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56894. * @param ray defines the ray to test with
  56895. * @returns array of intersected objects
  56896. */
  56897. intersectsRay(ray: Ray): SmartArray<T>;
  56898. /**
  56899. * Adds a mesh into the octree block if it intersects the block
  56900. */
  56901. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56902. /**
  56903. * Adds a submesh into the octree block if it intersects the block
  56904. */
  56905. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56906. }
  56907. }
  56908. declare module BABYLON {
  56909. interface Scene {
  56910. /**
  56911. * @hidden
  56912. * Backing Filed
  56913. */
  56914. _selectionOctree: Octree<AbstractMesh>;
  56915. /**
  56916. * Gets the octree used to boost mesh selection (picking)
  56917. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56918. */
  56919. selectionOctree: Octree<AbstractMesh>;
  56920. /**
  56921. * Creates or updates the octree used to boost selection (picking)
  56922. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56923. * @param maxCapacity defines the maximum capacity per leaf
  56924. * @param maxDepth defines the maximum depth of the octree
  56925. * @returns an octree of AbstractMesh
  56926. */
  56927. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56928. }
  56929. interface AbstractMesh {
  56930. /**
  56931. * @hidden
  56932. * Backing Field
  56933. */
  56934. _submeshesOctree: Octree<SubMesh>;
  56935. /**
  56936. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56937. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56938. * @param maxCapacity defines the maximum size of each block (64 by default)
  56939. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56940. * @returns the new octree
  56941. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56942. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56943. */
  56944. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56945. }
  56946. /**
  56947. * Defines the octree scene component responsible to manage any octrees
  56948. * in a given scene.
  56949. */
  56950. export class OctreeSceneComponent {
  56951. /**
  56952. * The component name help to identify the component in the list of scene components.
  56953. */
  56954. readonly name: string;
  56955. /**
  56956. * The scene the component belongs to.
  56957. */
  56958. scene: Scene;
  56959. /**
  56960. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56961. */
  56962. readonly checksIsEnabled: boolean;
  56963. /**
  56964. * Creates a new instance of the component for the given scene
  56965. * @param scene Defines the scene to register the component in
  56966. */
  56967. constructor(scene: Scene);
  56968. /**
  56969. * Registers the component in a given scene
  56970. */
  56971. register(): void;
  56972. /**
  56973. * Return the list of active meshes
  56974. * @returns the list of active meshes
  56975. */
  56976. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56977. /**
  56978. * Return the list of active sub meshes
  56979. * @param mesh The mesh to get the candidates sub meshes from
  56980. * @returns the list of active sub meshes
  56981. */
  56982. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56983. private _tempRay;
  56984. /**
  56985. * Return the list of sub meshes intersecting with a given local ray
  56986. * @param mesh defines the mesh to find the submesh for
  56987. * @param localRay defines the ray in local space
  56988. * @returns the list of intersecting sub meshes
  56989. */
  56990. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56991. /**
  56992. * Return the list of sub meshes colliding with a collider
  56993. * @param mesh defines the mesh to find the submesh for
  56994. * @param collider defines the collider to evaluate the collision against
  56995. * @returns the list of colliding sub meshes
  56996. */
  56997. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56998. /**
  56999. * Rebuilds the elements related to this component in case of
  57000. * context lost for instance.
  57001. */
  57002. rebuild(): void;
  57003. /**
  57004. * Disposes the component and the associated ressources.
  57005. */
  57006. dispose(): void;
  57007. }
  57008. }
  57009. declare module BABYLON {
  57010. /**
  57011. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57012. */
  57013. export interface GizmoAxisCache {
  57014. /** Mesh used to runder the Gizmo */
  57015. gizmoMeshes: Mesh[];
  57016. /** Mesh used to detect user interaction with Gizmo */
  57017. colliderMeshes: Mesh[];
  57018. /** Material used to inicate color of gizmo mesh */
  57019. material: StandardMaterial;
  57020. /** Material used to inicate hover state of the Gizmo */
  57021. hoverMaterial: StandardMaterial;
  57022. /** Material used to inicate disabled state of the Gizmo */
  57023. disableMaterial: StandardMaterial;
  57024. /** Used to indicate Active state of the Gizmo */
  57025. active: boolean;
  57026. }
  57027. /**
  57028. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57029. */
  57030. export class Gizmo implements IDisposable {
  57031. /** The utility layer the gizmo will be added to */
  57032. gizmoLayer: UtilityLayerRenderer;
  57033. /**
  57034. * The root mesh of the gizmo
  57035. */
  57036. _rootMesh: Mesh;
  57037. private _attachedMesh;
  57038. private _attachedNode;
  57039. /**
  57040. * Ratio for the scale of the gizmo (Default: 1)
  57041. */
  57042. protected _scaleRatio: number;
  57043. /**
  57044. * boolean updated by pointermove when a gizmo mesh is hovered
  57045. */
  57046. protected _isHovered: boolean;
  57047. /**
  57048. * Ratio for the scale of the gizmo (Default: 1)
  57049. */
  57050. set scaleRatio(value: number);
  57051. get scaleRatio(): number;
  57052. /**
  57053. * True when the mouse pointer is hovered a gizmo mesh
  57054. */
  57055. get isHovered(): boolean;
  57056. /**
  57057. * If a custom mesh has been set (Default: false)
  57058. */
  57059. protected _customMeshSet: boolean;
  57060. /**
  57061. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57062. * * When set, interactions will be enabled
  57063. */
  57064. get attachedMesh(): Nullable<AbstractMesh>;
  57065. set attachedMesh(value: Nullable<AbstractMesh>);
  57066. /**
  57067. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57068. * * When set, interactions will be enabled
  57069. */
  57070. get attachedNode(): Nullable<Node>;
  57071. set attachedNode(value: Nullable<Node>);
  57072. /**
  57073. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57074. * @param mesh The mesh to replace the default mesh of the gizmo
  57075. */
  57076. setCustomMesh(mesh: Mesh): void;
  57077. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57078. /**
  57079. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57080. */
  57081. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57082. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57083. /**
  57084. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57085. */
  57086. updateGizmoPositionToMatchAttachedMesh: boolean;
  57087. /**
  57088. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57089. */
  57090. updateScale: boolean;
  57091. protected _interactionsEnabled: boolean;
  57092. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57093. private _beforeRenderObserver;
  57094. private _tempQuaternion;
  57095. private _tempVector;
  57096. private _tempVector2;
  57097. private _tempMatrix1;
  57098. private _tempMatrix2;
  57099. private _rightHandtoLeftHandMatrix;
  57100. /**
  57101. * Creates a gizmo
  57102. * @param gizmoLayer The utility layer the gizmo will be added to
  57103. */
  57104. constructor(
  57105. /** The utility layer the gizmo will be added to */
  57106. gizmoLayer?: UtilityLayerRenderer);
  57107. /**
  57108. * Updates the gizmo to match the attached mesh's position/rotation
  57109. */
  57110. protected _update(): void;
  57111. /**
  57112. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57113. * @param value Node, TransformNode or mesh
  57114. */
  57115. protected _matrixChanged(): void;
  57116. /**
  57117. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57118. * @param gizmoLayer The utility layer the gizmo will be added to
  57119. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57120. * @returns {Observer<PointerInfo>} pointerObserver
  57121. */
  57122. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57123. /**
  57124. * Disposes of the gizmo
  57125. */
  57126. dispose(): void;
  57127. }
  57128. }
  57129. declare module BABYLON {
  57130. /**
  57131. * Single plane drag gizmo
  57132. */
  57133. export class PlaneDragGizmo extends Gizmo {
  57134. /**
  57135. * Drag behavior responsible for the gizmos dragging interactions
  57136. */
  57137. dragBehavior: PointerDragBehavior;
  57138. private _pointerObserver;
  57139. /**
  57140. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57141. */
  57142. snapDistance: number;
  57143. /**
  57144. * Event that fires each time the gizmo snaps to a new location.
  57145. * * snapDistance is the the change in distance
  57146. */
  57147. onSnapObservable: Observable<{
  57148. snapDistance: number;
  57149. }>;
  57150. private _gizmoMesh;
  57151. private _coloredMaterial;
  57152. private _hoverMaterial;
  57153. private _disableMaterial;
  57154. private _isEnabled;
  57155. private _parent;
  57156. private _dragging;
  57157. /** @hidden */
  57158. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57159. /**
  57160. * Creates a PlaneDragGizmo
  57161. * @param gizmoLayer The utility layer the gizmo will be added to
  57162. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57163. * @param color The color of the gizmo
  57164. */
  57165. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57166. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57167. /**
  57168. * If the gizmo is enabled
  57169. */
  57170. set isEnabled(value: boolean);
  57171. get isEnabled(): boolean;
  57172. /**
  57173. * Disposes of the gizmo
  57174. */
  57175. dispose(): void;
  57176. }
  57177. }
  57178. declare module BABYLON {
  57179. /**
  57180. * Single plane rotation gizmo
  57181. */
  57182. export class PlaneRotationGizmo extends Gizmo {
  57183. /**
  57184. * Drag behavior responsible for the gizmos dragging interactions
  57185. */
  57186. dragBehavior: PointerDragBehavior;
  57187. private _pointerObserver;
  57188. /**
  57189. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57190. */
  57191. snapDistance: number;
  57192. /**
  57193. * Event that fires each time the gizmo snaps to a new location.
  57194. * * snapDistance is the the change in distance
  57195. */
  57196. onSnapObservable: Observable<{
  57197. snapDistance: number;
  57198. }>;
  57199. private _isEnabled;
  57200. private _parent;
  57201. private _coloredMaterial;
  57202. private _hoverMaterial;
  57203. private _disableMaterial;
  57204. private _gizmoMesh;
  57205. private _rotationCircle;
  57206. private _dragging;
  57207. private static _CircleConstants;
  57208. /**
  57209. * Creates a PlaneRotationGizmo
  57210. * @param gizmoLayer The utility layer the gizmo will be added to
  57211. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57212. * @param color The color of the gizmo
  57213. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57214. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57215. * @param thickness display gizmo axis thickness
  57216. */
  57217. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57218. /** Create Geometry for Gizmo */
  57219. private _createGizmoMesh;
  57220. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57221. private setupRotationCircle;
  57222. private updateRotationPath;
  57223. private updateRotationCircle;
  57224. /**
  57225. * If the gizmo is enabled
  57226. */
  57227. set isEnabled(value: boolean);
  57228. get isEnabled(): boolean;
  57229. /**
  57230. * Disposes of the gizmo
  57231. */
  57232. dispose(): void;
  57233. }
  57234. }
  57235. declare module BABYLON {
  57236. /**
  57237. * Gizmo that enables rotating a mesh along 3 axis
  57238. */
  57239. export class RotationGizmo extends Gizmo {
  57240. /**
  57241. * Internal gizmo used for interactions on the x axis
  57242. */
  57243. xGizmo: PlaneRotationGizmo;
  57244. /**
  57245. * Internal gizmo used for interactions on the y axis
  57246. */
  57247. yGizmo: PlaneRotationGizmo;
  57248. /**
  57249. * Internal gizmo used for interactions on the z axis
  57250. */
  57251. zGizmo: PlaneRotationGizmo;
  57252. /** Fires an event when any of it's sub gizmos are dragged */
  57253. onDragStartObservable: Observable<unknown>;
  57254. /** Fires an event when any of it's sub gizmos are released from dragging */
  57255. onDragEndObservable: Observable<unknown>;
  57256. private _meshAttached;
  57257. private _nodeAttached;
  57258. private _observables;
  57259. /** Node Caching for quick lookup */
  57260. private _gizmoAxisCache;
  57261. get attachedMesh(): Nullable<AbstractMesh>;
  57262. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57263. get attachedNode(): Nullable<Node>;
  57264. set attachedNode(node: Nullable<Node>);
  57265. protected _checkBillboardTransform(): void;
  57266. /**
  57267. * True when the mouse pointer is hovering a gizmo mesh
  57268. */
  57269. get isHovered(): boolean;
  57270. /**
  57271. * Creates a RotationGizmo
  57272. * @param gizmoLayer The utility layer the gizmo will be added to
  57273. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57274. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57275. * @param thickness display gizmo axis thickness
  57276. */
  57277. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57278. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57279. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57280. /**
  57281. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57282. */
  57283. set snapDistance(value: number);
  57284. get snapDistance(): number;
  57285. /**
  57286. * Ratio for the scale of the gizmo (Default: 1)
  57287. */
  57288. set scaleRatio(value: number);
  57289. get scaleRatio(): number;
  57290. /**
  57291. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57292. * @param mesh Axis gizmo mesh
  57293. * @param cache Gizmo axis definition used for reactive gizmo UI
  57294. */
  57295. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57296. /**
  57297. * Disposes of the gizmo
  57298. */
  57299. dispose(): void;
  57300. /**
  57301. * CustomMeshes are not supported by this gizmo
  57302. * @param mesh The mesh to replace the default mesh of the gizmo
  57303. */
  57304. setCustomMesh(mesh: Mesh): void;
  57305. }
  57306. }
  57307. declare module BABYLON {
  57308. /**
  57309. * Class containing static functions to help procedurally build meshes
  57310. */
  57311. export class PolyhedronBuilder {
  57312. /**
  57313. * Creates a polyhedron mesh
  57314. * * 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
  57315. * * The parameter `size` (positive float, default 1) sets the polygon size
  57316. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57317. * * 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`
  57318. * * 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
  57319. * * 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)`)
  57320. * * 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
  57321. * * 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
  57322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57323. * * 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
  57324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57325. * @param name defines the name of the mesh
  57326. * @param options defines the options used to create the mesh
  57327. * @param scene defines the hosting scene
  57328. * @returns the polyhedron mesh
  57329. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57330. */
  57331. static CreatePolyhedron(name: string, options: {
  57332. type?: number;
  57333. size?: number;
  57334. sizeX?: number;
  57335. sizeY?: number;
  57336. sizeZ?: number;
  57337. custom?: any;
  57338. faceUV?: Vector4[];
  57339. faceColors?: Color4[];
  57340. flat?: boolean;
  57341. updatable?: boolean;
  57342. sideOrientation?: number;
  57343. frontUVs?: Vector4;
  57344. backUVs?: Vector4;
  57345. }, scene?: Nullable<Scene>): Mesh;
  57346. }
  57347. }
  57348. declare module BABYLON {
  57349. /**
  57350. * Class containing static functions to help procedurally build meshes
  57351. */
  57352. export class BoxBuilder {
  57353. /**
  57354. * Creates a box mesh
  57355. * * The parameter `size` sets the size (float) of each box side (default 1)
  57356. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57357. * * 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)
  57358. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57360. * * 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
  57361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57362. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57363. * @param name defines the name of the mesh
  57364. * @param options defines the options used to create the mesh
  57365. * @param scene defines the hosting scene
  57366. * @returns the box mesh
  57367. */
  57368. static CreateBox(name: string, options: {
  57369. size?: number;
  57370. width?: number;
  57371. height?: number;
  57372. depth?: number;
  57373. faceUV?: Vector4[];
  57374. faceColors?: Color4[];
  57375. sideOrientation?: number;
  57376. frontUVs?: Vector4;
  57377. backUVs?: Vector4;
  57378. wrap?: boolean;
  57379. topBaseAt?: number;
  57380. bottomBaseAt?: number;
  57381. updatable?: boolean;
  57382. }, scene?: Nullable<Scene>): Mesh;
  57383. }
  57384. }
  57385. declare module BABYLON {
  57386. /**
  57387. * Single axis scale gizmo
  57388. */
  57389. export class AxisScaleGizmo extends Gizmo {
  57390. /**
  57391. * Drag behavior responsible for the gizmos dragging interactions
  57392. */
  57393. dragBehavior: PointerDragBehavior;
  57394. private _pointerObserver;
  57395. /**
  57396. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57397. */
  57398. snapDistance: number;
  57399. /**
  57400. * Event that fires each time the gizmo snaps to a new location.
  57401. * * snapDistance is the the change in distance
  57402. */
  57403. onSnapObservable: Observable<{
  57404. snapDistance: number;
  57405. }>;
  57406. /**
  57407. * If the scaling operation should be done on all axis (default: false)
  57408. */
  57409. uniformScaling: boolean;
  57410. /**
  57411. * Custom sensitivity value for the drag strength
  57412. */
  57413. sensitivity: number;
  57414. private _isEnabled;
  57415. private _parent;
  57416. private _gizmoMesh;
  57417. private _coloredMaterial;
  57418. private _hoverMaterial;
  57419. private _disableMaterial;
  57420. private _dragging;
  57421. private _tmpVector;
  57422. private _tmpMatrix;
  57423. private _tmpMatrix2;
  57424. /**
  57425. * Creates an AxisScaleGizmo
  57426. * @param gizmoLayer The utility layer the gizmo will be added to
  57427. * @param dragAxis The axis which the gizmo will be able to scale on
  57428. * @param color The color of the gizmo
  57429. * @param thickness display gizmo axis thickness
  57430. */
  57431. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57432. /** Create Geometry for Gizmo */
  57433. private _createGizmoMesh;
  57434. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57435. /**
  57436. * If the gizmo is enabled
  57437. */
  57438. set isEnabled(value: boolean);
  57439. get isEnabled(): boolean;
  57440. /**
  57441. * Disposes of the gizmo
  57442. */
  57443. dispose(): void;
  57444. /**
  57445. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57446. * @param mesh The mesh to replace the default mesh of the gizmo
  57447. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57448. */
  57449. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57450. }
  57451. }
  57452. declare module BABYLON {
  57453. /**
  57454. * Gizmo that enables scaling a mesh along 3 axis
  57455. */
  57456. export class ScaleGizmo extends Gizmo {
  57457. /**
  57458. * Internal gizmo used for interactions on the x axis
  57459. */
  57460. xGizmo: AxisScaleGizmo;
  57461. /**
  57462. * Internal gizmo used for interactions on the y axis
  57463. */
  57464. yGizmo: AxisScaleGizmo;
  57465. /**
  57466. * Internal gizmo used for interactions on the z axis
  57467. */
  57468. zGizmo: AxisScaleGizmo;
  57469. /**
  57470. * Internal gizmo used to scale all axis equally
  57471. */
  57472. uniformScaleGizmo: AxisScaleGizmo;
  57473. private _meshAttached;
  57474. private _nodeAttached;
  57475. private _snapDistance;
  57476. private _uniformScalingMesh;
  57477. private _octahedron;
  57478. private _sensitivity;
  57479. private _coloredMaterial;
  57480. private _hoverMaterial;
  57481. private _disableMaterial;
  57482. private _observables;
  57483. /** Node Caching for quick lookup */
  57484. private _gizmoAxisCache;
  57485. /** Fires an event when any of it's sub gizmos are dragged */
  57486. onDragStartObservable: Observable<unknown>;
  57487. /** Fires an event when any of it's sub gizmos are released from dragging */
  57488. onDragEndObservable: Observable<unknown>;
  57489. get attachedMesh(): Nullable<AbstractMesh>;
  57490. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57491. get attachedNode(): Nullable<Node>;
  57492. set attachedNode(node: Nullable<Node>);
  57493. /**
  57494. * True when the mouse pointer is hovering a gizmo mesh
  57495. */
  57496. get isHovered(): boolean;
  57497. /**
  57498. * Creates a ScaleGizmo
  57499. * @param gizmoLayer The utility layer the gizmo will be added to
  57500. * @param thickness display gizmo axis thickness
  57501. */
  57502. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57503. /** Create Geometry for Gizmo */
  57504. private _createUniformScaleMesh;
  57505. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57506. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57507. /**
  57508. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57509. */
  57510. set snapDistance(value: number);
  57511. get snapDistance(): number;
  57512. /**
  57513. * Ratio for the scale of the gizmo (Default: 1)
  57514. */
  57515. set scaleRatio(value: number);
  57516. get scaleRatio(): number;
  57517. /**
  57518. * Sensitivity factor for dragging (Default: 1)
  57519. */
  57520. set sensitivity(value: number);
  57521. get sensitivity(): number;
  57522. /**
  57523. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57524. * @param mesh Axis gizmo mesh
  57525. * @param cache Gizmo axis definition used for reactive gizmo UI
  57526. */
  57527. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57528. /**
  57529. * Disposes of the gizmo
  57530. */
  57531. dispose(): void;
  57532. }
  57533. }
  57534. declare module BABYLON {
  57535. /**
  57536. * Bounding box gizmo
  57537. */
  57538. export class BoundingBoxGizmo extends Gizmo {
  57539. private _lineBoundingBox;
  57540. private _rotateSpheresParent;
  57541. private _scaleBoxesParent;
  57542. private _boundingDimensions;
  57543. private _renderObserver;
  57544. private _pointerObserver;
  57545. private _scaleDragSpeed;
  57546. private _tmpQuaternion;
  57547. private _tmpVector;
  57548. private _tmpRotationMatrix;
  57549. /**
  57550. * 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)
  57551. */
  57552. ignoreChildren: boolean;
  57553. /**
  57554. * 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)
  57555. */
  57556. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57557. /**
  57558. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57559. */
  57560. rotationSphereSize: number;
  57561. /**
  57562. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57563. */
  57564. scaleBoxSize: number;
  57565. /**
  57566. * 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)
  57567. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57568. */
  57569. fixedDragMeshScreenSize: boolean;
  57570. /**
  57571. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57572. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57573. */
  57574. fixedDragMeshBoundsSize: boolean;
  57575. /**
  57576. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57577. */
  57578. fixedDragMeshScreenSizeDistanceFactor: number;
  57579. /**
  57580. * Fired when a rotation sphere or scale box is dragged
  57581. */
  57582. onDragStartObservable: Observable<{}>;
  57583. /**
  57584. * Fired when a scale box is dragged
  57585. */
  57586. onScaleBoxDragObservable: Observable<{}>;
  57587. /**
  57588. * Fired when a scale box drag is ended
  57589. */
  57590. onScaleBoxDragEndObservable: Observable<{}>;
  57591. /**
  57592. * Fired when a rotation sphere is dragged
  57593. */
  57594. onRotationSphereDragObservable: Observable<{}>;
  57595. /**
  57596. * Fired when a rotation sphere drag is ended
  57597. */
  57598. onRotationSphereDragEndObservable: Observable<{}>;
  57599. /**
  57600. * 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)
  57601. */
  57602. scalePivot: Nullable<Vector3>;
  57603. /**
  57604. * Mesh used as a pivot to rotate the attached node
  57605. */
  57606. private _anchorMesh;
  57607. private _existingMeshScale;
  57608. private _dragMesh;
  57609. private pointerDragBehavior;
  57610. private coloredMaterial;
  57611. private hoverColoredMaterial;
  57612. /**
  57613. * Sets the color of the bounding box gizmo
  57614. * @param color the color to set
  57615. */
  57616. setColor(color: Color3): void;
  57617. /**
  57618. * Creates an BoundingBoxGizmo
  57619. * @param gizmoLayer The utility layer the gizmo will be added to
  57620. * @param color The color of the gizmo
  57621. */
  57622. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57623. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57624. private _selectNode;
  57625. /**
  57626. * Updates the bounding box information for the Gizmo
  57627. */
  57628. updateBoundingBox(): void;
  57629. private _updateRotationSpheres;
  57630. private _updateScaleBoxes;
  57631. /**
  57632. * Enables rotation on the specified axis and disables rotation on the others
  57633. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57634. */
  57635. setEnabledRotationAxis(axis: string): void;
  57636. /**
  57637. * Enables/disables scaling
  57638. * @param enable if scaling should be enabled
  57639. * @param homogeneousScaling defines if scaling should only be homogeneous
  57640. */
  57641. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57642. private _updateDummy;
  57643. /**
  57644. * Enables a pointer drag behavior on the bounding box of the gizmo
  57645. */
  57646. enableDragBehavior(): void;
  57647. /**
  57648. * Disposes of the gizmo
  57649. */
  57650. dispose(): void;
  57651. /**
  57652. * 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)
  57653. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57654. * @returns the bounding box mesh with the passed in mesh as a child
  57655. */
  57656. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57657. /**
  57658. * CustomMeshes are not supported by this gizmo
  57659. * @param mesh The mesh to replace the default mesh of the gizmo
  57660. */
  57661. setCustomMesh(mesh: Mesh): void;
  57662. }
  57663. }
  57664. declare module BABYLON {
  57665. /**
  57666. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57667. */
  57668. export class GizmoManager implements IDisposable {
  57669. private scene;
  57670. /**
  57671. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57672. */
  57673. gizmos: {
  57674. positionGizmo: Nullable<PositionGizmo>;
  57675. rotationGizmo: Nullable<RotationGizmo>;
  57676. scaleGizmo: Nullable<ScaleGizmo>;
  57677. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57678. };
  57679. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57680. clearGizmoOnEmptyPointerEvent: boolean;
  57681. /** Fires an event when the manager is attached to a mesh */
  57682. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57683. /** Fires an event when the manager is attached to a node */
  57684. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57685. private _gizmosEnabled;
  57686. private _pointerObservers;
  57687. private _attachedMesh;
  57688. private _attachedNode;
  57689. private _boundingBoxColor;
  57690. private _defaultUtilityLayer;
  57691. private _defaultKeepDepthUtilityLayer;
  57692. private _thickness;
  57693. /** Node Caching for quick lookup */
  57694. private _gizmoAxisCache;
  57695. /**
  57696. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57697. */
  57698. boundingBoxDragBehavior: SixDofDragBehavior;
  57699. /**
  57700. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57701. */
  57702. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57703. /**
  57704. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57705. */
  57706. attachableNodes: Nullable<Array<Node>>;
  57707. /**
  57708. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57709. */
  57710. usePointerToAttachGizmos: boolean;
  57711. /**
  57712. * Utility layer that the bounding box gizmo belongs to
  57713. */
  57714. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57715. /**
  57716. * Utility layer that all gizmos besides bounding box belong to
  57717. */
  57718. get utilityLayer(): UtilityLayerRenderer;
  57719. /**
  57720. * True when the mouse pointer is hovering a gizmo mesh
  57721. */
  57722. get isHovered(): boolean;
  57723. /**
  57724. * Instatiates a gizmo manager
  57725. * @param scene the scene to overlay the gizmos on top of
  57726. * @param thickness display gizmo axis thickness
  57727. * @param utilityLayer the layer where gizmos are rendered
  57728. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57729. */
  57730. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57731. /**
  57732. * Subscribes to pointer down events, for attaching and detaching mesh
  57733. * @param scene The sceme layer the observer will be added to
  57734. */
  57735. private _attachToMeshPointerObserver;
  57736. /**
  57737. * Attaches a set of gizmos to the specified mesh
  57738. * @param mesh The mesh the gizmo's should be attached to
  57739. */
  57740. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57741. /**
  57742. * Attaches a set of gizmos to the specified node
  57743. * @param node The node the gizmo's should be attached to
  57744. */
  57745. attachToNode(node: Nullable<Node>): void;
  57746. /**
  57747. * If the position gizmo is enabled
  57748. */
  57749. set positionGizmoEnabled(value: boolean);
  57750. get positionGizmoEnabled(): boolean;
  57751. /**
  57752. * If the rotation gizmo is enabled
  57753. */
  57754. set rotationGizmoEnabled(value: boolean);
  57755. get rotationGizmoEnabled(): boolean;
  57756. /**
  57757. * If the scale gizmo is enabled
  57758. */
  57759. set scaleGizmoEnabled(value: boolean);
  57760. get scaleGizmoEnabled(): boolean;
  57761. /**
  57762. * If the boundingBox gizmo is enabled
  57763. */
  57764. set boundingBoxGizmoEnabled(value: boolean);
  57765. get boundingBoxGizmoEnabled(): boolean;
  57766. /**
  57767. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57768. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57769. */
  57770. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57771. /**
  57772. * Disposes of the gizmo manager
  57773. */
  57774. dispose(): void;
  57775. }
  57776. }
  57777. declare module BABYLON {
  57778. /**
  57779. * Gizmo that enables dragging a mesh along 3 axis
  57780. */
  57781. export class PositionGizmo extends Gizmo {
  57782. /**
  57783. * Internal gizmo used for interactions on the x axis
  57784. */
  57785. xGizmo: AxisDragGizmo;
  57786. /**
  57787. * Internal gizmo used for interactions on the y axis
  57788. */
  57789. yGizmo: AxisDragGizmo;
  57790. /**
  57791. * Internal gizmo used for interactions on the z axis
  57792. */
  57793. zGizmo: AxisDragGizmo;
  57794. /**
  57795. * Internal gizmo used for interactions on the yz plane
  57796. */
  57797. xPlaneGizmo: PlaneDragGizmo;
  57798. /**
  57799. * Internal gizmo used for interactions on the xz plane
  57800. */
  57801. yPlaneGizmo: PlaneDragGizmo;
  57802. /**
  57803. * Internal gizmo used for interactions on the xy plane
  57804. */
  57805. zPlaneGizmo: PlaneDragGizmo;
  57806. /**
  57807. * private variables
  57808. */
  57809. private _meshAttached;
  57810. private _nodeAttached;
  57811. private _snapDistance;
  57812. private _observables;
  57813. /** Node Caching for quick lookup */
  57814. private _gizmoAxisCache;
  57815. /** Fires an event when any of it's sub gizmos are dragged */
  57816. onDragStartObservable: Observable<unknown>;
  57817. /** Fires an event when any of it's sub gizmos are released from dragging */
  57818. onDragEndObservable: Observable<unknown>;
  57819. /**
  57820. * If set to true, planar drag is enabled
  57821. */
  57822. private _planarGizmoEnabled;
  57823. get attachedMesh(): Nullable<AbstractMesh>;
  57824. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57825. get attachedNode(): Nullable<Node>;
  57826. set attachedNode(node: Nullable<Node>);
  57827. /**
  57828. * True when the mouse pointer is hovering a gizmo mesh
  57829. */
  57830. get isHovered(): boolean;
  57831. /**
  57832. * Creates a PositionGizmo
  57833. * @param gizmoLayer The utility layer the gizmo will be added to
  57834. @param thickness display gizmo axis thickness
  57835. */
  57836. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57837. /**
  57838. * If the planar drag gizmo is enabled
  57839. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57840. */
  57841. set planarGizmoEnabled(value: boolean);
  57842. get planarGizmoEnabled(): boolean;
  57843. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57844. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57845. /**
  57846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57847. */
  57848. set snapDistance(value: number);
  57849. get snapDistance(): number;
  57850. /**
  57851. * Ratio for the scale of the gizmo (Default: 1)
  57852. */
  57853. set scaleRatio(value: number);
  57854. get scaleRatio(): number;
  57855. /**
  57856. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57857. * @param mesh Axis gizmo mesh
  57858. * @param cache Gizmo axis definition used for reactive gizmo UI
  57859. */
  57860. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57861. /**
  57862. * Disposes of the gizmo
  57863. */
  57864. dispose(): void;
  57865. /**
  57866. * CustomMeshes are not supported by this gizmo
  57867. * @param mesh The mesh to replace the default mesh of the gizmo
  57868. */
  57869. setCustomMesh(mesh: Mesh): void;
  57870. }
  57871. }
  57872. declare module BABYLON {
  57873. /**
  57874. * Single axis drag gizmo
  57875. */
  57876. export class AxisDragGizmo extends Gizmo {
  57877. /**
  57878. * Drag behavior responsible for the gizmos dragging interactions
  57879. */
  57880. dragBehavior: PointerDragBehavior;
  57881. private _pointerObserver;
  57882. /**
  57883. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57884. */
  57885. snapDistance: number;
  57886. /**
  57887. * Event that fires each time the gizmo snaps to a new location.
  57888. * * snapDistance is the the change in distance
  57889. */
  57890. onSnapObservable: Observable<{
  57891. snapDistance: number;
  57892. }>;
  57893. private _isEnabled;
  57894. private _parent;
  57895. private _gizmoMesh;
  57896. private _coloredMaterial;
  57897. private _hoverMaterial;
  57898. private _disableMaterial;
  57899. private _dragging;
  57900. /** @hidden */
  57901. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57902. /** @hidden */
  57903. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57904. /**
  57905. * Creates an AxisDragGizmo
  57906. * @param gizmoLayer The utility layer the gizmo will be added to
  57907. * @param dragAxis The axis which the gizmo will be able to drag on
  57908. * @param color The color of the gizmo
  57909. * @param thickness display gizmo axis thickness
  57910. */
  57911. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57912. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57913. /**
  57914. * If the gizmo is enabled
  57915. */
  57916. set isEnabled(value: boolean);
  57917. get isEnabled(): boolean;
  57918. /**
  57919. * Disposes of the gizmo
  57920. */
  57921. dispose(): void;
  57922. }
  57923. }
  57924. declare module BABYLON.Debug {
  57925. /**
  57926. * The Axes viewer will show 3 axes in a specific point in space
  57927. */
  57928. export class AxesViewer {
  57929. private _xAxis;
  57930. private _yAxis;
  57931. private _zAxis;
  57932. private _scaleLinesFactor;
  57933. private _instanced;
  57934. /**
  57935. * Gets the hosting scene
  57936. */
  57937. scene: Nullable<Scene>;
  57938. /**
  57939. * Gets or sets a number used to scale line length
  57940. */
  57941. scaleLines: number;
  57942. /** Gets the node hierarchy used to render x-axis */
  57943. get xAxis(): TransformNode;
  57944. /** Gets the node hierarchy used to render y-axis */
  57945. get yAxis(): TransformNode;
  57946. /** Gets the node hierarchy used to render z-axis */
  57947. get zAxis(): TransformNode;
  57948. /**
  57949. * Creates a new AxesViewer
  57950. * @param scene defines the hosting scene
  57951. * @param scaleLines defines a number used to scale line length (1 by default)
  57952. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57953. * @param xAxis defines the node hierarchy used to render the x-axis
  57954. * @param yAxis defines the node hierarchy used to render the y-axis
  57955. * @param zAxis defines the node hierarchy used to render the z-axis
  57956. */
  57957. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57958. /**
  57959. * Force the viewer to update
  57960. * @param position defines the position of the viewer
  57961. * @param xaxis defines the x axis of the viewer
  57962. * @param yaxis defines the y axis of the viewer
  57963. * @param zaxis defines the z axis of the viewer
  57964. */
  57965. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57966. /**
  57967. * Creates an instance of this axes viewer.
  57968. * @returns a new axes viewer with instanced meshes
  57969. */
  57970. createInstance(): AxesViewer;
  57971. /** Releases resources */
  57972. dispose(): void;
  57973. private static _SetRenderingGroupId;
  57974. }
  57975. }
  57976. declare module BABYLON.Debug {
  57977. /**
  57978. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57979. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57980. */
  57981. export class BoneAxesViewer extends AxesViewer {
  57982. /**
  57983. * Gets or sets the target mesh where to display the axes viewer
  57984. */
  57985. mesh: Nullable<Mesh>;
  57986. /**
  57987. * Gets or sets the target bone where to display the axes viewer
  57988. */
  57989. bone: Nullable<Bone>;
  57990. /** Gets current position */
  57991. pos: Vector3;
  57992. /** Gets direction of X axis */
  57993. xaxis: Vector3;
  57994. /** Gets direction of Y axis */
  57995. yaxis: Vector3;
  57996. /** Gets direction of Z axis */
  57997. zaxis: Vector3;
  57998. /**
  57999. * Creates a new BoneAxesViewer
  58000. * @param scene defines the hosting scene
  58001. * @param bone defines the target bone
  58002. * @param mesh defines the target mesh
  58003. * @param scaleLines defines a scaling factor for line length (1 by default)
  58004. */
  58005. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58006. /**
  58007. * Force the viewer to update
  58008. */
  58009. update(): void;
  58010. /** Releases resources */
  58011. dispose(): void;
  58012. }
  58013. }
  58014. declare module BABYLON {
  58015. /**
  58016. * Interface used to define scene explorer extensibility option
  58017. */
  58018. export interface IExplorerExtensibilityOption {
  58019. /**
  58020. * Define the option label
  58021. */
  58022. label: string;
  58023. /**
  58024. * Defines the action to execute on click
  58025. */
  58026. action: (entity: any) => void;
  58027. }
  58028. /**
  58029. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58030. */
  58031. export interface IExplorerExtensibilityGroup {
  58032. /**
  58033. * Defines a predicate to test if a given type mut be extended
  58034. */
  58035. predicate: (entity: any) => boolean;
  58036. /**
  58037. * Gets the list of options added to a type
  58038. */
  58039. entries: IExplorerExtensibilityOption[];
  58040. }
  58041. /**
  58042. * Interface used to define the options to use to create the Inspector
  58043. */
  58044. export interface IInspectorOptions {
  58045. /**
  58046. * Display in overlay mode (default: false)
  58047. */
  58048. overlay?: boolean;
  58049. /**
  58050. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58051. */
  58052. globalRoot?: HTMLElement;
  58053. /**
  58054. * Display the Scene explorer
  58055. */
  58056. showExplorer?: boolean;
  58057. /**
  58058. * Display the property inspector
  58059. */
  58060. showInspector?: boolean;
  58061. /**
  58062. * Display in embed mode (both panes on the right)
  58063. */
  58064. embedMode?: boolean;
  58065. /**
  58066. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58067. */
  58068. handleResize?: boolean;
  58069. /**
  58070. * Allow the panes to popup (default: true)
  58071. */
  58072. enablePopup?: boolean;
  58073. /**
  58074. * Allow the panes to be closed by users (default: true)
  58075. */
  58076. enableClose?: boolean;
  58077. /**
  58078. * Optional list of extensibility entries
  58079. */
  58080. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58081. /**
  58082. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58083. */
  58084. inspectorURL?: string;
  58085. /**
  58086. * Optional initial tab (default to DebugLayerTab.Properties)
  58087. */
  58088. initialTab?: DebugLayerTab;
  58089. }
  58090. interface Scene {
  58091. /**
  58092. * @hidden
  58093. * Backing field
  58094. */
  58095. _debugLayer: DebugLayer;
  58096. /**
  58097. * Gets the debug layer (aka Inspector) associated with the scene
  58098. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58099. */
  58100. debugLayer: DebugLayer;
  58101. }
  58102. /**
  58103. * Enum of inspector action tab
  58104. */
  58105. export enum DebugLayerTab {
  58106. /**
  58107. * Properties tag (default)
  58108. */
  58109. Properties = 0,
  58110. /**
  58111. * Debug tab
  58112. */
  58113. Debug = 1,
  58114. /**
  58115. * Statistics tab
  58116. */
  58117. Statistics = 2,
  58118. /**
  58119. * Tools tab
  58120. */
  58121. Tools = 3,
  58122. /**
  58123. * Settings tab
  58124. */
  58125. Settings = 4
  58126. }
  58127. /**
  58128. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58129. * what is happening in your scene
  58130. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58131. */
  58132. export class DebugLayer {
  58133. /**
  58134. * Define the url to get the inspector script from.
  58135. * By default it uses the babylonjs CDN.
  58136. * @ignoreNaming
  58137. */
  58138. static InspectorURL: string;
  58139. private _scene;
  58140. private BJSINSPECTOR;
  58141. private _onPropertyChangedObservable?;
  58142. /**
  58143. * Observable triggered when a property is changed through the inspector.
  58144. */
  58145. get onPropertyChangedObservable(): any;
  58146. /**
  58147. * Instantiates a new debug layer.
  58148. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58149. * what is happening in your scene
  58150. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58151. * @param scene Defines the scene to inspect
  58152. */
  58153. constructor(scene: Scene);
  58154. /** Creates the inspector window. */
  58155. private _createInspector;
  58156. /**
  58157. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58158. * @param entity defines the entity to select
  58159. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58160. */
  58161. select(entity: any, lineContainerTitles?: string | string[]): void;
  58162. /** Get the inspector from bundle or global */
  58163. private _getGlobalInspector;
  58164. /**
  58165. * Get if the inspector is visible or not.
  58166. * @returns true if visible otherwise, false
  58167. */
  58168. isVisible(): boolean;
  58169. /**
  58170. * Hide the inspector and close its window.
  58171. */
  58172. hide(): void;
  58173. /**
  58174. * Update the scene in the inspector
  58175. */
  58176. setAsActiveScene(): void;
  58177. /**
  58178. * Launch the debugLayer.
  58179. * @param config Define the configuration of the inspector
  58180. * @return a promise fulfilled when the debug layer is visible
  58181. */
  58182. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58183. }
  58184. }
  58185. declare module BABYLON.Debug {
  58186. /**
  58187. * Used to show the physics impostor around the specific mesh
  58188. */
  58189. export class PhysicsViewer {
  58190. /** @hidden */
  58191. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58192. /** @hidden */
  58193. protected _meshes: Array<Nullable<AbstractMesh>>;
  58194. /** @hidden */
  58195. protected _scene: Nullable<Scene>;
  58196. /** @hidden */
  58197. protected _numMeshes: number;
  58198. /** @hidden */
  58199. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58200. private _renderFunction;
  58201. private _utilityLayer;
  58202. private _debugBoxMesh;
  58203. private _debugSphereMesh;
  58204. private _debugCylinderMesh;
  58205. private _debugMaterial;
  58206. private _debugMeshMeshes;
  58207. /**
  58208. * Creates a new PhysicsViewer
  58209. * @param scene defines the hosting scene
  58210. */
  58211. constructor(scene: Scene);
  58212. /** @hidden */
  58213. protected _updateDebugMeshes(): void;
  58214. /**
  58215. * Renders a specified physic impostor
  58216. * @param impostor defines the impostor to render
  58217. * @param targetMesh defines the mesh represented by the impostor
  58218. * @returns the new debug mesh used to render the impostor
  58219. */
  58220. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58221. /**
  58222. * Hides a specified physic impostor
  58223. * @param impostor defines the impostor to hide
  58224. */
  58225. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58226. private _getDebugMaterial;
  58227. private _getDebugBoxMesh;
  58228. private _getDebugSphereMesh;
  58229. private _getDebugCylinderMesh;
  58230. private _getDebugMeshMesh;
  58231. private _getDebugMesh;
  58232. /** Releases all resources */
  58233. dispose(): void;
  58234. }
  58235. }
  58236. declare module BABYLON {
  58237. /**
  58238. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58239. * in order to better appreciate the issue one might have.
  58240. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58241. */
  58242. export class RayHelper {
  58243. /**
  58244. * Defines the ray we are currently tryin to visualize.
  58245. */
  58246. ray: Nullable<Ray>;
  58247. private _renderPoints;
  58248. private _renderLine;
  58249. private _renderFunction;
  58250. private _scene;
  58251. private _onAfterRenderObserver;
  58252. private _onAfterStepObserver;
  58253. private _attachedToMesh;
  58254. private _meshSpaceDirection;
  58255. private _meshSpaceOrigin;
  58256. /**
  58257. * Helper function to create a colored helper in a scene in one line.
  58258. * @param ray Defines the ray we are currently tryin to visualize
  58259. * @param scene Defines the scene the ray is used in
  58260. * @param color Defines the color we want to see the ray in
  58261. * @returns The newly created ray helper.
  58262. */
  58263. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58264. /**
  58265. * Instantiate a new ray helper.
  58266. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58267. * in order to better appreciate the issue one might have.
  58268. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58269. * @param ray Defines the ray we are currently tryin to visualize
  58270. */
  58271. constructor(ray: Ray);
  58272. /**
  58273. * Shows the ray we are willing to debug.
  58274. * @param scene Defines the scene the ray needs to be rendered in
  58275. * @param color Defines the color the ray needs to be rendered in
  58276. */
  58277. show(scene: Scene, color?: Color3): void;
  58278. /**
  58279. * Hides the ray we are debugging.
  58280. */
  58281. hide(): void;
  58282. private _render;
  58283. /**
  58284. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58285. * @param mesh Defines the mesh we want the helper attached to
  58286. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58287. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58288. * @param length Defines the length of the ray
  58289. */
  58290. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58291. /**
  58292. * Detach the ray helper from the mesh it has previously been attached to.
  58293. */
  58294. detachFromMesh(): void;
  58295. private _updateToMesh;
  58296. /**
  58297. * Dispose the helper and release its associated resources.
  58298. */
  58299. dispose(): void;
  58300. }
  58301. }
  58302. declare module BABYLON {
  58303. /**
  58304. * Defines the options associated with the creation of a SkeletonViewer.
  58305. */
  58306. export interface ISkeletonViewerOptions {
  58307. /** Should the system pause animations before building the Viewer? */
  58308. pauseAnimations: boolean;
  58309. /** Should the system return the skeleton to rest before building? */
  58310. returnToRest: boolean;
  58311. /** public Display Mode of the Viewer */
  58312. displayMode: number;
  58313. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58314. displayOptions: ISkeletonViewerDisplayOptions;
  58315. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58316. computeBonesUsingShaders: boolean;
  58317. /** Flag ignore non weighted bones */
  58318. useAllBones: boolean;
  58319. }
  58320. /**
  58321. * Defines how to display the various bone meshes for the viewer.
  58322. */
  58323. export interface ISkeletonViewerDisplayOptions {
  58324. /** How far down to start tapering the bone spurs */
  58325. midStep?: number;
  58326. /** How big is the midStep? */
  58327. midStepFactor?: number;
  58328. /** Base for the Sphere Size */
  58329. sphereBaseSize?: number;
  58330. /** The ratio of the sphere to the longest bone in units */
  58331. sphereScaleUnit?: number;
  58332. /** Ratio for the Sphere Size */
  58333. sphereFactor?: number;
  58334. /** Whether a spur should attach its far end to the child bone position */
  58335. spurFollowsChild?: boolean;
  58336. /** Whether to show local axes or not */
  58337. showLocalAxes?: boolean;
  58338. /** Length of each local axis */
  58339. localAxesSize?: number;
  58340. }
  58341. /**
  58342. * Defines the constructor options for the BoneWeight Shader.
  58343. */
  58344. export interface IBoneWeightShaderOptions {
  58345. /** Skeleton to Map */
  58346. skeleton: Skeleton;
  58347. /** Colors for Uninfluenced bones */
  58348. colorBase?: Color3;
  58349. /** Colors for 0.0-0.25 Weight bones */
  58350. colorZero?: Color3;
  58351. /** Color for 0.25-0.5 Weight Influence */
  58352. colorQuarter?: Color3;
  58353. /** Color for 0.5-0.75 Weight Influence */
  58354. colorHalf?: Color3;
  58355. /** Color for 0.75-1 Weight Influence */
  58356. colorFull?: Color3;
  58357. /** Color for Zero Weight Influence */
  58358. targetBoneIndex?: number;
  58359. }
  58360. /**
  58361. * Simple structure of the gradient steps for the Color Map.
  58362. */
  58363. export interface ISkeletonMapShaderColorMapKnot {
  58364. /** Color of the Knot */
  58365. color: Color3;
  58366. /** Location of the Knot */
  58367. location: number;
  58368. }
  58369. /**
  58370. * Defines the constructor options for the SkeletonMap Shader.
  58371. */
  58372. export interface ISkeletonMapShaderOptions {
  58373. /** Skeleton to Map */
  58374. skeleton: Skeleton;
  58375. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58376. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58377. }
  58378. }
  58379. declare module BABYLON {
  58380. /**
  58381. * Class containing static functions to help procedurally build meshes
  58382. */
  58383. export class RibbonBuilder {
  58384. /**
  58385. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58386. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58387. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58388. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58389. * * 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
  58390. * * 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
  58391. * * 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
  58392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58393. * * 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
  58394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58395. * * 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
  58396. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58397. * * 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
  58398. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58400. * @param name defines the name of the mesh
  58401. * @param options defines the options used to create the mesh
  58402. * @param scene defines the hosting scene
  58403. * @returns the ribbon mesh
  58404. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58406. */
  58407. static CreateRibbon(name: string, options: {
  58408. pathArray: Vector3[][];
  58409. closeArray?: boolean;
  58410. closePath?: boolean;
  58411. offset?: number;
  58412. updatable?: boolean;
  58413. sideOrientation?: number;
  58414. frontUVs?: Vector4;
  58415. backUVs?: Vector4;
  58416. instance?: Mesh;
  58417. invertUV?: boolean;
  58418. uvs?: Vector2[];
  58419. colors?: Color4[];
  58420. }, scene?: Nullable<Scene>): Mesh;
  58421. }
  58422. }
  58423. declare module BABYLON {
  58424. /**
  58425. * Class containing static functions to help procedurally build meshes
  58426. */
  58427. export class ShapeBuilder {
  58428. /**
  58429. * 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.
  58430. * * 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.
  58431. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58432. * * 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.
  58433. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58434. * * 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
  58435. * * 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
  58436. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58438. * * 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
  58439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58441. * @param name defines the name of the mesh
  58442. * @param options defines the options used to create the mesh
  58443. * @param scene defines the hosting scene
  58444. * @returns the extruded shape mesh
  58445. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58447. */
  58448. static ExtrudeShape(name: string, options: {
  58449. shape: Vector3[];
  58450. path: Vector3[];
  58451. scale?: number;
  58452. rotation?: number;
  58453. cap?: number;
  58454. updatable?: boolean;
  58455. sideOrientation?: number;
  58456. frontUVs?: Vector4;
  58457. backUVs?: Vector4;
  58458. instance?: Mesh;
  58459. invertUV?: boolean;
  58460. }, scene?: Nullable<Scene>): Mesh;
  58461. /**
  58462. * Creates an custom extruded shape mesh.
  58463. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58464. * * 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.
  58465. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58466. * * 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
  58467. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58468. * * 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
  58469. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58470. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58471. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58472. * * 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
  58473. * * 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
  58474. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58476. * * 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
  58477. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58479. * @param name defines the name of the mesh
  58480. * @param options defines the options used to create the mesh
  58481. * @param scene defines the hosting scene
  58482. * @returns the custom extruded shape mesh
  58483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58486. */
  58487. static ExtrudeShapeCustom(name: string, options: {
  58488. shape: Vector3[];
  58489. path: Vector3[];
  58490. scaleFunction?: any;
  58491. rotationFunction?: any;
  58492. ribbonCloseArray?: boolean;
  58493. ribbonClosePath?: boolean;
  58494. cap?: number;
  58495. updatable?: boolean;
  58496. sideOrientation?: number;
  58497. frontUVs?: Vector4;
  58498. backUVs?: Vector4;
  58499. instance?: Mesh;
  58500. invertUV?: boolean;
  58501. }, scene?: Nullable<Scene>): Mesh;
  58502. private static _ExtrudeShapeGeneric;
  58503. }
  58504. }
  58505. declare module BABYLON.Debug {
  58506. /**
  58507. * Class used to render a debug view of a given skeleton
  58508. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58509. */
  58510. export class SkeletonViewer {
  58511. /** defines the skeleton to render */
  58512. skeleton: Skeleton;
  58513. /** defines the mesh attached to the skeleton */
  58514. mesh: AbstractMesh;
  58515. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58516. autoUpdateBonesMatrices: boolean;
  58517. /** defines the rendering group id to use with the viewer */
  58518. renderingGroupId: number;
  58519. /** is the options for the viewer */
  58520. options: Partial<ISkeletonViewerOptions>;
  58521. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58522. static readonly DISPLAY_LINES: number;
  58523. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58524. static readonly DISPLAY_SPHERES: number;
  58525. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58526. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58527. /** public static method to create a BoneWeight Shader
  58528. * @param options The constructor options
  58529. * @param scene The scene that the shader is scoped to
  58530. * @returns The created ShaderMaterial
  58531. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58532. */
  58533. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58534. /** public static method to create a BoneWeight Shader
  58535. * @param options The constructor options
  58536. * @param scene The scene that the shader is scoped to
  58537. * @returns The created ShaderMaterial
  58538. */
  58539. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58540. /** private static method to create a BoneWeight Shader
  58541. * @param size The size of the buffer to create (usually the bone count)
  58542. * @param colorMap The gradient data to generate
  58543. * @param scene The scene that the shader is scoped to
  58544. * @returns an Array of floats from the color gradient values
  58545. */
  58546. private static _CreateBoneMapColorBuffer;
  58547. /** If SkeletonViewer scene scope. */
  58548. private _scene;
  58549. /** Gets or sets the color used to render the skeleton */
  58550. color: Color3;
  58551. /** Array of the points of the skeleton fo the line view. */
  58552. private _debugLines;
  58553. /** The SkeletonViewers Mesh. */
  58554. private _debugMesh;
  58555. /** The local axes Meshes. */
  58556. private _localAxes;
  58557. /** If SkeletonViewer is enabled. */
  58558. private _isEnabled;
  58559. /** If SkeletonViewer is ready. */
  58560. private _ready;
  58561. /** SkeletonViewer render observable. */
  58562. private _obs;
  58563. /** The Utility Layer to render the gizmos in. */
  58564. private _utilityLayer;
  58565. private _boneIndices;
  58566. /** Gets the Scene. */
  58567. get scene(): Scene;
  58568. /** Gets the utilityLayer. */
  58569. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58570. /** Checks Ready Status. */
  58571. get isReady(): Boolean;
  58572. /** Sets Ready Status. */
  58573. set ready(value: boolean);
  58574. /** Gets the debugMesh */
  58575. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58576. /** Sets the debugMesh */
  58577. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58578. /** Gets the displayMode */
  58579. get displayMode(): number;
  58580. /** Sets the displayMode */
  58581. set displayMode(value: number);
  58582. /**
  58583. * Creates a new SkeletonViewer
  58584. * @param skeleton defines the skeleton to render
  58585. * @param mesh defines the mesh attached to the skeleton
  58586. * @param scene defines the hosting scene
  58587. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58588. * @param renderingGroupId defines the rendering group id to use with the viewer
  58589. * @param options All of the extra constructor options for the SkeletonViewer
  58590. */
  58591. constructor(
  58592. /** defines the skeleton to render */
  58593. skeleton: Skeleton,
  58594. /** defines the mesh attached to the skeleton */
  58595. mesh: AbstractMesh,
  58596. /** The Scene scope*/
  58597. scene: Scene,
  58598. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58599. autoUpdateBonesMatrices?: boolean,
  58600. /** defines the rendering group id to use with the viewer */
  58601. renderingGroupId?: number,
  58602. /** is the options for the viewer */
  58603. options?: Partial<ISkeletonViewerOptions>);
  58604. /** The Dynamic bindings for the update functions */
  58605. private _bindObs;
  58606. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58607. update(): void;
  58608. /** Gets or sets a boolean indicating if the viewer is enabled */
  58609. set isEnabled(value: boolean);
  58610. get isEnabled(): boolean;
  58611. private _getBonePosition;
  58612. private _getLinesForBonesWithLength;
  58613. private _getLinesForBonesNoLength;
  58614. /** function to revert the mesh and scene back to the initial state. */
  58615. private _revert;
  58616. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58617. private _getAbsoluteBindPoseToRef;
  58618. /** function to build and bind sphere joint points and spur bone representations. */
  58619. private _buildSpheresAndSpurs;
  58620. private _buildLocalAxes;
  58621. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58622. private _displayLinesUpdate;
  58623. /** Changes the displayMode of the skeleton viewer
  58624. * @param mode The displayMode numerical value
  58625. */
  58626. changeDisplayMode(mode: number): void;
  58627. /** Sets a display option of the skeleton viewer
  58628. *
  58629. * | Option | Type | Default | Description |
  58630. * | ---------------- | ------- | ------- | ----------- |
  58631. * | 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`. |
  58632. * | 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`. |
  58633. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58634. * | 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`. |
  58635. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58636. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58637. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58638. *
  58639. * @param option String of the option name
  58640. * @param value The numerical option value
  58641. */
  58642. changeDisplayOptions(option: string, value: number): void;
  58643. /** Release associated resources */
  58644. dispose(): void;
  58645. }
  58646. }
  58647. declare module BABYLON {
  58648. /**
  58649. * Enum for Device Types
  58650. */
  58651. export enum DeviceType {
  58652. /** Generic */
  58653. Generic = 0,
  58654. /** Keyboard */
  58655. Keyboard = 1,
  58656. /** Mouse */
  58657. Mouse = 2,
  58658. /** Touch Pointers */
  58659. Touch = 3,
  58660. /** PS4 Dual Shock */
  58661. DualShock = 4,
  58662. /** Xbox */
  58663. Xbox = 5,
  58664. /** Switch Controller */
  58665. Switch = 6
  58666. }
  58667. /**
  58668. * Enum for All Pointers (Touch/Mouse)
  58669. */
  58670. export enum PointerInput {
  58671. /** Horizontal Axis */
  58672. Horizontal = 0,
  58673. /** Vertical Axis */
  58674. Vertical = 1,
  58675. /** Left Click or Touch */
  58676. LeftClick = 2,
  58677. /** Middle Click */
  58678. MiddleClick = 3,
  58679. /** Right Click */
  58680. RightClick = 4,
  58681. /** Browser Back */
  58682. BrowserBack = 5,
  58683. /** Browser Forward */
  58684. BrowserForward = 6
  58685. }
  58686. /**
  58687. * Enum for Dual Shock Gamepad
  58688. */
  58689. export enum DualShockInput {
  58690. /** Cross */
  58691. Cross = 0,
  58692. /** Circle */
  58693. Circle = 1,
  58694. /** Square */
  58695. Square = 2,
  58696. /** Triangle */
  58697. Triangle = 3,
  58698. /** L1 */
  58699. L1 = 4,
  58700. /** R1 */
  58701. R1 = 5,
  58702. /** L2 */
  58703. L2 = 6,
  58704. /** R2 */
  58705. R2 = 7,
  58706. /** Share */
  58707. Share = 8,
  58708. /** Options */
  58709. Options = 9,
  58710. /** L3 */
  58711. L3 = 10,
  58712. /** R3 */
  58713. R3 = 11,
  58714. /** DPadUp */
  58715. DPadUp = 12,
  58716. /** DPadDown */
  58717. DPadDown = 13,
  58718. /** DPadLeft */
  58719. DPadLeft = 14,
  58720. /** DRight */
  58721. DPadRight = 15,
  58722. /** Home */
  58723. Home = 16,
  58724. /** TouchPad */
  58725. TouchPad = 17,
  58726. /** LStickXAxis */
  58727. LStickXAxis = 18,
  58728. /** LStickYAxis */
  58729. LStickYAxis = 19,
  58730. /** RStickXAxis */
  58731. RStickXAxis = 20,
  58732. /** RStickYAxis */
  58733. RStickYAxis = 21
  58734. }
  58735. /**
  58736. * Enum for Xbox Gamepad
  58737. */
  58738. export enum XboxInput {
  58739. /** A */
  58740. A = 0,
  58741. /** B */
  58742. B = 1,
  58743. /** X */
  58744. X = 2,
  58745. /** Y */
  58746. Y = 3,
  58747. /** LB */
  58748. LB = 4,
  58749. /** RB */
  58750. RB = 5,
  58751. /** LT */
  58752. LT = 6,
  58753. /** RT */
  58754. RT = 7,
  58755. /** Back */
  58756. Back = 8,
  58757. /** Start */
  58758. Start = 9,
  58759. /** LS */
  58760. LS = 10,
  58761. /** RS */
  58762. RS = 11,
  58763. /** DPadUp */
  58764. DPadUp = 12,
  58765. /** DPadDown */
  58766. DPadDown = 13,
  58767. /** DPadLeft */
  58768. DPadLeft = 14,
  58769. /** DRight */
  58770. DPadRight = 15,
  58771. /** Home */
  58772. Home = 16,
  58773. /** LStickXAxis */
  58774. LStickXAxis = 17,
  58775. /** LStickYAxis */
  58776. LStickYAxis = 18,
  58777. /** RStickXAxis */
  58778. RStickXAxis = 19,
  58779. /** RStickYAxis */
  58780. RStickYAxis = 20
  58781. }
  58782. /**
  58783. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58784. */
  58785. export enum SwitchInput {
  58786. /** B */
  58787. B = 0,
  58788. /** A */
  58789. A = 1,
  58790. /** Y */
  58791. Y = 2,
  58792. /** X */
  58793. X = 3,
  58794. /** L */
  58795. L = 4,
  58796. /** R */
  58797. R = 5,
  58798. /** ZL */
  58799. ZL = 6,
  58800. /** ZR */
  58801. ZR = 7,
  58802. /** Minus */
  58803. Minus = 8,
  58804. /** Plus */
  58805. Plus = 9,
  58806. /** LS */
  58807. LS = 10,
  58808. /** RS */
  58809. RS = 11,
  58810. /** DPadUp */
  58811. DPadUp = 12,
  58812. /** DPadDown */
  58813. DPadDown = 13,
  58814. /** DPadLeft */
  58815. DPadLeft = 14,
  58816. /** DRight */
  58817. DPadRight = 15,
  58818. /** Home */
  58819. Home = 16,
  58820. /** Capture */
  58821. Capture = 17,
  58822. /** LStickXAxis */
  58823. LStickXAxis = 18,
  58824. /** LStickYAxis */
  58825. LStickYAxis = 19,
  58826. /** RStickXAxis */
  58827. RStickXAxis = 20,
  58828. /** RStickYAxis */
  58829. RStickYAxis = 21
  58830. }
  58831. }
  58832. declare module BABYLON {
  58833. /**
  58834. * This class will take all inputs from Keyboard, Pointer, and
  58835. * any Gamepads and provide a polling system that all devices
  58836. * will use. This class assumes that there will only be one
  58837. * pointer device and one keyboard.
  58838. */
  58839. export class DeviceInputSystem implements IDisposable {
  58840. /**
  58841. * Returns onDeviceConnected callback property
  58842. * @returns Callback with function to execute when a device is connected
  58843. */
  58844. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58845. /**
  58846. * Sets callback function when a device is connected and executes against all connected devices
  58847. * @param callback Function to execute when a device is connected
  58848. */
  58849. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58850. /**
  58851. * Callback to be triggered when a device is disconnected
  58852. */
  58853. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58854. /**
  58855. * Callback to be triggered when event driven input is updated
  58856. */
  58857. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58858. private _inputs;
  58859. private _gamepads;
  58860. private _keyboardActive;
  58861. private _pointerActive;
  58862. private _elementToAttachTo;
  58863. private _keyboardDownEvent;
  58864. private _keyboardUpEvent;
  58865. private _pointerMoveEvent;
  58866. private _pointerDownEvent;
  58867. private _pointerUpEvent;
  58868. private _gamepadConnectedEvent;
  58869. private _gamepadDisconnectedEvent;
  58870. private _onDeviceConnected;
  58871. private static _MAX_KEYCODES;
  58872. private static _MAX_POINTER_INPUTS;
  58873. private constructor();
  58874. /**
  58875. * Creates a new DeviceInputSystem instance
  58876. * @param engine Engine to pull input element from
  58877. * @returns The new instance
  58878. */
  58879. static Create(engine: Engine): DeviceInputSystem;
  58880. /**
  58881. * Checks for current device input value, given an id and input index
  58882. * @param deviceName Id of connected device
  58883. * @param inputIndex Index of device input
  58884. * @returns Current value of input
  58885. */
  58886. /**
  58887. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58888. * @param deviceType Enum specifiying device type
  58889. * @param deviceSlot "Slot" or index that device is referenced in
  58890. * @param inputIndex Id of input to be checked
  58891. * @returns Current value of input
  58892. */
  58893. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58894. /**
  58895. * Dispose of all the eventlisteners
  58896. */
  58897. dispose(): void;
  58898. /**
  58899. * Checks for existing connections to devices and register them, if necessary
  58900. * Currently handles gamepads and mouse
  58901. */
  58902. private _checkForConnectedDevices;
  58903. /**
  58904. * Add a gamepad to the DeviceInputSystem
  58905. * @param gamepad A single DOM Gamepad object
  58906. */
  58907. private _addGamePad;
  58908. /**
  58909. * Add pointer device to DeviceInputSystem
  58910. * @param deviceType Type of Pointer to add
  58911. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58912. * @param currentX Current X at point of adding
  58913. * @param currentY Current Y at point of adding
  58914. */
  58915. private _addPointerDevice;
  58916. /**
  58917. * Add device and inputs to device array
  58918. * @param deviceType Enum specifiying device type
  58919. * @param deviceSlot "Slot" or index that device is referenced in
  58920. * @param numberOfInputs Number of input entries to create for given device
  58921. */
  58922. private _registerDevice;
  58923. /**
  58924. * Given a specific device name, remove that device from the device map
  58925. * @param deviceType Enum specifiying device type
  58926. * @param deviceSlot "Slot" or index that device is referenced in
  58927. */
  58928. private _unregisterDevice;
  58929. /**
  58930. * Handle all actions that come from keyboard interaction
  58931. */
  58932. private _handleKeyActions;
  58933. /**
  58934. * Handle all actions that come from pointer interaction
  58935. */
  58936. private _handlePointerActions;
  58937. /**
  58938. * Handle all actions that come from gamepad interaction
  58939. */
  58940. private _handleGamepadActions;
  58941. /**
  58942. * Update all non-event based devices with each frame
  58943. * @param deviceType Enum specifiying device type
  58944. * @param deviceSlot "Slot" or index that device is referenced in
  58945. * @param inputIndex Id of input to be checked
  58946. */
  58947. private _updateDevice;
  58948. /**
  58949. * Gets DeviceType from the device name
  58950. * @param deviceName Name of Device from DeviceInputSystem
  58951. * @returns DeviceType enum value
  58952. */
  58953. private _getGamepadDeviceType;
  58954. }
  58955. }
  58956. declare module BABYLON {
  58957. /**
  58958. * Type to handle enforcement of inputs
  58959. */
  58960. 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;
  58961. }
  58962. declare module BABYLON {
  58963. /**
  58964. * Class that handles all input for a specific device
  58965. */
  58966. export class DeviceSource<T extends DeviceType> {
  58967. /** Type of device */
  58968. readonly deviceType: DeviceType;
  58969. /** "Slot" or index that device is referenced in */
  58970. readonly deviceSlot: number;
  58971. /**
  58972. * Observable to handle device input changes per device
  58973. */
  58974. readonly onInputChangedObservable: Observable<{
  58975. inputIndex: DeviceInput<T>;
  58976. previousState: Nullable<number>;
  58977. currentState: Nullable<number>;
  58978. }>;
  58979. private readonly _deviceInputSystem;
  58980. /**
  58981. * Default Constructor
  58982. * @param deviceInputSystem Reference to DeviceInputSystem
  58983. * @param deviceType Type of device
  58984. * @param deviceSlot "Slot" or index that device is referenced in
  58985. */
  58986. constructor(deviceInputSystem: DeviceInputSystem,
  58987. /** Type of device */
  58988. deviceType: DeviceType,
  58989. /** "Slot" or index that device is referenced in */
  58990. deviceSlot?: number);
  58991. /**
  58992. * Get input for specific input
  58993. * @param inputIndex index of specific input on device
  58994. * @returns Input value from DeviceInputSystem
  58995. */
  58996. getInput(inputIndex: DeviceInput<T>): number;
  58997. }
  58998. /**
  58999. * Class to keep track of devices
  59000. */
  59001. export class DeviceSourceManager implements IDisposable {
  59002. /**
  59003. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59004. */
  59005. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59006. /**
  59007. * Observable to be triggered when after a device is disconnected
  59008. */
  59009. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59010. private readonly _devices;
  59011. private readonly _firstDevice;
  59012. private readonly _deviceInputSystem;
  59013. /**
  59014. * Default Constructor
  59015. * @param engine engine to pull input element from
  59016. */
  59017. constructor(engine: Engine);
  59018. /**
  59019. * Gets a DeviceSource, given a type and slot
  59020. * @param deviceType Enum specifying device type
  59021. * @param deviceSlot "Slot" or index that device is referenced in
  59022. * @returns DeviceSource object
  59023. */
  59024. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59025. /**
  59026. * Gets an array of DeviceSource objects for a given device type
  59027. * @param deviceType Enum specifying device type
  59028. * @returns Array of DeviceSource objects
  59029. */
  59030. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59031. /**
  59032. * Returns a read-only list of all available devices
  59033. * @returns Read-only array with active devices
  59034. */
  59035. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59036. /**
  59037. * Dispose of DeviceInputSystem and other parts
  59038. */
  59039. dispose(): void;
  59040. /**
  59041. * Function to add device name to device list
  59042. * @param deviceType Enum specifying device type
  59043. * @param deviceSlot "Slot" or index that device is referenced in
  59044. */
  59045. private _addDevice;
  59046. /**
  59047. * Function to remove device name to device list
  59048. * @param deviceType Enum specifying device type
  59049. * @param deviceSlot "Slot" or index that device is referenced in
  59050. */
  59051. private _removeDevice;
  59052. /**
  59053. * Updates array storing first connected device of each type
  59054. * @param type Type of Device
  59055. */
  59056. private _updateFirstDevices;
  59057. }
  59058. }
  59059. declare module BABYLON {
  59060. /**
  59061. * Options to create the null engine
  59062. */
  59063. export class NullEngineOptions {
  59064. /**
  59065. * Render width (Default: 512)
  59066. */
  59067. renderWidth: number;
  59068. /**
  59069. * Render height (Default: 256)
  59070. */
  59071. renderHeight: number;
  59072. /**
  59073. * Texture size (Default: 512)
  59074. */
  59075. textureSize: number;
  59076. /**
  59077. * If delta time between frames should be constant
  59078. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59079. */
  59080. deterministicLockstep: boolean;
  59081. /**
  59082. * Maximum about of steps between frames (Default: 4)
  59083. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59084. */
  59085. lockstepMaxSteps: number;
  59086. /**
  59087. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59088. */
  59089. useHighPrecisionMatrix?: boolean;
  59090. }
  59091. /**
  59092. * The null engine class provides support for headless version of babylon.js.
  59093. * This can be used in server side scenario or for testing purposes
  59094. */
  59095. export class NullEngine extends Engine {
  59096. private _options;
  59097. /**
  59098. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59099. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59100. * @returns true if engine is in deterministic lock step mode
  59101. */
  59102. isDeterministicLockStep(): boolean;
  59103. /**
  59104. * Gets the max steps when engine is running in deterministic lock step
  59105. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59106. * @returns the max steps
  59107. */
  59108. getLockstepMaxSteps(): number;
  59109. /**
  59110. * Gets the current hardware scaling level.
  59111. * By default the hardware scaling level is computed from the window device ratio.
  59112. * 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.
  59113. * @returns a number indicating the current hardware scaling level
  59114. */
  59115. getHardwareScalingLevel(): number;
  59116. constructor(options?: NullEngineOptions);
  59117. /**
  59118. * Creates a vertex buffer
  59119. * @param vertices the data for the vertex buffer
  59120. * @returns the new WebGL static buffer
  59121. */
  59122. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59123. /**
  59124. * Creates a new index buffer
  59125. * @param indices defines the content of the index buffer
  59126. * @param updatable defines if the index buffer must be updatable
  59127. * @returns a new webGL buffer
  59128. */
  59129. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59130. /**
  59131. * Clear the current render buffer or the current render target (if any is set up)
  59132. * @param color defines the color to use
  59133. * @param backBuffer defines if the back buffer must be cleared
  59134. * @param depth defines if the depth buffer must be cleared
  59135. * @param stencil defines if the stencil buffer must be cleared
  59136. */
  59137. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59138. /**
  59139. * Gets the current render width
  59140. * @param useScreen defines if screen size must be used (or the current render target if any)
  59141. * @returns a number defining the current render width
  59142. */
  59143. getRenderWidth(useScreen?: boolean): number;
  59144. /**
  59145. * Gets the current render height
  59146. * @param useScreen defines if screen size must be used (or the current render target if any)
  59147. * @returns a number defining the current render height
  59148. */
  59149. getRenderHeight(useScreen?: boolean): number;
  59150. /**
  59151. * Set the WebGL's viewport
  59152. * @param viewport defines the viewport element to be used
  59153. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59154. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59155. */
  59156. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59157. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59158. /**
  59159. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59160. * @param pipelineContext defines the pipeline context to use
  59161. * @param uniformsNames defines the list of uniform names
  59162. * @returns an array of webGL uniform locations
  59163. */
  59164. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59165. /**
  59166. * Gets the lsit of active attributes for a given webGL program
  59167. * @param pipelineContext defines the pipeline context to use
  59168. * @param attributesNames defines the list of attribute names to get
  59169. * @returns an array of indices indicating the offset of each attribute
  59170. */
  59171. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59172. /**
  59173. * Binds an effect to the webGL context
  59174. * @param effect defines the effect to bind
  59175. */
  59176. bindSamplers(effect: Effect): void;
  59177. /**
  59178. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  59179. * @param effect defines the effect to activate
  59180. */
  59181. enableEffect(effect: Effect): void;
  59182. /**
  59183. * Set various states to the webGL context
  59184. * @param culling defines backface culling state
  59185. * @param zOffset defines the value to apply to zOffset (0 by default)
  59186. * @param force defines if states must be applied even if cache is up to date
  59187. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59188. */
  59189. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59190. /**
  59191. * Set the value of an uniform to an array of int32
  59192. * @param uniform defines the webGL uniform location where to store the value
  59193. * @param array defines the array of int32 to store
  59194. * @returns true if value was set
  59195. */
  59196. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59197. /**
  59198. * Set the value of an uniform to an array of int32 (stored as vec2)
  59199. * @param uniform defines the webGL uniform location where to store the value
  59200. * @param array defines the array of int32 to store
  59201. * @returns true if value was set
  59202. */
  59203. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59204. /**
  59205. * Set the value of an uniform to an array of int32 (stored as vec3)
  59206. * @param uniform defines the webGL uniform location where to store the value
  59207. * @param array defines the array of int32 to store
  59208. * @returns true if value was set
  59209. */
  59210. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59211. /**
  59212. * Set the value of an uniform to an array of int32 (stored as vec4)
  59213. * @param uniform defines the webGL uniform location where to store the value
  59214. * @param array defines the array of int32 to store
  59215. * @returns true if value was set
  59216. */
  59217. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59218. /**
  59219. * Set the value of an uniform to an array of float32
  59220. * @param uniform defines the webGL uniform location where to store the value
  59221. * @param array defines the array of float32 to store
  59222. * @returns true if value was set
  59223. */
  59224. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59225. /**
  59226. * Set the value of an uniform to an array of float32 (stored as vec2)
  59227. * @param uniform defines the webGL uniform location where to store the value
  59228. * @param array defines the array of float32 to store
  59229. * @returns true if value was set
  59230. */
  59231. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59232. /**
  59233. * Set the value of an uniform to an array of float32 (stored as vec3)
  59234. * @param uniform defines the webGL uniform location where to store the value
  59235. * @param array defines the array of float32 to store
  59236. * @returns true if value was set
  59237. */
  59238. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59239. /**
  59240. * Set the value of an uniform to an array of float32 (stored as vec4)
  59241. * @param uniform defines the webGL uniform location where to store the value
  59242. * @param array defines the array of float32 to store
  59243. * @returns true if value was set
  59244. */
  59245. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59246. /**
  59247. * Set the value of an uniform to an array of number
  59248. * @param uniform defines the webGL uniform location where to store the value
  59249. * @param array defines the array of number to store
  59250. * @returns true if value was set
  59251. */
  59252. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59253. /**
  59254. * Set the value of an uniform to an array of number (stored as vec2)
  59255. * @param uniform defines the webGL uniform location where to store the value
  59256. * @param array defines the array of number to store
  59257. * @returns true if value was set
  59258. */
  59259. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59260. /**
  59261. * Set the value of an uniform to an array of number (stored as vec3)
  59262. * @param uniform defines the webGL uniform location where to store the value
  59263. * @param array defines the array of number to store
  59264. * @returns true if value was set
  59265. */
  59266. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59267. /**
  59268. * Set the value of an uniform to an array of number (stored as vec4)
  59269. * @param uniform defines the webGL uniform location where to store the value
  59270. * @param array defines the array of number to store
  59271. * @returns true if value was set
  59272. */
  59273. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59274. /**
  59275. * Set the value of an uniform to an array of float32 (stored as matrices)
  59276. * @param uniform defines the webGL uniform location where to store the value
  59277. * @param matrices defines the array of float32 to store
  59278. * @returns true if value was set
  59279. */
  59280. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59281. /**
  59282. * Set the value of an uniform to a matrix (3x3)
  59283. * @param uniform defines the webGL uniform location where to store the value
  59284. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59285. * @returns true if value was set
  59286. */
  59287. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59288. /**
  59289. * Set the value of an uniform to a matrix (2x2)
  59290. * @param uniform defines the webGL uniform location where to store the value
  59291. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59292. * @returns true if value was set
  59293. */
  59294. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59295. /**
  59296. * Set the value of an uniform to a number (float)
  59297. * @param uniform defines the webGL uniform location where to store the value
  59298. * @param value defines the float number to store
  59299. * @returns true if value was set
  59300. */
  59301. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59302. /**
  59303. * Set the value of an uniform to a vec2
  59304. * @param uniform defines the webGL uniform location where to store the value
  59305. * @param x defines the 1st component of the value
  59306. * @param y defines the 2nd component of the value
  59307. * @returns true if value was set
  59308. */
  59309. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59310. /**
  59311. * Set the value of an uniform to a vec3
  59312. * @param uniform defines the webGL uniform location where to store the value
  59313. * @param x defines the 1st component of the value
  59314. * @param y defines the 2nd component of the value
  59315. * @param z defines the 3rd component of the value
  59316. * @returns true if value was set
  59317. */
  59318. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59319. /**
  59320. * Set the value of an uniform to a boolean
  59321. * @param uniform defines the webGL uniform location where to store the value
  59322. * @param bool defines the boolean to store
  59323. * @returns true if value was set
  59324. */
  59325. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59326. /**
  59327. * Set the value of an uniform to a vec4
  59328. * @param uniform defines the webGL uniform location where to store the value
  59329. * @param x defines the 1st component of the value
  59330. * @param y defines the 2nd component of the value
  59331. * @param z defines the 3rd component of the value
  59332. * @param w defines the 4th component of the value
  59333. * @returns true if value was set
  59334. */
  59335. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59336. /**
  59337. * Sets the current alpha mode
  59338. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59339. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59340. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59341. */
  59342. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59343. /**
  59344. * Bind webGl buffers directly to the webGL context
  59345. * @param vertexBuffers defines the vertex buffer to bind
  59346. * @param indexBuffer defines the index buffer to bind
  59347. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59348. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59349. * @param effect defines the effect associated with the vertex buffer
  59350. */
  59351. bindBuffers(vertexBuffers: {
  59352. [key: string]: VertexBuffer;
  59353. }, indexBuffer: DataBuffer, effect: Effect): void;
  59354. /**
  59355. * Force the entire cache to be cleared
  59356. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59357. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59358. */
  59359. wipeCaches(bruteForce?: boolean): void;
  59360. /**
  59361. * Send a draw order
  59362. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59363. * @param indexStart defines the starting index
  59364. * @param indexCount defines the number of index to draw
  59365. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59366. */
  59367. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59368. /**
  59369. * Draw a list of indexed primitives
  59370. * @param fillMode defines the primitive to use
  59371. * @param indexStart defines the starting index
  59372. * @param indexCount defines the number of index to draw
  59373. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59374. */
  59375. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59376. /**
  59377. * Draw a list of unindexed primitives
  59378. * @param fillMode defines the primitive to use
  59379. * @param verticesStart defines the index of first vertex to draw
  59380. * @param verticesCount defines the count of vertices to draw
  59381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59382. */
  59383. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59384. /** @hidden */
  59385. protected _createTexture(): WebGLTexture;
  59386. /** @hidden */
  59387. _releaseTexture(texture: InternalTexture): void;
  59388. /**
  59389. * Usually called from Texture.ts.
  59390. * Passed information to create a WebGLTexture
  59391. * @param urlArg defines a value which contains one of the following:
  59392. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59393. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59394. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59395. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59396. * @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)
  59397. * @param scene needed for loading to the correct scene
  59398. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59399. * @param onLoad optional callback to be called upon successful completion
  59400. * @param onError optional callback to be called upon failure
  59401. * @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
  59402. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59403. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59404. * @param forcedExtension defines the extension to use to pick the right loader
  59405. * @param mimeType defines an optional mime type
  59406. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59407. */
  59408. 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;
  59409. /**
  59410. * Creates a new render target texture
  59411. * @param size defines the size of the texture
  59412. * @param options defines the options used to create the texture
  59413. * @returns a new render target texture stored in an InternalTexture
  59414. */
  59415. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59416. /**
  59417. * Update the sampling mode of a given texture
  59418. * @param samplingMode defines the required sampling mode
  59419. * @param texture defines the texture to update
  59420. */
  59421. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59422. /**
  59423. * Binds the frame buffer to the specified texture.
  59424. * @param texture The texture to render to or null for the default canvas
  59425. * @param faceIndex The face of the texture to render to in case of cube texture
  59426. * @param requiredWidth The width of the target to render to
  59427. * @param requiredHeight The height of the target to render to
  59428. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59429. * @param lodLevel defines le lod level to bind to the frame buffer
  59430. */
  59431. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59432. /**
  59433. * Unbind the current render target texture from the webGL context
  59434. * @param texture defines the render target texture to unbind
  59435. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59436. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59437. */
  59438. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59439. /**
  59440. * Creates a dynamic vertex buffer
  59441. * @param vertices the data for the dynamic vertex buffer
  59442. * @returns the new WebGL dynamic buffer
  59443. */
  59444. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59445. /**
  59446. * Update the content of a dynamic texture
  59447. * @param texture defines the texture to update
  59448. * @param canvas defines the canvas containing the source
  59449. * @param invertY defines if data must be stored with Y axis inverted
  59450. * @param premulAlpha defines if alpha is stored as premultiplied
  59451. * @param format defines the format of the data
  59452. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59453. */
  59454. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59455. /**
  59456. * Gets a boolean indicating if all created effects are ready
  59457. * @returns true if all effects are ready
  59458. */
  59459. areAllEffectsReady(): boolean;
  59460. /**
  59461. * @hidden
  59462. * Get the current error code of the webGL context
  59463. * @returns the error code
  59464. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59465. */
  59466. getError(): number;
  59467. /** @hidden */
  59468. _getUnpackAlignement(): number;
  59469. /** @hidden */
  59470. _unpackFlipY(value: boolean): void;
  59471. /**
  59472. * Update a dynamic index buffer
  59473. * @param indexBuffer defines the target index buffer
  59474. * @param indices defines the data to update
  59475. * @param offset defines the offset in the target index buffer where update should start
  59476. */
  59477. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59478. /**
  59479. * Updates a dynamic vertex buffer.
  59480. * @param vertexBuffer the vertex buffer to update
  59481. * @param vertices the data used to update the vertex buffer
  59482. * @param byteOffset the byte offset of the data (optional)
  59483. * @param byteLength the byte length of the data (optional)
  59484. */
  59485. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59486. /** @hidden */
  59487. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59488. /** @hidden */
  59489. _bindTexture(channel: number, texture: InternalTexture): void;
  59490. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59491. /**
  59492. * 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
  59493. */
  59494. releaseEffects(): void;
  59495. displayLoadingUI(): void;
  59496. hideLoadingUI(): void;
  59497. /** @hidden */
  59498. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59499. /** @hidden */
  59500. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59501. /** @hidden */
  59502. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59503. /** @hidden */
  59504. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59505. }
  59506. }
  59507. declare module BABYLON {
  59508. /** @hidden */
  59509. export class _OcclusionDataStorage {
  59510. /** @hidden */
  59511. occlusionInternalRetryCounter: number;
  59512. /** @hidden */
  59513. isOcclusionQueryInProgress: boolean;
  59514. /** @hidden */
  59515. isOccluded: boolean;
  59516. /** @hidden */
  59517. occlusionRetryCount: number;
  59518. /** @hidden */
  59519. occlusionType: number;
  59520. /** @hidden */
  59521. occlusionQueryAlgorithmType: number;
  59522. }
  59523. interface Engine {
  59524. /**
  59525. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59526. * @return the new query
  59527. */
  59528. createQuery(): WebGLQuery;
  59529. /**
  59530. * Delete and release a webGL query
  59531. * @param query defines the query to delete
  59532. * @return the current engine
  59533. */
  59534. deleteQuery(query: WebGLQuery): Engine;
  59535. /**
  59536. * Check if a given query has resolved and got its value
  59537. * @param query defines the query to check
  59538. * @returns true if the query got its value
  59539. */
  59540. isQueryResultAvailable(query: WebGLQuery): boolean;
  59541. /**
  59542. * Gets the value of a given query
  59543. * @param query defines the query to check
  59544. * @returns the value of the query
  59545. */
  59546. getQueryResult(query: WebGLQuery): number;
  59547. /**
  59548. * Initiates an occlusion query
  59549. * @param algorithmType defines the algorithm to use
  59550. * @param query defines the query to use
  59551. * @returns the current engine
  59552. * @see https://doc.babylonjs.com/features/occlusionquery
  59553. */
  59554. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59555. /**
  59556. * Ends an occlusion query
  59557. * @see https://doc.babylonjs.com/features/occlusionquery
  59558. * @param algorithmType defines the algorithm to use
  59559. * @returns the current engine
  59560. */
  59561. endOcclusionQuery(algorithmType: number): Engine;
  59562. /**
  59563. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59564. * Please note that only one query can be issued at a time
  59565. * @returns a time token used to track the time span
  59566. */
  59567. startTimeQuery(): Nullable<_TimeToken>;
  59568. /**
  59569. * Ends a time query
  59570. * @param token defines the token used to measure the time span
  59571. * @returns the time spent (in ns)
  59572. */
  59573. endTimeQuery(token: _TimeToken): int;
  59574. /** @hidden */
  59575. _currentNonTimestampToken: Nullable<_TimeToken>;
  59576. /** @hidden */
  59577. _createTimeQuery(): WebGLQuery;
  59578. /** @hidden */
  59579. _deleteTimeQuery(query: WebGLQuery): void;
  59580. /** @hidden */
  59581. _getGlAlgorithmType(algorithmType: number): number;
  59582. /** @hidden */
  59583. _getTimeQueryResult(query: WebGLQuery): any;
  59584. /** @hidden */
  59585. _getTimeQueryAvailability(query: WebGLQuery): any;
  59586. }
  59587. interface AbstractMesh {
  59588. /**
  59589. * Backing filed
  59590. * @hidden
  59591. */
  59592. __occlusionDataStorage: _OcclusionDataStorage;
  59593. /**
  59594. * Access property
  59595. * @hidden
  59596. */
  59597. _occlusionDataStorage: _OcclusionDataStorage;
  59598. /**
  59599. * 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.
  59600. * The default value is -1 which means don't break the query and wait till the result
  59601. * @see https://doc.babylonjs.com/features/occlusionquery
  59602. */
  59603. occlusionRetryCount: number;
  59604. /**
  59605. * 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:
  59606. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59607. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59608. * * 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.
  59609. * @see https://doc.babylonjs.com/features/occlusionquery
  59610. */
  59611. occlusionType: number;
  59612. /**
  59613. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59614. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59615. * * 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.
  59616. * @see https://doc.babylonjs.com/features/occlusionquery
  59617. */
  59618. occlusionQueryAlgorithmType: number;
  59619. /**
  59620. * 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
  59621. * @see https://doc.babylonjs.com/features/occlusionquery
  59622. */
  59623. isOccluded: boolean;
  59624. /**
  59625. * Flag to check the progress status of the query
  59626. * @see https://doc.babylonjs.com/features/occlusionquery
  59627. */
  59628. isOcclusionQueryInProgress: boolean;
  59629. }
  59630. }
  59631. declare module BABYLON {
  59632. /** @hidden */
  59633. export var _forceTransformFeedbackToBundle: boolean;
  59634. interface Engine {
  59635. /**
  59636. * Creates a webGL transform feedback object
  59637. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59638. * @returns the webGL transform feedback object
  59639. */
  59640. createTransformFeedback(): WebGLTransformFeedback;
  59641. /**
  59642. * Delete a webGL transform feedback object
  59643. * @param value defines the webGL transform feedback object to delete
  59644. */
  59645. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59646. /**
  59647. * Bind a webGL transform feedback object to the webgl context
  59648. * @param value defines the webGL transform feedback object to bind
  59649. */
  59650. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59651. /**
  59652. * Begins a transform feedback operation
  59653. * @param usePoints defines if points or triangles must be used
  59654. */
  59655. beginTransformFeedback(usePoints: boolean): void;
  59656. /**
  59657. * Ends a transform feedback operation
  59658. */
  59659. endTransformFeedback(): void;
  59660. /**
  59661. * Specify the varyings to use with transform feedback
  59662. * @param program defines the associated webGL program
  59663. * @param value defines the list of strings representing the varying names
  59664. */
  59665. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59666. /**
  59667. * Bind a webGL buffer for a transform feedback operation
  59668. * @param value defines the webGL buffer to bind
  59669. */
  59670. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59671. }
  59672. }
  59673. declare module BABYLON {
  59674. /**
  59675. * Class used to define an additional view for the engine
  59676. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59677. */
  59678. export class EngineView {
  59679. /** Defines the canvas where to render the view */
  59680. target: HTMLCanvasElement;
  59681. /** Defines an optional camera used to render the view (will use active camera else) */
  59682. camera?: Camera;
  59683. }
  59684. interface Engine {
  59685. /**
  59686. * Gets or sets the HTML element to use for attaching events
  59687. */
  59688. inputElement: Nullable<HTMLElement>;
  59689. /**
  59690. * Gets the current engine view
  59691. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59692. */
  59693. activeView: Nullable<EngineView>;
  59694. /** Gets or sets the list of views */
  59695. views: EngineView[];
  59696. /**
  59697. * Register a new child canvas
  59698. * @param canvas defines the canvas to register
  59699. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59700. * @returns the associated view
  59701. */
  59702. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59703. /**
  59704. * Remove a registered child canvas
  59705. * @param canvas defines the canvas to remove
  59706. * @returns the current engine
  59707. */
  59708. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59709. }
  59710. }
  59711. declare module BABYLON {
  59712. interface Engine {
  59713. /** @hidden */
  59714. _excludedCompressedTextures: string[];
  59715. /** @hidden */
  59716. _textureFormatInUse: string;
  59717. /**
  59718. * Gets the list of texture formats supported
  59719. */
  59720. readonly texturesSupported: Array<string>;
  59721. /**
  59722. * Gets the texture format in use
  59723. */
  59724. readonly textureFormatInUse: Nullable<string>;
  59725. /**
  59726. * Set the compressed texture extensions or file names to skip.
  59727. *
  59728. * @param skippedFiles defines the list of those texture files you want to skip
  59729. * Example: [".dds", ".env", "myfile.png"]
  59730. */
  59731. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59732. /**
  59733. * Set the compressed texture format to use, based on the formats you have, and the formats
  59734. * supported by the hardware / browser.
  59735. *
  59736. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59737. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59738. * to API arguments needed to compressed textures. This puts the burden on the container
  59739. * generator to house the arcane code for determining these for current & future formats.
  59740. *
  59741. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59742. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59743. *
  59744. * Note: The result of this call is not taken into account when a texture is base64.
  59745. *
  59746. * @param formatsAvailable defines the list of those format families you have created
  59747. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59748. *
  59749. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59750. * @returns The extension selected.
  59751. */
  59752. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59753. }
  59754. }
  59755. declare module BABYLON {
  59756. /** @hidden */
  59757. export var rgbdEncodePixelShader: {
  59758. name: string;
  59759. shader: string;
  59760. };
  59761. }
  59762. declare module BABYLON {
  59763. /**
  59764. * Raw texture data and descriptor sufficient for WebGL texture upload
  59765. */
  59766. export interface EnvironmentTextureInfo {
  59767. /**
  59768. * Version of the environment map
  59769. */
  59770. version: number;
  59771. /**
  59772. * Width of image
  59773. */
  59774. width: number;
  59775. /**
  59776. * Irradiance information stored in the file.
  59777. */
  59778. irradiance: any;
  59779. /**
  59780. * Specular information stored in the file.
  59781. */
  59782. specular: any;
  59783. }
  59784. /**
  59785. * Defines One Image in the file. It requires only the position in the file
  59786. * as well as the length.
  59787. */
  59788. interface BufferImageData {
  59789. /**
  59790. * Length of the image data.
  59791. */
  59792. length: number;
  59793. /**
  59794. * Position of the data from the null terminator delimiting the end of the JSON.
  59795. */
  59796. position: number;
  59797. }
  59798. /**
  59799. * Defines the specular data enclosed in the file.
  59800. * This corresponds to the version 1 of the data.
  59801. */
  59802. export interface EnvironmentTextureSpecularInfoV1 {
  59803. /**
  59804. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59805. */
  59806. specularDataPosition?: number;
  59807. /**
  59808. * This contains all the images data needed to reconstruct the cubemap.
  59809. */
  59810. mipmaps: Array<BufferImageData>;
  59811. /**
  59812. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59813. */
  59814. lodGenerationScale: number;
  59815. }
  59816. /**
  59817. * Sets of helpers addressing the serialization and deserialization of environment texture
  59818. * stored in a BabylonJS env file.
  59819. * Those files are usually stored as .env files.
  59820. */
  59821. export class EnvironmentTextureTools {
  59822. /**
  59823. * Magic number identifying the env file.
  59824. */
  59825. private static _MagicBytes;
  59826. /**
  59827. * Gets the environment info from an env file.
  59828. * @param data The array buffer containing the .env bytes.
  59829. * @returns the environment file info (the json header) if successfully parsed.
  59830. */
  59831. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59832. /**
  59833. * Creates an environment texture from a loaded cube texture.
  59834. * @param texture defines the cube texture to convert in env file
  59835. * @return a promise containing the environment data if succesfull.
  59836. */
  59837. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59838. /**
  59839. * Creates a JSON representation of the spherical data.
  59840. * @param texture defines the texture containing the polynomials
  59841. * @return the JSON representation of the spherical info
  59842. */
  59843. private static _CreateEnvTextureIrradiance;
  59844. /**
  59845. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59846. * @param data the image data
  59847. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59848. * @return the views described by info providing access to the underlying buffer
  59849. */
  59850. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59851. /**
  59852. * Uploads the texture info contained in the env file to the GPU.
  59853. * @param texture defines the internal texture to upload to
  59854. * @param data defines the data to load
  59855. * @param info defines the texture info retrieved through the GetEnvInfo method
  59856. * @returns a promise
  59857. */
  59858. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59859. private static _OnImageReadyAsync;
  59860. /**
  59861. * Uploads the levels of image data to the GPU.
  59862. * @param texture defines the internal texture to upload to
  59863. * @param imageData defines the array buffer views of image data [mipmap][face]
  59864. * @returns a promise
  59865. */
  59866. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59867. /**
  59868. * Uploads spherical polynomials information to the texture.
  59869. * @param texture defines the texture we are trying to upload the information to
  59870. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59871. */
  59872. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59873. /** @hidden */
  59874. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59875. }
  59876. }
  59877. declare module BABYLON {
  59878. /**
  59879. * Container for accessors for natively-stored mesh data buffers.
  59880. */
  59881. class NativeDataBuffer extends DataBuffer {
  59882. /**
  59883. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59884. */
  59885. nativeIndexBuffer?: any;
  59886. /**
  59887. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59888. */
  59889. nativeVertexBuffer?: any;
  59890. }
  59891. /** @hidden */
  59892. class NativeTexture extends InternalTexture {
  59893. getInternalTexture(): InternalTexture;
  59894. getViewCount(): number;
  59895. }
  59896. /** @hidden */
  59897. export class NativeEngine extends Engine {
  59898. private readonly _native;
  59899. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59900. private readonly INVALID_HANDLE;
  59901. private _boundBuffersVertexArray;
  59902. private _currentDepthTest;
  59903. getHardwareScalingLevel(): number;
  59904. constructor();
  59905. dispose(): void;
  59906. /**
  59907. * Can be used to override the current requestAnimationFrame requester.
  59908. * @hidden
  59909. */
  59910. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59911. /**
  59912. * Override default engine behavior.
  59913. * @param color
  59914. * @param backBuffer
  59915. * @param depth
  59916. * @param stencil
  59917. */
  59918. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59919. /**
  59920. * Gets host document
  59921. * @returns the host document object
  59922. */
  59923. getHostDocument(): Nullable<Document>;
  59924. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59925. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59926. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59927. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59928. [key: string]: VertexBuffer;
  59929. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59930. bindBuffers(vertexBuffers: {
  59931. [key: string]: VertexBuffer;
  59932. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59933. recordVertexArrayObject(vertexBuffers: {
  59934. [key: string]: VertexBuffer;
  59935. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59936. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59937. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59938. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59939. /**
  59940. * Draw a list of indexed primitives
  59941. * @param fillMode defines the primitive to use
  59942. * @param indexStart defines the starting index
  59943. * @param indexCount defines the number of index to draw
  59944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59945. */
  59946. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59947. /**
  59948. * Draw a list of unindexed primitives
  59949. * @param fillMode defines the primitive to use
  59950. * @param verticesStart defines the index of first vertex to draw
  59951. * @param verticesCount defines the count of vertices to draw
  59952. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59953. */
  59954. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59955. createPipelineContext(): IPipelineContext;
  59956. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59957. /** @hidden */
  59958. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59959. /** @hidden */
  59960. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59961. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59962. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59963. protected _setProgram(program: WebGLProgram): void;
  59964. _releaseEffect(effect: Effect): void;
  59965. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59966. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59967. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59968. bindSamplers(effect: Effect): void;
  59969. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  59970. getRenderWidth(useScreen?: boolean): number;
  59971. getRenderHeight(useScreen?: boolean): number;
  59972. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59973. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59974. /**
  59975. * Set the z offset to apply to current rendering
  59976. * @param value defines the offset to apply
  59977. */
  59978. setZOffset(value: number): void;
  59979. /**
  59980. * Gets the current value of the zOffset
  59981. * @returns the current zOffset state
  59982. */
  59983. getZOffset(): number;
  59984. /**
  59985. * Enable or disable depth buffering
  59986. * @param enable defines the state to set
  59987. */
  59988. setDepthBuffer(enable: boolean): void;
  59989. /**
  59990. * Gets a boolean indicating if depth writing is enabled
  59991. * @returns the current depth writing state
  59992. */
  59993. getDepthWrite(): boolean;
  59994. setDepthFunctionToGreater(): void;
  59995. setDepthFunctionToGreaterOrEqual(): void;
  59996. setDepthFunctionToLess(): void;
  59997. setDepthFunctionToLessOrEqual(): void;
  59998. /**
  59999. * Enable or disable depth writing
  60000. * @param enable defines the state to set
  60001. */
  60002. setDepthWrite(enable: boolean): void;
  60003. /**
  60004. * Enable or disable color writing
  60005. * @param enable defines the state to set
  60006. */
  60007. setColorWrite(enable: boolean): void;
  60008. /**
  60009. * Gets a boolean indicating if color writing is enabled
  60010. * @returns the current color writing state
  60011. */
  60012. getColorWrite(): boolean;
  60013. /**
  60014. * Sets alpha constants used by some alpha blending modes
  60015. * @param r defines the red component
  60016. * @param g defines the green component
  60017. * @param b defines the blue component
  60018. * @param a defines the alpha component
  60019. */
  60020. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60021. /**
  60022. * Sets the current alpha mode
  60023. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60024. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60025. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60026. */
  60027. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60028. /**
  60029. * Gets the current alpha mode
  60030. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60031. * @returns the current alpha mode
  60032. */
  60033. getAlphaMode(): number;
  60034. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60035. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60036. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60037. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60038. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60039. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60040. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60041. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60042. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60043. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60044. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60045. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60046. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60047. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60048. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60049. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60050. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60051. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60052. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60053. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60054. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60055. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60056. wipeCaches(bruteForce?: boolean): void;
  60057. protected _createTexture(): WebGLTexture;
  60058. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60059. /**
  60060. * Update the content of a dynamic texture
  60061. * @param texture defines the texture to update
  60062. * @param canvas defines the canvas containing the source
  60063. * @param invertY defines if data must be stored with Y axis inverted
  60064. * @param premulAlpha defines if alpha is stored as premultiplied
  60065. * @param format defines the format of the data
  60066. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60067. */
  60068. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60069. /**
  60070. * Usually called from Texture.ts.
  60071. * Passed information to create a WebGLTexture
  60072. * @param url defines a value which contains one of the following:
  60073. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60074. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60075. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60076. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60077. * @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)
  60078. * @param scene needed for loading to the correct scene
  60079. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60080. * @param onLoad optional callback to be called upon successful completion
  60081. * @param onError optional callback to be called upon failure
  60082. * @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
  60083. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60084. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60085. * @param forcedExtension defines the extension to use to pick the right loader
  60086. * @param mimeType defines an optional mime type
  60087. * @param loaderOptions options to be passed to the loader
  60088. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60089. */
  60090. 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;
  60091. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60092. _releaseFramebufferObjects(texture: InternalTexture): void;
  60093. /**
  60094. * Creates a cube texture
  60095. * @param rootUrl defines the url where the files to load is located
  60096. * @param scene defines the current scene
  60097. * @param files defines the list of files to load (1 per face)
  60098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60099. * @param onLoad defines an optional callback raised when the texture is loaded
  60100. * @param onError defines an optional callback raised if there is an issue to load the texture
  60101. * @param format defines the format of the data
  60102. * @param forcedExtension defines the extension to use to pick the right loader
  60103. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60104. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60105. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60106. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60107. * @returns the cube texture as an InternalTexture
  60108. */
  60109. 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;
  60110. createRenderTargetTexture(size: number | {
  60111. width: number;
  60112. height: number;
  60113. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60114. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60115. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60116. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60117. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60118. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60119. /**
  60120. * Updates a dynamic vertex buffer.
  60121. * @param vertexBuffer the vertex buffer to update
  60122. * @param data the data used to update the vertex buffer
  60123. * @param byteOffset the byte offset of the data (optional)
  60124. * @param byteLength the byte length of the data (optional)
  60125. */
  60126. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60127. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60128. private _updateAnisotropicLevel;
  60129. private _getAddressMode;
  60130. /** @hidden */
  60131. _bindTexture(channel: number, texture: InternalTexture): void;
  60132. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60133. releaseEffects(): void;
  60134. /** @hidden */
  60135. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60136. /** @hidden */
  60137. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60138. /** @hidden */
  60139. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60140. /** @hidden */
  60141. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60142. private _getNativeSamplingMode;
  60143. private _getNativeTextureFormat;
  60144. private _getNativeAlphaMode;
  60145. private _getNativeAttribType;
  60146. }
  60147. }
  60148. declare module BABYLON {
  60149. /**
  60150. * Helper class to create the best engine depending on the current hardware
  60151. */
  60152. export class EngineFactory {
  60153. /**
  60154. * Creates an engine based on the capabilities of the underlying hardware
  60155. * @param canvas Defines the canvas to use to display the result
  60156. * @param options Defines the options passed to the engine to create the context dependencies
  60157. * @returns a promise that resolves with the created engine
  60158. */
  60159. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60160. }
  60161. }
  60162. declare module BABYLON {
  60163. /**
  60164. * Gather the list of clipboard event types as constants.
  60165. */
  60166. export class ClipboardEventTypes {
  60167. /**
  60168. * The clipboard event is fired when a copy command is active (pressed).
  60169. */
  60170. static readonly COPY: number;
  60171. /**
  60172. * The clipboard event is fired when a cut command is active (pressed).
  60173. */
  60174. static readonly CUT: number;
  60175. /**
  60176. * The clipboard event is fired when a paste command is active (pressed).
  60177. */
  60178. static readonly PASTE: number;
  60179. }
  60180. /**
  60181. * This class is used to store clipboard related info for the onClipboardObservable event.
  60182. */
  60183. export class ClipboardInfo {
  60184. /**
  60185. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60186. */
  60187. type: number;
  60188. /**
  60189. * Defines the related dom event
  60190. */
  60191. event: ClipboardEvent;
  60192. /**
  60193. *Creates an instance of ClipboardInfo.
  60194. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60195. * @param event Defines the related dom event
  60196. */
  60197. constructor(
  60198. /**
  60199. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60200. */
  60201. type: number,
  60202. /**
  60203. * Defines the related dom event
  60204. */
  60205. event: ClipboardEvent);
  60206. /**
  60207. * Get the clipboard event's type from the keycode.
  60208. * @param keyCode Defines the keyCode for the current keyboard event.
  60209. * @return {number}
  60210. */
  60211. static GetTypeFromCharacter(keyCode: number): number;
  60212. }
  60213. }
  60214. declare module BABYLON {
  60215. /**
  60216. * Google Daydream controller
  60217. */
  60218. export class DaydreamController extends WebVRController {
  60219. /**
  60220. * Base Url for the controller model.
  60221. */
  60222. static MODEL_BASE_URL: string;
  60223. /**
  60224. * File name for the controller model.
  60225. */
  60226. static MODEL_FILENAME: string;
  60227. /**
  60228. * Gamepad Id prefix used to identify Daydream Controller.
  60229. */
  60230. static readonly GAMEPAD_ID_PREFIX: string;
  60231. /**
  60232. * Creates a new DaydreamController from a gamepad
  60233. * @param vrGamepad the gamepad that the controller should be created from
  60234. */
  60235. constructor(vrGamepad: any);
  60236. /**
  60237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60238. * @param scene scene in which to add meshes
  60239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60240. */
  60241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60242. /**
  60243. * Called once for each button that changed state since the last frame
  60244. * @param buttonIdx Which button index changed
  60245. * @param state New state of the button
  60246. * @param changes Which properties on the state changed since last frame
  60247. */
  60248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60249. }
  60250. }
  60251. declare module BABYLON {
  60252. /**
  60253. * Gear VR Controller
  60254. */
  60255. export class GearVRController extends WebVRController {
  60256. /**
  60257. * Base Url for the controller model.
  60258. */
  60259. static MODEL_BASE_URL: string;
  60260. /**
  60261. * File name for the controller model.
  60262. */
  60263. static MODEL_FILENAME: string;
  60264. /**
  60265. * Gamepad Id prefix used to identify this controller.
  60266. */
  60267. static readonly GAMEPAD_ID_PREFIX: string;
  60268. private readonly _buttonIndexToObservableNameMap;
  60269. /**
  60270. * Creates a new GearVRController from a gamepad
  60271. * @param vrGamepad the gamepad that the controller should be created from
  60272. */
  60273. constructor(vrGamepad: any);
  60274. /**
  60275. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60276. * @param scene scene in which to add meshes
  60277. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60278. */
  60279. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60280. /**
  60281. * Called once for each button that changed state since the last frame
  60282. * @param buttonIdx Which button index changed
  60283. * @param state New state of the button
  60284. * @param changes Which properties on the state changed since last frame
  60285. */
  60286. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60287. }
  60288. }
  60289. declare module BABYLON {
  60290. /**
  60291. * Generic Controller
  60292. */
  60293. export class GenericController extends WebVRController {
  60294. /**
  60295. * Base Url for the controller model.
  60296. */
  60297. static readonly MODEL_BASE_URL: string;
  60298. /**
  60299. * File name for the controller model.
  60300. */
  60301. static readonly MODEL_FILENAME: string;
  60302. /**
  60303. * Creates a new GenericController from a gamepad
  60304. * @param vrGamepad the gamepad that the controller should be created from
  60305. */
  60306. constructor(vrGamepad: any);
  60307. /**
  60308. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60309. * @param scene scene in which to add meshes
  60310. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60311. */
  60312. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60313. /**
  60314. * Called once for each button that changed state since the last frame
  60315. * @param buttonIdx Which button index changed
  60316. * @param state New state of the button
  60317. * @param changes Which properties on the state changed since last frame
  60318. */
  60319. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60320. }
  60321. }
  60322. declare module BABYLON {
  60323. /**
  60324. * Oculus Touch Controller
  60325. */
  60326. export class OculusTouchController extends WebVRController {
  60327. /**
  60328. * Base Url for the controller model.
  60329. */
  60330. static MODEL_BASE_URL: string;
  60331. /**
  60332. * File name for the left controller model.
  60333. */
  60334. static MODEL_LEFT_FILENAME: string;
  60335. /**
  60336. * File name for the right controller model.
  60337. */
  60338. static MODEL_RIGHT_FILENAME: string;
  60339. /**
  60340. * Base Url for the Quest controller model.
  60341. */
  60342. static QUEST_MODEL_BASE_URL: string;
  60343. /**
  60344. * @hidden
  60345. * If the controllers are running on a device that needs the updated Quest controller models
  60346. */
  60347. static _IsQuest: boolean;
  60348. /**
  60349. * Fired when the secondary trigger on this controller is modified
  60350. */
  60351. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60352. /**
  60353. * Fired when the thumb rest on this controller is modified
  60354. */
  60355. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60356. /**
  60357. * Creates a new OculusTouchController from a gamepad
  60358. * @param vrGamepad the gamepad that the controller should be created from
  60359. */
  60360. constructor(vrGamepad: any);
  60361. /**
  60362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60363. * @param scene scene in which to add meshes
  60364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60365. */
  60366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60367. /**
  60368. * Fired when the A button on this controller is modified
  60369. */
  60370. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60371. /**
  60372. * Fired when the B button on this controller is modified
  60373. */
  60374. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60375. /**
  60376. * Fired when the X button on this controller is modified
  60377. */
  60378. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60379. /**
  60380. * Fired when the Y button on this controller is modified
  60381. */
  60382. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60383. /**
  60384. * Called once for each button that changed state since the last frame
  60385. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60386. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60387. * 2) secondary trigger (same)
  60388. * 3) A (right) X (left), touch, pressed = value
  60389. * 4) B / Y
  60390. * 5) thumb rest
  60391. * @param buttonIdx Which button index changed
  60392. * @param state New state of the button
  60393. * @param changes Which properties on the state changed since last frame
  60394. */
  60395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60396. }
  60397. }
  60398. declare module BABYLON {
  60399. /**
  60400. * Vive Controller
  60401. */
  60402. export class ViveController extends WebVRController {
  60403. /**
  60404. * Base Url for the controller model.
  60405. */
  60406. static MODEL_BASE_URL: string;
  60407. /**
  60408. * File name for the controller model.
  60409. */
  60410. static MODEL_FILENAME: string;
  60411. /**
  60412. * Creates a new ViveController from a gamepad
  60413. * @param vrGamepad the gamepad that the controller should be created from
  60414. */
  60415. constructor(vrGamepad: any);
  60416. /**
  60417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60418. * @param scene scene in which to add meshes
  60419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60420. */
  60421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60422. /**
  60423. * Fired when the left button on this controller is modified
  60424. */
  60425. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60426. /**
  60427. * Fired when the right button on this controller is modified
  60428. */
  60429. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60430. /**
  60431. * Fired when the menu button on this controller is modified
  60432. */
  60433. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60434. /**
  60435. * Called once for each button that changed state since the last frame
  60436. * Vive mapping:
  60437. * 0: touchpad
  60438. * 1: trigger
  60439. * 2: left AND right buttons
  60440. * 3: menu button
  60441. * @param buttonIdx Which button index changed
  60442. * @param state New state of the button
  60443. * @param changes Which properties on the state changed since last frame
  60444. */
  60445. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60446. }
  60447. }
  60448. declare module BABYLON {
  60449. /**
  60450. * Defines the WindowsMotionController object that the state of the windows motion controller
  60451. */
  60452. export class WindowsMotionController extends WebVRController {
  60453. /**
  60454. * The base url used to load the left and right controller models
  60455. */
  60456. static MODEL_BASE_URL: string;
  60457. /**
  60458. * The name of the left controller model file
  60459. */
  60460. static MODEL_LEFT_FILENAME: string;
  60461. /**
  60462. * The name of the right controller model file
  60463. */
  60464. static MODEL_RIGHT_FILENAME: string;
  60465. /**
  60466. * The controller name prefix for this controller type
  60467. */
  60468. static readonly GAMEPAD_ID_PREFIX: string;
  60469. /**
  60470. * The controller id pattern for this controller type
  60471. */
  60472. private static readonly GAMEPAD_ID_PATTERN;
  60473. private _loadedMeshInfo;
  60474. protected readonly _mapping: {
  60475. buttons: string[];
  60476. buttonMeshNames: {
  60477. trigger: string;
  60478. menu: string;
  60479. grip: string;
  60480. thumbstick: string;
  60481. trackpad: string;
  60482. };
  60483. buttonObservableNames: {
  60484. trigger: string;
  60485. menu: string;
  60486. grip: string;
  60487. thumbstick: string;
  60488. trackpad: string;
  60489. };
  60490. axisMeshNames: string[];
  60491. pointingPoseMeshName: string;
  60492. };
  60493. /**
  60494. * Fired when the trackpad on this controller is clicked
  60495. */
  60496. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60497. /**
  60498. * Fired when the trackpad on this controller is modified
  60499. */
  60500. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60501. /**
  60502. * The current x and y values of this controller's trackpad
  60503. */
  60504. trackpad: StickValues;
  60505. /**
  60506. * Creates a new WindowsMotionController from a gamepad
  60507. * @param vrGamepad the gamepad that the controller should be created from
  60508. */
  60509. constructor(vrGamepad: any);
  60510. /**
  60511. * Fired when the trigger on this controller is modified
  60512. */
  60513. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60514. /**
  60515. * Fired when the menu button on this controller is modified
  60516. */
  60517. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60518. /**
  60519. * Fired when the grip button on this controller is modified
  60520. */
  60521. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60522. /**
  60523. * Fired when the thumbstick button on this controller is modified
  60524. */
  60525. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60526. /**
  60527. * Fired when the touchpad button on this controller is modified
  60528. */
  60529. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60530. /**
  60531. * Fired when the touchpad values on this controller are modified
  60532. */
  60533. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60534. protected _updateTrackpad(): void;
  60535. /**
  60536. * Called once per frame by the engine.
  60537. */
  60538. update(): void;
  60539. /**
  60540. * Called once for each button that changed state since the last frame
  60541. * @param buttonIdx Which button index changed
  60542. * @param state New state of the button
  60543. * @param changes Which properties on the state changed since last frame
  60544. */
  60545. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60546. /**
  60547. * Moves the buttons on the controller mesh based on their current state
  60548. * @param buttonName the name of the button to move
  60549. * @param buttonValue the value of the button which determines the buttons new position
  60550. */
  60551. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60552. /**
  60553. * Moves the axis on the controller mesh based on its current state
  60554. * @param axis the index of the axis
  60555. * @param axisValue the value of the axis which determines the meshes new position
  60556. * @hidden
  60557. */
  60558. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60559. /**
  60560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60561. * @param scene scene in which to add meshes
  60562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60563. */
  60564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60565. /**
  60566. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60567. * can be transformed by button presses and axes values, based on this._mapping.
  60568. *
  60569. * @param scene scene in which the meshes exist
  60570. * @param meshes list of meshes that make up the controller model to process
  60571. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60572. */
  60573. private processModel;
  60574. private createMeshInfo;
  60575. /**
  60576. * Gets the ray of the controller in the direction the controller is pointing
  60577. * @param length the length the resulting ray should be
  60578. * @returns a ray in the direction the controller is pointing
  60579. */
  60580. getForwardRay(length?: number): Ray;
  60581. /**
  60582. * Disposes of the controller
  60583. */
  60584. dispose(): void;
  60585. }
  60586. /**
  60587. * This class represents a new windows motion controller in XR.
  60588. */
  60589. export class XRWindowsMotionController extends WindowsMotionController {
  60590. /**
  60591. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60592. */
  60593. protected readonly _mapping: {
  60594. buttons: string[];
  60595. buttonMeshNames: {
  60596. trigger: string;
  60597. menu: string;
  60598. grip: string;
  60599. thumbstick: string;
  60600. trackpad: string;
  60601. };
  60602. buttonObservableNames: {
  60603. trigger: string;
  60604. menu: string;
  60605. grip: string;
  60606. thumbstick: string;
  60607. trackpad: string;
  60608. };
  60609. axisMeshNames: string[];
  60610. pointingPoseMeshName: string;
  60611. };
  60612. /**
  60613. * Construct a new XR-Based windows motion controller
  60614. *
  60615. * @param gamepadInfo the gamepad object from the browser
  60616. */
  60617. constructor(gamepadInfo: any);
  60618. /**
  60619. * holds the thumbstick values (X,Y)
  60620. */
  60621. thumbstickValues: StickValues;
  60622. /**
  60623. * Fired when the thumbstick on this controller is clicked
  60624. */
  60625. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60626. /**
  60627. * Fired when the thumbstick on this controller is modified
  60628. */
  60629. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60630. /**
  60631. * Fired when the touchpad button on this controller is modified
  60632. */
  60633. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60634. /**
  60635. * Fired when the touchpad values on this controller are modified
  60636. */
  60637. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60638. /**
  60639. * Fired when the thumbstick button on this controller is modified
  60640. * here to prevent breaking changes
  60641. */
  60642. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60643. /**
  60644. * updating the thumbstick(!) and not the trackpad.
  60645. * This is named this way due to the difference between WebVR and XR and to avoid
  60646. * changing the parent class.
  60647. */
  60648. protected _updateTrackpad(): void;
  60649. /**
  60650. * Disposes the class with joy
  60651. */
  60652. dispose(): void;
  60653. }
  60654. }
  60655. declare module BABYLON {
  60656. /**
  60657. * A directional light is defined by a direction (what a surprise!).
  60658. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60659. * 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.
  60660. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60661. */
  60662. export class DirectionalLight extends ShadowLight {
  60663. private _shadowFrustumSize;
  60664. /**
  60665. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60666. */
  60667. get shadowFrustumSize(): number;
  60668. /**
  60669. * Specifies a fix frustum size for the shadow generation.
  60670. */
  60671. set shadowFrustumSize(value: number);
  60672. private _shadowOrthoScale;
  60673. /**
  60674. * Gets the shadow projection scale against the optimal computed one.
  60675. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60676. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60677. */
  60678. get shadowOrthoScale(): number;
  60679. /**
  60680. * Sets the shadow projection scale against the optimal computed one.
  60681. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60682. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60683. */
  60684. set shadowOrthoScale(value: number);
  60685. /**
  60686. * Automatically compute the projection matrix to best fit (including all the casters)
  60687. * on each frame.
  60688. */
  60689. autoUpdateExtends: boolean;
  60690. /**
  60691. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60692. * on each frame. autoUpdateExtends must be set to true for this to work
  60693. */
  60694. autoCalcShadowZBounds: boolean;
  60695. private _orthoLeft;
  60696. private _orthoRight;
  60697. private _orthoTop;
  60698. private _orthoBottom;
  60699. /**
  60700. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60701. * The directional light is emitted from everywhere in the given direction.
  60702. * It can cast shadows.
  60703. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60704. * @param name The friendly name of the light
  60705. * @param direction The direction of the light
  60706. * @param scene The scene the light belongs to
  60707. */
  60708. constructor(name: string, direction: Vector3, scene: Scene);
  60709. /**
  60710. * Returns the string "DirectionalLight".
  60711. * @return The class name
  60712. */
  60713. getClassName(): string;
  60714. /**
  60715. * Returns the integer 1.
  60716. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60717. */
  60718. getTypeID(): number;
  60719. /**
  60720. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60721. * Returns the DirectionalLight Shadow projection matrix.
  60722. */
  60723. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60724. /**
  60725. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60726. * Returns the DirectionalLight Shadow projection matrix.
  60727. */
  60728. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60729. /**
  60730. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60731. * Returns the DirectionalLight Shadow projection matrix.
  60732. */
  60733. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60734. protected _buildUniformLayout(): void;
  60735. /**
  60736. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60737. * @param effect The effect to update
  60738. * @param lightIndex The index of the light in the effect to update
  60739. * @returns The directional light
  60740. */
  60741. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60742. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60743. /**
  60744. * Gets the minZ used for shadow according to both the scene and the light.
  60745. *
  60746. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60747. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60748. * @param activeCamera The camera we are returning the min for
  60749. * @returns the depth min z
  60750. */
  60751. getDepthMinZ(activeCamera: Camera): number;
  60752. /**
  60753. * Gets the maxZ used for shadow according to both the scene and the light.
  60754. *
  60755. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60756. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60757. * @param activeCamera The camera we are returning the max for
  60758. * @returns the depth max z
  60759. */
  60760. getDepthMaxZ(activeCamera: Camera): number;
  60761. /**
  60762. * Prepares the list of defines specific to the light type.
  60763. * @param defines the list of defines
  60764. * @param lightIndex defines the index of the light for the effect
  60765. */
  60766. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60767. }
  60768. }
  60769. declare module BABYLON {
  60770. /**
  60771. * Class containing static functions to help procedurally build meshes
  60772. */
  60773. export class HemisphereBuilder {
  60774. /**
  60775. * Creates a hemisphere mesh
  60776. * @param name defines the name of the mesh
  60777. * @param options defines the options used to create the mesh
  60778. * @param scene defines the hosting scene
  60779. * @returns the hemisphere mesh
  60780. */
  60781. static CreateHemisphere(name: string, options: {
  60782. segments?: number;
  60783. diameter?: number;
  60784. sideOrientation?: number;
  60785. }, scene: any): Mesh;
  60786. }
  60787. }
  60788. declare module BABYLON {
  60789. /**
  60790. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60791. * These values define a cone of light starting from the position, emitting toward the direction.
  60792. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60793. * and the exponent defines the speed of the decay of the light with distance (reach).
  60794. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60795. */
  60796. export class SpotLight extends ShadowLight {
  60797. private _angle;
  60798. private _innerAngle;
  60799. private _cosHalfAngle;
  60800. private _lightAngleScale;
  60801. private _lightAngleOffset;
  60802. /**
  60803. * Gets the cone angle of the spot light in Radians.
  60804. */
  60805. get angle(): number;
  60806. /**
  60807. * Sets the cone angle of the spot light in Radians.
  60808. */
  60809. set angle(value: number);
  60810. /**
  60811. * Only used in gltf falloff mode, this defines the angle where
  60812. * the directional falloff will start before cutting at angle which could be seen
  60813. * as outer angle.
  60814. */
  60815. get innerAngle(): number;
  60816. /**
  60817. * Only used in gltf falloff mode, this defines the angle where
  60818. * the directional falloff will start before cutting at angle which could be seen
  60819. * as outer angle.
  60820. */
  60821. set innerAngle(value: number);
  60822. private _shadowAngleScale;
  60823. /**
  60824. * Allows scaling the angle of the light for shadow generation only.
  60825. */
  60826. get shadowAngleScale(): number;
  60827. /**
  60828. * Allows scaling the angle of the light for shadow generation only.
  60829. */
  60830. set shadowAngleScale(value: number);
  60831. /**
  60832. * The light decay speed with the distance from the emission spot.
  60833. */
  60834. exponent: number;
  60835. private _projectionTextureMatrix;
  60836. /**
  60837. * Allows reading the projecton texture
  60838. */
  60839. get projectionTextureMatrix(): Matrix;
  60840. protected _projectionTextureLightNear: number;
  60841. /**
  60842. * Gets the near clip of the Spotlight for texture projection.
  60843. */
  60844. get projectionTextureLightNear(): number;
  60845. /**
  60846. * Sets the near clip of the Spotlight for texture projection.
  60847. */
  60848. set projectionTextureLightNear(value: number);
  60849. protected _projectionTextureLightFar: number;
  60850. /**
  60851. * Gets the far clip of the Spotlight for texture projection.
  60852. */
  60853. get projectionTextureLightFar(): number;
  60854. /**
  60855. * Sets the far clip of the Spotlight for texture projection.
  60856. */
  60857. set projectionTextureLightFar(value: number);
  60858. protected _projectionTextureUpDirection: Vector3;
  60859. /**
  60860. * Gets the Up vector of the Spotlight for texture projection.
  60861. */
  60862. get projectionTextureUpDirection(): Vector3;
  60863. /**
  60864. * Sets the Up vector of the Spotlight for texture projection.
  60865. */
  60866. set projectionTextureUpDirection(value: Vector3);
  60867. private _projectionTexture;
  60868. /**
  60869. * Gets the projection texture of the light.
  60870. */
  60871. get projectionTexture(): Nullable<BaseTexture>;
  60872. /**
  60873. * Sets the projection texture of the light.
  60874. */
  60875. set projectionTexture(value: Nullable<BaseTexture>);
  60876. private static _IsProceduralTexture;
  60877. private static _IsTexture;
  60878. private _projectionTextureViewLightDirty;
  60879. private _projectionTextureProjectionLightDirty;
  60880. private _projectionTextureDirty;
  60881. private _projectionTextureViewTargetVector;
  60882. private _projectionTextureViewLightMatrix;
  60883. private _projectionTextureProjectionLightMatrix;
  60884. private _projectionTextureScalingMatrix;
  60885. /**
  60886. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60887. * It can cast shadows.
  60888. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60889. * @param name The light friendly name
  60890. * @param position The position of the spot light in the scene
  60891. * @param direction The direction of the light in the scene
  60892. * @param angle The cone angle of the light in Radians
  60893. * @param exponent The light decay speed with the distance from the emission spot
  60894. * @param scene The scene the lights belongs to
  60895. */
  60896. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60897. /**
  60898. * Returns the string "SpotLight".
  60899. * @returns the class name
  60900. */
  60901. getClassName(): string;
  60902. /**
  60903. * Returns the integer 2.
  60904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60905. */
  60906. getTypeID(): number;
  60907. /**
  60908. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60909. */
  60910. protected _setDirection(value: Vector3): void;
  60911. /**
  60912. * Overrides the position setter to recompute the projection texture view light Matrix.
  60913. */
  60914. protected _setPosition(value: Vector3): void;
  60915. /**
  60916. * 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.
  60917. * Returns the SpotLight.
  60918. */
  60919. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60920. protected _computeProjectionTextureViewLightMatrix(): void;
  60921. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60922. /**
  60923. * Main function for light texture projection matrix computing.
  60924. */
  60925. protected _computeProjectionTextureMatrix(): void;
  60926. protected _buildUniformLayout(): void;
  60927. private _computeAngleValues;
  60928. /**
  60929. * Sets the passed Effect "effect" with the Light textures.
  60930. * @param effect The effect to update
  60931. * @param lightIndex The index of the light in the effect to update
  60932. * @returns The light
  60933. */
  60934. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60935. /**
  60936. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60937. * @param effect The effect to update
  60938. * @param lightIndex The index of the light in the effect to update
  60939. * @returns The spot light
  60940. */
  60941. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60942. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60943. /**
  60944. * Disposes the light and the associated resources.
  60945. */
  60946. dispose(): void;
  60947. /**
  60948. * Prepares the list of defines specific to the light type.
  60949. * @param defines the list of defines
  60950. * @param lightIndex defines the index of the light for the effect
  60951. */
  60952. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60953. }
  60954. }
  60955. declare module BABYLON {
  60956. /**
  60957. * Gizmo that enables viewing a light
  60958. */
  60959. export class LightGizmo extends Gizmo {
  60960. private _lightMesh;
  60961. private _material;
  60962. private _cachedPosition;
  60963. private _cachedForward;
  60964. private _attachedMeshParent;
  60965. private _pointerObserver;
  60966. /**
  60967. * Event that fires each time the gizmo is clicked
  60968. */
  60969. onClickedObservable: Observable<Light>;
  60970. /**
  60971. * Creates a LightGizmo
  60972. * @param gizmoLayer The utility layer the gizmo will be added to
  60973. */
  60974. constructor(gizmoLayer?: UtilityLayerRenderer);
  60975. private _light;
  60976. /**
  60977. * The light that the gizmo is attached to
  60978. */
  60979. set light(light: Nullable<Light>);
  60980. get light(): Nullable<Light>;
  60981. /**
  60982. * Gets the material used to render the light gizmo
  60983. */
  60984. get material(): StandardMaterial;
  60985. /**
  60986. * @hidden
  60987. * Updates the gizmo to match the attached mesh's position/rotation
  60988. */
  60989. protected _update(): void;
  60990. private static _Scale;
  60991. /**
  60992. * Creates the lines for a light mesh
  60993. */
  60994. private static _CreateLightLines;
  60995. /**
  60996. * Disposes of the light gizmo
  60997. */
  60998. dispose(): void;
  60999. private static _CreateHemisphericLightMesh;
  61000. private static _CreatePointLightMesh;
  61001. private static _CreateSpotLightMesh;
  61002. private static _CreateDirectionalLightMesh;
  61003. }
  61004. }
  61005. declare module BABYLON {
  61006. /**
  61007. * Gizmo that enables viewing a camera
  61008. */
  61009. export class CameraGizmo extends Gizmo {
  61010. private _cameraMesh;
  61011. private _cameraLinesMesh;
  61012. private _material;
  61013. private _pointerObserver;
  61014. /**
  61015. * Event that fires each time the gizmo is clicked
  61016. */
  61017. onClickedObservable: Observable<Camera>;
  61018. /**
  61019. * Creates a CameraGizmo
  61020. * @param gizmoLayer The utility layer the gizmo will be added to
  61021. */
  61022. constructor(gizmoLayer?: UtilityLayerRenderer);
  61023. private _camera;
  61024. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61025. get displayFrustum(): boolean;
  61026. set displayFrustum(value: boolean);
  61027. /**
  61028. * The camera that the gizmo is attached to
  61029. */
  61030. set camera(camera: Nullable<Camera>);
  61031. get camera(): Nullable<Camera>;
  61032. /**
  61033. * Gets the material used to render the camera gizmo
  61034. */
  61035. get material(): StandardMaterial;
  61036. /**
  61037. * @hidden
  61038. * Updates the gizmo to match the attached mesh's position/rotation
  61039. */
  61040. protected _update(): void;
  61041. private static _Scale;
  61042. private _invProjection;
  61043. /**
  61044. * Disposes of the camera gizmo
  61045. */
  61046. dispose(): void;
  61047. private static _CreateCameraMesh;
  61048. private static _CreateCameraFrustum;
  61049. }
  61050. }
  61051. declare module BABYLON {
  61052. /** @hidden */
  61053. export var backgroundFragmentDeclaration: {
  61054. name: string;
  61055. shader: string;
  61056. };
  61057. }
  61058. declare module BABYLON {
  61059. /** @hidden */
  61060. export var backgroundUboDeclaration: {
  61061. name: string;
  61062. shader: string;
  61063. };
  61064. }
  61065. declare module BABYLON {
  61066. /** @hidden */
  61067. export var backgroundPixelShader: {
  61068. name: string;
  61069. shader: string;
  61070. };
  61071. }
  61072. declare module BABYLON {
  61073. /** @hidden */
  61074. export var backgroundVertexDeclaration: {
  61075. name: string;
  61076. shader: string;
  61077. };
  61078. }
  61079. declare module BABYLON {
  61080. /** @hidden */
  61081. export var backgroundVertexShader: {
  61082. name: string;
  61083. shader: string;
  61084. };
  61085. }
  61086. declare module BABYLON {
  61087. /**
  61088. * Background material used to create an efficient environement around your scene.
  61089. */
  61090. export class BackgroundMaterial extends PushMaterial {
  61091. /**
  61092. * Standard reflectance value at parallel view angle.
  61093. */
  61094. static StandardReflectance0: number;
  61095. /**
  61096. * Standard reflectance value at grazing angle.
  61097. */
  61098. static StandardReflectance90: number;
  61099. protected _primaryColor: Color3;
  61100. /**
  61101. * Key light Color (multiply against the environement texture)
  61102. */
  61103. primaryColor: Color3;
  61104. protected __perceptualColor: Nullable<Color3>;
  61105. /**
  61106. * Experimental Internal Use Only.
  61107. *
  61108. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61109. * This acts as a helper to set the primary color to a more "human friendly" value.
  61110. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61111. * output color as close as possible from the chosen value.
  61112. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61113. * part of lighting setup.)
  61114. */
  61115. get _perceptualColor(): Nullable<Color3>;
  61116. set _perceptualColor(value: Nullable<Color3>);
  61117. protected _primaryColorShadowLevel: float;
  61118. /**
  61119. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61120. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61121. */
  61122. get primaryColorShadowLevel(): float;
  61123. set primaryColorShadowLevel(value: float);
  61124. protected _primaryColorHighlightLevel: float;
  61125. /**
  61126. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  61127. * The primary color is used at the level chosen to define what the white area would look.
  61128. */
  61129. get primaryColorHighlightLevel(): float;
  61130. set primaryColorHighlightLevel(value: float);
  61131. protected _reflectionTexture: Nullable<BaseTexture>;
  61132. /**
  61133. * Reflection Texture used in the material.
  61134. * Should be author in a specific way for the best result (refer to the documentation).
  61135. */
  61136. reflectionTexture: Nullable<BaseTexture>;
  61137. protected _reflectionBlur: float;
  61138. /**
  61139. * Reflection Texture level of blur.
  61140. *
  61141. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61142. * texture twice.
  61143. */
  61144. reflectionBlur: float;
  61145. protected _diffuseTexture: Nullable<BaseTexture>;
  61146. /**
  61147. * Diffuse Texture used in the material.
  61148. * Should be author in a specific way for the best result (refer to the documentation).
  61149. */
  61150. diffuseTexture: Nullable<BaseTexture>;
  61151. protected _shadowLights: Nullable<IShadowLight[]>;
  61152. /**
  61153. * Specify the list of lights casting shadow on the material.
  61154. * All scene shadow lights will be included if null.
  61155. */
  61156. shadowLights: Nullable<IShadowLight[]>;
  61157. protected _shadowLevel: float;
  61158. /**
  61159. * Helps adjusting the shadow to a softer level if required.
  61160. * 0 means black shadows and 1 means no shadows.
  61161. */
  61162. shadowLevel: float;
  61163. protected _sceneCenter: Vector3;
  61164. /**
  61165. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61166. * It is usually zero but might be interesting to modify according to your setup.
  61167. */
  61168. sceneCenter: Vector3;
  61169. protected _opacityFresnel: boolean;
  61170. /**
  61171. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61172. * This helps ensuring a nice transition when the camera goes under the ground.
  61173. */
  61174. opacityFresnel: boolean;
  61175. protected _reflectionFresnel: boolean;
  61176. /**
  61177. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61178. * This helps adding a mirror texture on the ground.
  61179. */
  61180. reflectionFresnel: boolean;
  61181. protected _reflectionFalloffDistance: number;
  61182. /**
  61183. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61184. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61185. */
  61186. reflectionFalloffDistance: number;
  61187. protected _reflectionAmount: number;
  61188. /**
  61189. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61190. */
  61191. reflectionAmount: number;
  61192. protected _reflectionReflectance0: number;
  61193. /**
  61194. * This specifies the weight of the reflection at grazing angle.
  61195. */
  61196. reflectionReflectance0: number;
  61197. protected _reflectionReflectance90: number;
  61198. /**
  61199. * This specifies the weight of the reflection at a perpendicular point of view.
  61200. */
  61201. reflectionReflectance90: number;
  61202. /**
  61203. * Sets the reflection reflectance fresnel values according to the default standard
  61204. * empirically know to work well :-)
  61205. */
  61206. set reflectionStandardFresnelWeight(value: number);
  61207. protected _useRGBColor: boolean;
  61208. /**
  61209. * Helps to directly use the maps channels instead of their level.
  61210. */
  61211. useRGBColor: boolean;
  61212. protected _enableNoise: boolean;
  61213. /**
  61214. * This helps reducing the banding effect that could occur on the background.
  61215. */
  61216. enableNoise: boolean;
  61217. /**
  61218. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61219. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61220. * Recommended to be keep at 1.0 except for special cases.
  61221. */
  61222. get fovMultiplier(): number;
  61223. set fovMultiplier(value: number);
  61224. private _fovMultiplier;
  61225. /**
  61226. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61227. */
  61228. useEquirectangularFOV: boolean;
  61229. private _maxSimultaneousLights;
  61230. /**
  61231. * Number of Simultaneous lights allowed on the material.
  61232. */
  61233. maxSimultaneousLights: int;
  61234. private _shadowOnly;
  61235. /**
  61236. * Make the material only render shadows
  61237. */
  61238. shadowOnly: boolean;
  61239. /**
  61240. * Default configuration related to image processing available in the Background Material.
  61241. */
  61242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61243. /**
  61244. * Keep track of the image processing observer to allow dispose and replace.
  61245. */
  61246. private _imageProcessingObserver;
  61247. /**
  61248. * Attaches a new image processing configuration to the PBR Material.
  61249. * @param configuration (if null the scene configuration will be use)
  61250. */
  61251. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61252. /**
  61253. * Gets the image processing configuration used either in this material.
  61254. */
  61255. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61256. /**
  61257. * Sets the Default image processing configuration used either in the this material.
  61258. *
  61259. * If sets to null, the scene one is in use.
  61260. */
  61261. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61262. /**
  61263. * Gets wether the color curves effect is enabled.
  61264. */
  61265. get cameraColorCurvesEnabled(): boolean;
  61266. /**
  61267. * Sets wether the color curves effect is enabled.
  61268. */
  61269. set cameraColorCurvesEnabled(value: boolean);
  61270. /**
  61271. * Gets wether the color grading effect is enabled.
  61272. */
  61273. get cameraColorGradingEnabled(): boolean;
  61274. /**
  61275. * Gets wether the color grading effect is enabled.
  61276. */
  61277. set cameraColorGradingEnabled(value: boolean);
  61278. /**
  61279. * Gets wether tonemapping is enabled or not.
  61280. */
  61281. get cameraToneMappingEnabled(): boolean;
  61282. /**
  61283. * Sets wether tonemapping is enabled or not
  61284. */
  61285. set cameraToneMappingEnabled(value: boolean);
  61286. /**
  61287. * The camera exposure used on this material.
  61288. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61289. * This corresponds to a photographic exposure.
  61290. */
  61291. get cameraExposure(): float;
  61292. /**
  61293. * The camera exposure used on this material.
  61294. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61295. * This corresponds to a photographic exposure.
  61296. */
  61297. set cameraExposure(value: float);
  61298. /**
  61299. * Gets The camera contrast used on this material.
  61300. */
  61301. get cameraContrast(): float;
  61302. /**
  61303. * Sets The camera contrast used on this material.
  61304. */
  61305. set cameraContrast(value: float);
  61306. /**
  61307. * Gets the Color Grading 2D Lookup Texture.
  61308. */
  61309. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61310. /**
  61311. * Sets the Color Grading 2D Lookup Texture.
  61312. */
  61313. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61314. /**
  61315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61317. * 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;
  61318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61319. */
  61320. get cameraColorCurves(): Nullable<ColorCurves>;
  61321. /**
  61322. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61323. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61324. * 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;
  61325. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61326. */
  61327. set cameraColorCurves(value: Nullable<ColorCurves>);
  61328. /**
  61329. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61330. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61331. */
  61332. switchToBGR: boolean;
  61333. private _renderTargets;
  61334. private _reflectionControls;
  61335. private _white;
  61336. private _primaryShadowColor;
  61337. private _primaryHighlightColor;
  61338. /**
  61339. * Instantiates a Background Material in the given scene
  61340. * @param name The friendly name of the material
  61341. * @param scene The scene to add the material to
  61342. */
  61343. constructor(name: string, scene: Scene);
  61344. /**
  61345. * Gets a boolean indicating that current material needs to register RTT
  61346. */
  61347. get hasRenderTargetTextures(): boolean;
  61348. /**
  61349. * The entire material has been created in order to prevent overdraw.
  61350. * @returns false
  61351. */
  61352. needAlphaTesting(): boolean;
  61353. /**
  61354. * The entire material has been created in order to prevent overdraw.
  61355. * @returns true if blending is enable
  61356. */
  61357. needAlphaBlending(): boolean;
  61358. /**
  61359. * Checks wether the material is ready to be rendered for a given mesh.
  61360. * @param mesh The mesh to render
  61361. * @param subMesh The submesh to check against
  61362. * @param useInstances Specify wether or not the material is used with instances
  61363. * @returns true if all the dependencies are ready (Textures, Effects...)
  61364. */
  61365. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61366. /**
  61367. * Compute the primary color according to the chosen perceptual color.
  61368. */
  61369. private _computePrimaryColorFromPerceptualColor;
  61370. /**
  61371. * Compute the highlights and shadow colors according to their chosen levels.
  61372. */
  61373. private _computePrimaryColors;
  61374. /**
  61375. * Build the uniform buffer used in the material.
  61376. */
  61377. buildUniformLayout(): void;
  61378. /**
  61379. * Unbind the material.
  61380. */
  61381. unbind(): void;
  61382. /**
  61383. * Bind only the world matrix to the material.
  61384. * @param world The world matrix to bind.
  61385. */
  61386. bindOnlyWorldMatrix(world: Matrix): void;
  61387. /**
  61388. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61389. * @param world The world matrix to bind.
  61390. * @param subMesh The submesh to bind for.
  61391. */
  61392. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61393. /**
  61394. * Checks to see if a texture is used in the material.
  61395. * @param texture - Base texture to use.
  61396. * @returns - Boolean specifying if a texture is used in the material.
  61397. */
  61398. hasTexture(texture: BaseTexture): boolean;
  61399. /**
  61400. * Dispose the material.
  61401. * @param forceDisposeEffect Force disposal of the associated effect.
  61402. * @param forceDisposeTextures Force disposal of the associated textures.
  61403. */
  61404. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61405. /**
  61406. * Clones the material.
  61407. * @param name The cloned name.
  61408. * @returns The cloned material.
  61409. */
  61410. clone(name: string): BackgroundMaterial;
  61411. /**
  61412. * Serializes the current material to its JSON representation.
  61413. * @returns The JSON representation.
  61414. */
  61415. serialize(): any;
  61416. /**
  61417. * Gets the class name of the material
  61418. * @returns "BackgroundMaterial"
  61419. */
  61420. getClassName(): string;
  61421. /**
  61422. * Parse a JSON input to create back a background material.
  61423. * @param source The JSON data to parse
  61424. * @param scene The scene to create the parsed material in
  61425. * @param rootUrl The root url of the assets the material depends upon
  61426. * @returns the instantiated BackgroundMaterial.
  61427. */
  61428. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61429. }
  61430. }
  61431. declare module BABYLON {
  61432. /**
  61433. * Represents the different options available during the creation of
  61434. * a Environment helper.
  61435. *
  61436. * This can control the default ground, skybox and image processing setup of your scene.
  61437. */
  61438. export interface IEnvironmentHelperOptions {
  61439. /**
  61440. * Specifies whether or not to create a ground.
  61441. * True by default.
  61442. */
  61443. createGround: boolean;
  61444. /**
  61445. * Specifies the ground size.
  61446. * 15 by default.
  61447. */
  61448. groundSize: number;
  61449. /**
  61450. * The texture used on the ground for the main color.
  61451. * Comes from the BabylonJS CDN by default.
  61452. *
  61453. * Remarks: Can be either a texture or a url.
  61454. */
  61455. groundTexture: string | BaseTexture;
  61456. /**
  61457. * The color mixed in the ground texture by default.
  61458. * BabylonJS clearColor by default.
  61459. */
  61460. groundColor: Color3;
  61461. /**
  61462. * Specifies the ground opacity.
  61463. * 1 by default.
  61464. */
  61465. groundOpacity: number;
  61466. /**
  61467. * Enables the ground to receive shadows.
  61468. * True by default.
  61469. */
  61470. enableGroundShadow: boolean;
  61471. /**
  61472. * Helps preventing the shadow to be fully black on the ground.
  61473. * 0.5 by default.
  61474. */
  61475. groundShadowLevel: number;
  61476. /**
  61477. * Creates a mirror texture attach to the ground.
  61478. * false by default.
  61479. */
  61480. enableGroundMirror: boolean;
  61481. /**
  61482. * Specifies the ground mirror size ratio.
  61483. * 0.3 by default as the default kernel is 64.
  61484. */
  61485. groundMirrorSizeRatio: number;
  61486. /**
  61487. * Specifies the ground mirror blur kernel size.
  61488. * 64 by default.
  61489. */
  61490. groundMirrorBlurKernel: number;
  61491. /**
  61492. * Specifies the ground mirror visibility amount.
  61493. * 1 by default
  61494. */
  61495. groundMirrorAmount: number;
  61496. /**
  61497. * Specifies the ground mirror reflectance weight.
  61498. * This uses the standard weight of the background material to setup the fresnel effect
  61499. * of the mirror.
  61500. * 1 by default.
  61501. */
  61502. groundMirrorFresnelWeight: number;
  61503. /**
  61504. * Specifies the ground mirror Falloff distance.
  61505. * This can helps reducing the size of the reflection.
  61506. * 0 by Default.
  61507. */
  61508. groundMirrorFallOffDistance: number;
  61509. /**
  61510. * Specifies the ground mirror texture type.
  61511. * Unsigned Int by Default.
  61512. */
  61513. groundMirrorTextureType: number;
  61514. /**
  61515. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61516. * the shown objects.
  61517. */
  61518. groundYBias: number;
  61519. /**
  61520. * Specifies whether or not to create a skybox.
  61521. * True by default.
  61522. */
  61523. createSkybox: boolean;
  61524. /**
  61525. * Specifies the skybox size.
  61526. * 20 by default.
  61527. */
  61528. skyboxSize: number;
  61529. /**
  61530. * The texture used on the skybox for the main color.
  61531. * Comes from the BabylonJS CDN by default.
  61532. *
  61533. * Remarks: Can be either a texture or a url.
  61534. */
  61535. skyboxTexture: string | BaseTexture;
  61536. /**
  61537. * The color mixed in the skybox texture by default.
  61538. * BabylonJS clearColor by default.
  61539. */
  61540. skyboxColor: Color3;
  61541. /**
  61542. * The background rotation around the Y axis of the scene.
  61543. * This helps aligning the key lights of your scene with the background.
  61544. * 0 by default.
  61545. */
  61546. backgroundYRotation: number;
  61547. /**
  61548. * Compute automatically the size of the elements to best fit with the scene.
  61549. */
  61550. sizeAuto: boolean;
  61551. /**
  61552. * Default position of the rootMesh if autoSize is not true.
  61553. */
  61554. rootPosition: Vector3;
  61555. /**
  61556. * Sets up the image processing in the scene.
  61557. * true by default.
  61558. */
  61559. setupImageProcessing: boolean;
  61560. /**
  61561. * The texture used as your environment texture in the scene.
  61562. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61563. *
  61564. * Remarks: Can be either a texture or a url.
  61565. */
  61566. environmentTexture: string | BaseTexture;
  61567. /**
  61568. * The value of the exposure to apply to the scene.
  61569. * 0.6 by default if setupImageProcessing is true.
  61570. */
  61571. cameraExposure: number;
  61572. /**
  61573. * The value of the contrast to apply to the scene.
  61574. * 1.6 by default if setupImageProcessing is true.
  61575. */
  61576. cameraContrast: number;
  61577. /**
  61578. * Specifies whether or not tonemapping should be enabled in the scene.
  61579. * true by default if setupImageProcessing is true.
  61580. */
  61581. toneMappingEnabled: boolean;
  61582. }
  61583. /**
  61584. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61585. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61586. * It also helps with the default setup of your imageProcessing configuration.
  61587. */
  61588. export class EnvironmentHelper {
  61589. /**
  61590. * Default ground texture URL.
  61591. */
  61592. private static _groundTextureCDNUrl;
  61593. /**
  61594. * Default skybox texture URL.
  61595. */
  61596. private static _skyboxTextureCDNUrl;
  61597. /**
  61598. * Default environment texture URL.
  61599. */
  61600. private static _environmentTextureCDNUrl;
  61601. /**
  61602. * Creates the default options for the helper.
  61603. */
  61604. private static _getDefaultOptions;
  61605. private _rootMesh;
  61606. /**
  61607. * Gets the root mesh created by the helper.
  61608. */
  61609. get rootMesh(): Mesh;
  61610. private _skybox;
  61611. /**
  61612. * Gets the skybox created by the helper.
  61613. */
  61614. get skybox(): Nullable<Mesh>;
  61615. private _skyboxTexture;
  61616. /**
  61617. * Gets the skybox texture created by the helper.
  61618. */
  61619. get skyboxTexture(): Nullable<BaseTexture>;
  61620. private _skyboxMaterial;
  61621. /**
  61622. * Gets the skybox material created by the helper.
  61623. */
  61624. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61625. private _ground;
  61626. /**
  61627. * Gets the ground mesh created by the helper.
  61628. */
  61629. get ground(): Nullable<Mesh>;
  61630. private _groundTexture;
  61631. /**
  61632. * Gets the ground texture created by the helper.
  61633. */
  61634. get groundTexture(): Nullable<BaseTexture>;
  61635. private _groundMirror;
  61636. /**
  61637. * Gets the ground mirror created by the helper.
  61638. */
  61639. get groundMirror(): Nullable<MirrorTexture>;
  61640. /**
  61641. * Gets the ground mirror render list to helps pushing the meshes
  61642. * you wish in the ground reflection.
  61643. */
  61644. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61645. private _groundMaterial;
  61646. /**
  61647. * Gets the ground material created by the helper.
  61648. */
  61649. get groundMaterial(): Nullable<BackgroundMaterial>;
  61650. /**
  61651. * Stores the creation options.
  61652. */
  61653. private readonly _scene;
  61654. private _options;
  61655. /**
  61656. * This observable will be notified with any error during the creation of the environment,
  61657. * mainly texture creation errors.
  61658. */
  61659. onErrorObservable: Observable<{
  61660. message?: string;
  61661. exception?: any;
  61662. }>;
  61663. /**
  61664. * constructor
  61665. * @param options Defines the options we want to customize the helper
  61666. * @param scene The scene to add the material to
  61667. */
  61668. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61669. /**
  61670. * Updates the background according to the new options
  61671. * @param options
  61672. */
  61673. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61674. /**
  61675. * Sets the primary color of all the available elements.
  61676. * @param color the main color to affect to the ground and the background
  61677. */
  61678. setMainColor(color: Color3): void;
  61679. /**
  61680. * Setup the image processing according to the specified options.
  61681. */
  61682. private _setupImageProcessing;
  61683. /**
  61684. * Setup the environment texture according to the specified options.
  61685. */
  61686. private _setupEnvironmentTexture;
  61687. /**
  61688. * Setup the background according to the specified options.
  61689. */
  61690. private _setupBackground;
  61691. /**
  61692. * Get the scene sizes according to the setup.
  61693. */
  61694. private _getSceneSize;
  61695. /**
  61696. * Setup the ground according to the specified options.
  61697. */
  61698. private _setupGround;
  61699. /**
  61700. * Setup the ground material according to the specified options.
  61701. */
  61702. private _setupGroundMaterial;
  61703. /**
  61704. * Setup the ground diffuse texture according to the specified options.
  61705. */
  61706. private _setupGroundDiffuseTexture;
  61707. /**
  61708. * Setup the ground mirror texture according to the specified options.
  61709. */
  61710. private _setupGroundMirrorTexture;
  61711. /**
  61712. * Setup the ground to receive the mirror texture.
  61713. */
  61714. private _setupMirrorInGroundMaterial;
  61715. /**
  61716. * Setup the skybox according to the specified options.
  61717. */
  61718. private _setupSkybox;
  61719. /**
  61720. * Setup the skybox material according to the specified options.
  61721. */
  61722. private _setupSkyboxMaterial;
  61723. /**
  61724. * Setup the skybox reflection texture according to the specified options.
  61725. */
  61726. private _setupSkyboxReflectionTexture;
  61727. private _errorHandler;
  61728. /**
  61729. * Dispose all the elements created by the Helper.
  61730. */
  61731. dispose(): void;
  61732. }
  61733. }
  61734. declare module BABYLON {
  61735. /**
  61736. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61737. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61738. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61739. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61740. */
  61741. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61742. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61743. /**
  61744. * Define the source as a Monoscopic panoramic 360/180.
  61745. */
  61746. static readonly MODE_MONOSCOPIC: number;
  61747. /**
  61748. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61749. */
  61750. static readonly MODE_TOPBOTTOM: number;
  61751. /**
  61752. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61753. */
  61754. static readonly MODE_SIDEBYSIDE: number;
  61755. private _halfDome;
  61756. private _crossEye;
  61757. protected _useDirectMapping: boolean;
  61758. /**
  61759. * The texture being displayed on the sphere
  61760. */
  61761. protected _texture: T;
  61762. /**
  61763. * Gets the texture being displayed on the sphere
  61764. */
  61765. get texture(): T;
  61766. /**
  61767. * Sets the texture being displayed on the sphere
  61768. */
  61769. set texture(newTexture: T);
  61770. /**
  61771. * The skybox material
  61772. */
  61773. protected _material: BackgroundMaterial;
  61774. /**
  61775. * The surface used for the dome
  61776. */
  61777. protected _mesh: Mesh;
  61778. /**
  61779. * Gets the mesh used for the dome.
  61780. */
  61781. get mesh(): Mesh;
  61782. /**
  61783. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61784. */
  61785. private _halfDomeMask;
  61786. /**
  61787. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61788. * Also see the options.resolution property.
  61789. */
  61790. get fovMultiplier(): number;
  61791. set fovMultiplier(value: number);
  61792. protected _textureMode: number;
  61793. /**
  61794. * Gets or set the current texture mode for the texture. It can be:
  61795. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61796. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61797. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61798. */
  61799. get textureMode(): number;
  61800. /**
  61801. * Sets the current texture mode for the texture. It can be:
  61802. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61803. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61804. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61805. */
  61806. set textureMode(value: number);
  61807. /**
  61808. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61809. */
  61810. get halfDome(): boolean;
  61811. /**
  61812. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61813. */
  61814. set halfDome(enabled: boolean);
  61815. /**
  61816. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61817. */
  61818. set crossEye(enabled: boolean);
  61819. /**
  61820. * Is it a cross-eye texture?
  61821. */
  61822. get crossEye(): boolean;
  61823. /**
  61824. * The background material of this dome.
  61825. */
  61826. get material(): BackgroundMaterial;
  61827. /**
  61828. * Oberserver used in Stereoscopic VR Mode.
  61829. */
  61830. private _onBeforeCameraRenderObserver;
  61831. /**
  61832. * Observable raised when an error occured while loading the 360 image
  61833. */
  61834. onLoadErrorObservable: Observable<string>;
  61835. /**
  61836. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61837. * @param name Element's name, child elements will append suffixes for their own names.
  61838. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61839. * @param options An object containing optional or exposed sub element properties
  61840. */
  61841. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61842. resolution?: number;
  61843. clickToPlay?: boolean;
  61844. autoPlay?: boolean;
  61845. loop?: boolean;
  61846. size?: number;
  61847. poster?: string;
  61848. faceForward?: boolean;
  61849. useDirectMapping?: boolean;
  61850. halfDomeMode?: boolean;
  61851. crossEyeMode?: boolean;
  61852. generateMipMaps?: boolean;
  61853. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61854. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61855. protected _changeTextureMode(value: number): void;
  61856. /**
  61857. * Releases resources associated with this node.
  61858. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61859. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61860. */
  61861. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61862. }
  61863. }
  61864. declare module BABYLON {
  61865. /**
  61866. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61867. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61868. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61869. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61870. */
  61871. export class PhotoDome extends TextureDome<Texture> {
  61872. /**
  61873. * Define the image as a Monoscopic panoramic 360 image.
  61874. */
  61875. static readonly MODE_MONOSCOPIC: number;
  61876. /**
  61877. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61878. */
  61879. static readonly MODE_TOPBOTTOM: number;
  61880. /**
  61881. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61882. */
  61883. static readonly MODE_SIDEBYSIDE: number;
  61884. /**
  61885. * Gets or sets the texture being displayed on the sphere
  61886. */
  61887. get photoTexture(): Texture;
  61888. /**
  61889. * sets the texture being displayed on the sphere
  61890. */
  61891. set photoTexture(value: Texture);
  61892. /**
  61893. * Gets the current video mode for the video. It can be:
  61894. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61895. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61896. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61897. */
  61898. get imageMode(): number;
  61899. /**
  61900. * Sets the current video mode for the video. It can be:
  61901. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61902. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61903. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61904. */
  61905. set imageMode(value: number);
  61906. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61907. }
  61908. }
  61909. declare module BABYLON {
  61910. /**
  61911. * Direct draw surface info
  61912. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61913. */
  61914. export interface DDSInfo {
  61915. /**
  61916. * Width of the texture
  61917. */
  61918. width: number;
  61919. /**
  61920. * Width of the texture
  61921. */
  61922. height: number;
  61923. /**
  61924. * Number of Mipmaps for the texture
  61925. * @see https://en.wikipedia.org/wiki/Mipmap
  61926. */
  61927. mipmapCount: number;
  61928. /**
  61929. * If the textures format is a known fourCC format
  61930. * @see https://www.fourcc.org/
  61931. */
  61932. isFourCC: boolean;
  61933. /**
  61934. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61935. */
  61936. isRGB: boolean;
  61937. /**
  61938. * If the texture is a lumincance format
  61939. */
  61940. isLuminance: boolean;
  61941. /**
  61942. * If this is a cube texture
  61943. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61944. */
  61945. isCube: boolean;
  61946. /**
  61947. * If the texture is a compressed format eg. FOURCC_DXT1
  61948. */
  61949. isCompressed: boolean;
  61950. /**
  61951. * The dxgiFormat of the texture
  61952. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61953. */
  61954. dxgiFormat: number;
  61955. /**
  61956. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61957. */
  61958. textureType: number;
  61959. /**
  61960. * Sphericle polynomial created for the dds texture
  61961. */
  61962. sphericalPolynomial?: SphericalPolynomial;
  61963. }
  61964. /**
  61965. * Class used to provide DDS decompression tools
  61966. */
  61967. export class DDSTools {
  61968. /**
  61969. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61970. */
  61971. static StoreLODInAlphaChannel: boolean;
  61972. /**
  61973. * Gets DDS information from an array buffer
  61974. * @param data defines the array buffer view to read data from
  61975. * @returns the DDS information
  61976. */
  61977. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61978. private static _FloatView;
  61979. private static _Int32View;
  61980. private static _ToHalfFloat;
  61981. private static _FromHalfFloat;
  61982. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61983. private static _GetHalfFloatRGBAArrayBuffer;
  61984. private static _GetFloatRGBAArrayBuffer;
  61985. private static _GetFloatAsUIntRGBAArrayBuffer;
  61986. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61987. private static _GetRGBAArrayBuffer;
  61988. private static _ExtractLongWordOrder;
  61989. private static _GetRGBArrayBuffer;
  61990. private static _GetLuminanceArrayBuffer;
  61991. /**
  61992. * Uploads DDS Levels to a Babylon Texture
  61993. * @hidden
  61994. */
  61995. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61996. }
  61997. interface ThinEngine {
  61998. /**
  61999. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62000. * @param rootUrl defines the url where the file to load is located
  62001. * @param scene defines the current scene
  62002. * @param lodScale defines scale to apply to the mip map selection
  62003. * @param lodOffset defines offset to apply to the mip map selection
  62004. * @param onLoad defines an optional callback raised when the texture is loaded
  62005. * @param onError defines an optional callback raised if there is an issue to load the texture
  62006. * @param format defines the format of the data
  62007. * @param forcedExtension defines the extension to use to pick the right loader
  62008. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62009. * @returns the cube texture as an InternalTexture
  62010. */
  62011. 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;
  62012. }
  62013. }
  62014. declare module BABYLON {
  62015. /**
  62016. * Implementation of the DDS Texture Loader.
  62017. * @hidden
  62018. */
  62019. export class _DDSTextureLoader implements IInternalTextureLoader {
  62020. /**
  62021. * Defines wether the loader supports cascade loading the different faces.
  62022. */
  62023. readonly supportCascades: boolean;
  62024. /**
  62025. * This returns if the loader support the current file information.
  62026. * @param extension defines the file extension of the file being loaded
  62027. * @returns true if the loader can load the specified file
  62028. */
  62029. canLoad(extension: string): boolean;
  62030. /**
  62031. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62032. * @param data contains the texture data
  62033. * @param texture defines the BabylonJS internal texture
  62034. * @param createPolynomials will be true if polynomials have been requested
  62035. * @param onLoad defines the callback to trigger once the texture is ready
  62036. * @param onError defines the callback to trigger in case of error
  62037. */
  62038. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62039. /**
  62040. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62041. * @param data contains the texture data
  62042. * @param texture defines the BabylonJS internal texture
  62043. * @param callback defines the method to call once ready to upload
  62044. */
  62045. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62046. }
  62047. }
  62048. declare module BABYLON {
  62049. /**
  62050. * Implementation of the ENV Texture Loader.
  62051. * @hidden
  62052. */
  62053. export class _ENVTextureLoader implements IInternalTextureLoader {
  62054. /**
  62055. * Defines wether the loader supports cascade loading the different faces.
  62056. */
  62057. readonly supportCascades: boolean;
  62058. /**
  62059. * This returns if the loader support the current file information.
  62060. * @param extension defines the file extension of the file being loaded
  62061. * @returns true if the loader can load the specified file
  62062. */
  62063. canLoad(extension: string): boolean;
  62064. /**
  62065. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62066. * @param data contains the texture data
  62067. * @param texture defines the BabylonJS internal texture
  62068. * @param createPolynomials will be true if polynomials have been requested
  62069. * @param onLoad defines the callback to trigger once the texture is ready
  62070. * @param onError defines the callback to trigger in case of error
  62071. */
  62072. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62073. /**
  62074. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62075. * @param data contains the texture data
  62076. * @param texture defines the BabylonJS internal texture
  62077. * @param callback defines the method to call once ready to upload
  62078. */
  62079. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62080. }
  62081. }
  62082. declare module BABYLON {
  62083. /**
  62084. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62085. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62086. */
  62087. export class KhronosTextureContainer {
  62088. /** contents of the KTX container file */
  62089. data: ArrayBufferView;
  62090. private static HEADER_LEN;
  62091. private static COMPRESSED_2D;
  62092. private static COMPRESSED_3D;
  62093. private static TEX_2D;
  62094. private static TEX_3D;
  62095. /**
  62096. * Gets the openGL type
  62097. */
  62098. glType: number;
  62099. /**
  62100. * Gets the openGL type size
  62101. */
  62102. glTypeSize: number;
  62103. /**
  62104. * Gets the openGL format
  62105. */
  62106. glFormat: number;
  62107. /**
  62108. * Gets the openGL internal format
  62109. */
  62110. glInternalFormat: number;
  62111. /**
  62112. * Gets the base internal format
  62113. */
  62114. glBaseInternalFormat: number;
  62115. /**
  62116. * Gets image width in pixel
  62117. */
  62118. pixelWidth: number;
  62119. /**
  62120. * Gets image height in pixel
  62121. */
  62122. pixelHeight: number;
  62123. /**
  62124. * Gets image depth in pixels
  62125. */
  62126. pixelDepth: number;
  62127. /**
  62128. * Gets the number of array elements
  62129. */
  62130. numberOfArrayElements: number;
  62131. /**
  62132. * Gets the number of faces
  62133. */
  62134. numberOfFaces: number;
  62135. /**
  62136. * Gets the number of mipmap levels
  62137. */
  62138. numberOfMipmapLevels: number;
  62139. /**
  62140. * Gets the bytes of key value data
  62141. */
  62142. bytesOfKeyValueData: number;
  62143. /**
  62144. * Gets the load type
  62145. */
  62146. loadType: number;
  62147. /**
  62148. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62149. */
  62150. isInvalid: boolean;
  62151. /**
  62152. * Creates a new KhronosTextureContainer
  62153. * @param data contents of the KTX container file
  62154. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62155. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62156. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62157. */
  62158. constructor(
  62159. /** contents of the KTX container file */
  62160. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62161. /**
  62162. * Uploads KTX content to a Babylon Texture.
  62163. * It is assumed that the texture has already been created & is currently bound
  62164. * @hidden
  62165. */
  62166. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62167. private _upload2DCompressedLevels;
  62168. /**
  62169. * Checks if the given data starts with a KTX file identifier.
  62170. * @param data the data to check
  62171. * @returns true if the data is a KTX file or false otherwise
  62172. */
  62173. static IsValid(data: ArrayBufferView): boolean;
  62174. }
  62175. }
  62176. declare module BABYLON {
  62177. /**
  62178. * Helper class to push actions to a pool of workers.
  62179. */
  62180. export class WorkerPool implements IDisposable {
  62181. private _workerInfos;
  62182. private _pendingActions;
  62183. /**
  62184. * Constructor
  62185. * @param workers Array of workers to use for actions
  62186. */
  62187. constructor(workers: Array<Worker>);
  62188. /**
  62189. * Terminates all workers and clears any pending actions.
  62190. */
  62191. dispose(): void;
  62192. /**
  62193. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62194. * pended until a worker has completed its action.
  62195. * @param action The action to perform. Call onComplete when the action is complete.
  62196. */
  62197. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62198. private _execute;
  62199. }
  62200. }
  62201. declare module BABYLON {
  62202. /**
  62203. * Class for loading KTX2 files
  62204. */
  62205. export class KhronosTextureContainer2 {
  62206. private static _WorkerPoolPromise?;
  62207. private static _Initialized;
  62208. private static _Ktx2Decoder;
  62209. /**
  62210. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62211. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62212. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62213. * Urls you can change:
  62214. * URLConfig.jsDecoderModule
  62215. * URLConfig.wasmUASTCToASTC
  62216. * URLConfig.wasmUASTCToBC7
  62217. * URLConfig.wasmUASTCToRGBA_UNORM
  62218. * URLConfig.wasmUASTCToRGBA_SRGB
  62219. * URLConfig.jsMSCTranscoder
  62220. * URLConfig.wasmMSCTranscoder
  62221. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62222. */
  62223. static URLConfig: {
  62224. jsDecoderModule: string;
  62225. wasmUASTCToASTC: null;
  62226. wasmUASTCToBC7: null;
  62227. wasmUASTCToRGBA_UNORM: null;
  62228. wasmUASTCToRGBA_SRGB: null;
  62229. jsMSCTranscoder: null;
  62230. wasmMSCTranscoder: null;
  62231. };
  62232. /**
  62233. * Default number of workers used to handle data decoding
  62234. */
  62235. static DefaultNumWorkers: number;
  62236. private static GetDefaultNumWorkers;
  62237. private _engine;
  62238. private static _CreateWorkerPool;
  62239. /**
  62240. * Constructor
  62241. * @param engine The engine to use
  62242. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62243. */
  62244. constructor(engine: ThinEngine, numWorkers?: number);
  62245. /** @hidden */
  62246. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62247. /**
  62248. * Stop all async operations and release resources.
  62249. */
  62250. dispose(): void;
  62251. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62252. /**
  62253. * Checks if the given data starts with a KTX2 file identifier.
  62254. * @param data the data to check
  62255. * @returns true if the data is a KTX2 file or false otherwise
  62256. */
  62257. static IsValid(data: ArrayBufferView): boolean;
  62258. }
  62259. }
  62260. declare module BABYLON {
  62261. /**
  62262. * Implementation of the KTX Texture Loader.
  62263. * @hidden
  62264. */
  62265. export class _KTXTextureLoader implements IInternalTextureLoader {
  62266. /**
  62267. * Defines wether the loader supports cascade loading the different faces.
  62268. */
  62269. readonly supportCascades: boolean;
  62270. /**
  62271. * This returns if the loader support the current file information.
  62272. * @param extension defines the file extension of the file being loaded
  62273. * @param mimeType defines the optional mime type of the file being loaded
  62274. * @returns true if the loader can load the specified file
  62275. */
  62276. canLoad(extension: string, mimeType?: string): boolean;
  62277. /**
  62278. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62279. * @param data contains the texture data
  62280. * @param texture defines the BabylonJS internal texture
  62281. * @param createPolynomials will be true if polynomials have been requested
  62282. * @param onLoad defines the callback to trigger once the texture is ready
  62283. * @param onError defines the callback to trigger in case of error
  62284. */
  62285. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62286. /**
  62287. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62288. * @param data contains the texture data
  62289. * @param texture defines the BabylonJS internal texture
  62290. * @param callback defines the method to call once ready to upload
  62291. */
  62292. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62293. }
  62294. }
  62295. declare module BABYLON {
  62296. /** @hidden */
  62297. export var _forceSceneHelpersToBundle: boolean;
  62298. interface Scene {
  62299. /**
  62300. * Creates a default light for the scene.
  62301. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62302. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62303. */
  62304. createDefaultLight(replace?: boolean): void;
  62305. /**
  62306. * Creates a default camera for the scene.
  62307. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62308. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62309. * @param replace has default false, when true replaces the active camera in the scene
  62310. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62311. */
  62312. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62313. /**
  62314. * Creates a default camera and a default light.
  62315. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62316. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62317. * @param replace has the default false, when true replaces the active camera/light in the scene
  62318. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62319. */
  62320. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62321. /**
  62322. * Creates a new sky box
  62323. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62324. * @param environmentTexture defines the texture to use as environment texture
  62325. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62326. * @param scale defines the overall scale of the skybox
  62327. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62328. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62329. * @returns a new mesh holding the sky box
  62330. */
  62331. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62332. /**
  62333. * Creates a new environment
  62334. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62335. * @param options defines the options you can use to configure the environment
  62336. * @returns the new EnvironmentHelper
  62337. */
  62338. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62339. /**
  62340. * Creates a new VREXperienceHelper
  62341. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62342. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62343. * @returns a new VREXperienceHelper
  62344. */
  62345. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62346. /**
  62347. * Creates a new WebXRDefaultExperience
  62348. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62349. * @param options experience options
  62350. * @returns a promise for a new WebXRDefaultExperience
  62351. */
  62352. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62353. }
  62354. }
  62355. declare module BABYLON {
  62356. /**
  62357. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62358. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62359. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62360. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62361. */
  62362. export class VideoDome extends TextureDome<VideoTexture> {
  62363. /**
  62364. * Define the video source as a Monoscopic panoramic 360 video.
  62365. */
  62366. static readonly MODE_MONOSCOPIC: number;
  62367. /**
  62368. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62369. */
  62370. static readonly MODE_TOPBOTTOM: number;
  62371. /**
  62372. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62373. */
  62374. static readonly MODE_SIDEBYSIDE: number;
  62375. /**
  62376. * Get the video texture associated with this video dome
  62377. */
  62378. get videoTexture(): VideoTexture;
  62379. /**
  62380. * Get the video mode of this dome
  62381. */
  62382. get videoMode(): number;
  62383. /**
  62384. * Set the video mode of this dome.
  62385. * @see textureMode
  62386. */
  62387. set videoMode(value: number);
  62388. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62389. }
  62390. }
  62391. declare module BABYLON {
  62392. /**
  62393. * This class can be used to get instrumentation data from a Babylon engine
  62394. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62395. */
  62396. export class EngineInstrumentation implements IDisposable {
  62397. /**
  62398. * Define the instrumented engine.
  62399. */
  62400. engine: Engine;
  62401. private _captureGPUFrameTime;
  62402. private _gpuFrameTimeToken;
  62403. private _gpuFrameTime;
  62404. private _captureShaderCompilationTime;
  62405. private _shaderCompilationTime;
  62406. private _onBeginFrameObserver;
  62407. private _onEndFrameObserver;
  62408. private _onBeforeShaderCompilationObserver;
  62409. private _onAfterShaderCompilationObserver;
  62410. /**
  62411. * Gets the perf counter used for GPU frame time
  62412. */
  62413. get gpuFrameTimeCounter(): PerfCounter;
  62414. /**
  62415. * Gets the GPU frame time capture status
  62416. */
  62417. get captureGPUFrameTime(): boolean;
  62418. /**
  62419. * Enable or disable the GPU frame time capture
  62420. */
  62421. set captureGPUFrameTime(value: boolean);
  62422. /**
  62423. * Gets the perf counter used for shader compilation time
  62424. */
  62425. get shaderCompilationTimeCounter(): PerfCounter;
  62426. /**
  62427. * Gets the shader compilation time capture status
  62428. */
  62429. get captureShaderCompilationTime(): boolean;
  62430. /**
  62431. * Enable or disable the shader compilation time capture
  62432. */
  62433. set captureShaderCompilationTime(value: boolean);
  62434. /**
  62435. * Instantiates a new engine instrumentation.
  62436. * This class can be used to get instrumentation data from a Babylon engine
  62437. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62438. * @param engine Defines the engine to instrument
  62439. */
  62440. constructor(
  62441. /**
  62442. * Define the instrumented engine.
  62443. */
  62444. engine: Engine);
  62445. /**
  62446. * Dispose and release associated resources.
  62447. */
  62448. dispose(): void;
  62449. }
  62450. }
  62451. declare module BABYLON {
  62452. /**
  62453. * This class can be used to get instrumentation data from a Babylon engine
  62454. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62455. */
  62456. export class SceneInstrumentation implements IDisposable {
  62457. /**
  62458. * Defines the scene to instrument
  62459. */
  62460. scene: Scene;
  62461. private _captureActiveMeshesEvaluationTime;
  62462. private _activeMeshesEvaluationTime;
  62463. private _captureRenderTargetsRenderTime;
  62464. private _renderTargetsRenderTime;
  62465. private _captureFrameTime;
  62466. private _frameTime;
  62467. private _captureRenderTime;
  62468. private _renderTime;
  62469. private _captureInterFrameTime;
  62470. private _interFrameTime;
  62471. private _captureParticlesRenderTime;
  62472. private _particlesRenderTime;
  62473. private _captureSpritesRenderTime;
  62474. private _spritesRenderTime;
  62475. private _capturePhysicsTime;
  62476. private _physicsTime;
  62477. private _captureAnimationsTime;
  62478. private _animationsTime;
  62479. private _captureCameraRenderTime;
  62480. private _cameraRenderTime;
  62481. private _onBeforeActiveMeshesEvaluationObserver;
  62482. private _onAfterActiveMeshesEvaluationObserver;
  62483. private _onBeforeRenderTargetsRenderObserver;
  62484. private _onAfterRenderTargetsRenderObserver;
  62485. private _onAfterRenderObserver;
  62486. private _onBeforeDrawPhaseObserver;
  62487. private _onAfterDrawPhaseObserver;
  62488. private _onBeforeAnimationsObserver;
  62489. private _onBeforeParticlesRenderingObserver;
  62490. private _onAfterParticlesRenderingObserver;
  62491. private _onBeforeSpritesRenderingObserver;
  62492. private _onAfterSpritesRenderingObserver;
  62493. private _onBeforePhysicsObserver;
  62494. private _onAfterPhysicsObserver;
  62495. private _onAfterAnimationsObserver;
  62496. private _onBeforeCameraRenderObserver;
  62497. private _onAfterCameraRenderObserver;
  62498. /**
  62499. * Gets the perf counter used for active meshes evaluation time
  62500. */
  62501. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62502. /**
  62503. * Gets the active meshes evaluation time capture status
  62504. */
  62505. get captureActiveMeshesEvaluationTime(): boolean;
  62506. /**
  62507. * Enable or disable the active meshes evaluation time capture
  62508. */
  62509. set captureActiveMeshesEvaluationTime(value: boolean);
  62510. /**
  62511. * Gets the perf counter used for render targets render time
  62512. */
  62513. get renderTargetsRenderTimeCounter(): PerfCounter;
  62514. /**
  62515. * Gets the render targets render time capture status
  62516. */
  62517. get captureRenderTargetsRenderTime(): boolean;
  62518. /**
  62519. * Enable or disable the render targets render time capture
  62520. */
  62521. set captureRenderTargetsRenderTime(value: boolean);
  62522. /**
  62523. * Gets the perf counter used for particles render time
  62524. */
  62525. get particlesRenderTimeCounter(): PerfCounter;
  62526. /**
  62527. * Gets the particles render time capture status
  62528. */
  62529. get captureParticlesRenderTime(): boolean;
  62530. /**
  62531. * Enable or disable the particles render time capture
  62532. */
  62533. set captureParticlesRenderTime(value: boolean);
  62534. /**
  62535. * Gets the perf counter used for sprites render time
  62536. */
  62537. get spritesRenderTimeCounter(): PerfCounter;
  62538. /**
  62539. * Gets the sprites render time capture status
  62540. */
  62541. get captureSpritesRenderTime(): boolean;
  62542. /**
  62543. * Enable or disable the sprites render time capture
  62544. */
  62545. set captureSpritesRenderTime(value: boolean);
  62546. /**
  62547. * Gets the perf counter used for physics time
  62548. */
  62549. get physicsTimeCounter(): PerfCounter;
  62550. /**
  62551. * Gets the physics time capture status
  62552. */
  62553. get capturePhysicsTime(): boolean;
  62554. /**
  62555. * Enable or disable the physics time capture
  62556. */
  62557. set capturePhysicsTime(value: boolean);
  62558. /**
  62559. * Gets the perf counter used for animations time
  62560. */
  62561. get animationsTimeCounter(): PerfCounter;
  62562. /**
  62563. * Gets the animations time capture status
  62564. */
  62565. get captureAnimationsTime(): boolean;
  62566. /**
  62567. * Enable or disable the animations time capture
  62568. */
  62569. set captureAnimationsTime(value: boolean);
  62570. /**
  62571. * Gets the perf counter used for frame time capture
  62572. */
  62573. get frameTimeCounter(): PerfCounter;
  62574. /**
  62575. * Gets the frame time capture status
  62576. */
  62577. get captureFrameTime(): boolean;
  62578. /**
  62579. * Enable or disable the frame time capture
  62580. */
  62581. set captureFrameTime(value: boolean);
  62582. /**
  62583. * Gets the perf counter used for inter-frames time capture
  62584. */
  62585. get interFrameTimeCounter(): PerfCounter;
  62586. /**
  62587. * Gets the inter-frames time capture status
  62588. */
  62589. get captureInterFrameTime(): boolean;
  62590. /**
  62591. * Enable or disable the inter-frames time capture
  62592. */
  62593. set captureInterFrameTime(value: boolean);
  62594. /**
  62595. * Gets the perf counter used for render time capture
  62596. */
  62597. get renderTimeCounter(): PerfCounter;
  62598. /**
  62599. * Gets the render time capture status
  62600. */
  62601. get captureRenderTime(): boolean;
  62602. /**
  62603. * Enable or disable the render time capture
  62604. */
  62605. set captureRenderTime(value: boolean);
  62606. /**
  62607. * Gets the perf counter used for camera render time capture
  62608. */
  62609. get cameraRenderTimeCounter(): PerfCounter;
  62610. /**
  62611. * Gets the camera render time capture status
  62612. */
  62613. get captureCameraRenderTime(): boolean;
  62614. /**
  62615. * Enable or disable the camera render time capture
  62616. */
  62617. set captureCameraRenderTime(value: boolean);
  62618. /**
  62619. * Gets the perf counter used for draw calls
  62620. */
  62621. get drawCallsCounter(): PerfCounter;
  62622. /**
  62623. * Instantiates a new scene instrumentation.
  62624. * This class can be used to get instrumentation data from a Babylon engine
  62625. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62626. * @param scene Defines the scene to instrument
  62627. */
  62628. constructor(
  62629. /**
  62630. * Defines the scene to instrument
  62631. */
  62632. scene: Scene);
  62633. /**
  62634. * Dispose and release associated resources.
  62635. */
  62636. dispose(): void;
  62637. }
  62638. }
  62639. declare module BABYLON {
  62640. /** @hidden */
  62641. export var glowMapGenerationPixelShader: {
  62642. name: string;
  62643. shader: string;
  62644. };
  62645. }
  62646. declare module BABYLON {
  62647. /** @hidden */
  62648. export var glowMapGenerationVertexShader: {
  62649. name: string;
  62650. shader: string;
  62651. };
  62652. }
  62653. declare module BABYLON {
  62654. /**
  62655. * Effect layer options. This helps customizing the behaviour
  62656. * of the effect layer.
  62657. */
  62658. export interface IEffectLayerOptions {
  62659. /**
  62660. * Multiplication factor apply to the canvas size to compute the render target size
  62661. * used to generated the objects (the smaller the faster).
  62662. */
  62663. mainTextureRatio: number;
  62664. /**
  62665. * Enforces a fixed size texture to ensure effect stability across devices.
  62666. */
  62667. mainTextureFixedSize?: number;
  62668. /**
  62669. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62670. */
  62671. alphaBlendingMode: number;
  62672. /**
  62673. * The camera attached to the layer.
  62674. */
  62675. camera: Nullable<Camera>;
  62676. /**
  62677. * The rendering group to draw the layer in.
  62678. */
  62679. renderingGroupId: number;
  62680. }
  62681. /**
  62682. * The effect layer Helps adding post process effect blended with the main pass.
  62683. *
  62684. * This can be for instance use to generate glow or higlight effects on the scene.
  62685. *
  62686. * The effect layer class can not be used directly and is intented to inherited from to be
  62687. * customized per effects.
  62688. */
  62689. export abstract class EffectLayer {
  62690. private _vertexBuffers;
  62691. private _indexBuffer;
  62692. private _cachedDefines;
  62693. private _effectLayerMapGenerationEffect;
  62694. private _effectLayerOptions;
  62695. private _mergeEffect;
  62696. protected _scene: Scene;
  62697. protected _engine: Engine;
  62698. protected _maxSize: number;
  62699. protected _mainTextureDesiredSize: ISize;
  62700. protected _mainTexture: RenderTargetTexture;
  62701. protected _shouldRender: boolean;
  62702. protected _postProcesses: PostProcess[];
  62703. protected _textures: BaseTexture[];
  62704. protected _emissiveTextureAndColor: {
  62705. texture: Nullable<BaseTexture>;
  62706. color: Color4;
  62707. };
  62708. /**
  62709. * The name of the layer
  62710. */
  62711. name: string;
  62712. /**
  62713. * The clear color of the texture used to generate the glow map.
  62714. */
  62715. neutralColor: Color4;
  62716. /**
  62717. * Specifies whether the highlight layer is enabled or not.
  62718. */
  62719. isEnabled: boolean;
  62720. /**
  62721. * Gets the camera attached to the layer.
  62722. */
  62723. get camera(): Nullable<Camera>;
  62724. /**
  62725. * Gets the rendering group id the layer should render in.
  62726. */
  62727. get renderingGroupId(): number;
  62728. set renderingGroupId(renderingGroupId: number);
  62729. /**
  62730. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62731. */
  62732. disableBoundingBoxesFromEffectLayer: boolean;
  62733. /**
  62734. * An event triggered when the effect layer has been disposed.
  62735. */
  62736. onDisposeObservable: Observable<EffectLayer>;
  62737. /**
  62738. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62739. */
  62740. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62741. /**
  62742. * An event triggered when the generated texture is being merged in the scene.
  62743. */
  62744. onBeforeComposeObservable: Observable<EffectLayer>;
  62745. /**
  62746. * An event triggered when the mesh is rendered into the effect render target.
  62747. */
  62748. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62749. /**
  62750. * An event triggered after the mesh has been rendered into the effect render target.
  62751. */
  62752. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62753. /**
  62754. * An event triggered when the generated texture has been merged in the scene.
  62755. */
  62756. onAfterComposeObservable: Observable<EffectLayer>;
  62757. /**
  62758. * An event triggered when the efffect layer changes its size.
  62759. */
  62760. onSizeChangedObservable: Observable<EffectLayer>;
  62761. /** @hidden */
  62762. static _SceneComponentInitialization: (scene: Scene) => void;
  62763. /**
  62764. * Instantiates a new effect Layer and references it in the scene.
  62765. * @param name The name of the layer
  62766. * @param scene The scene to use the layer in
  62767. */
  62768. constructor(
  62769. /** The Friendly of the effect in the scene */
  62770. name: string, scene: Scene);
  62771. /**
  62772. * Get the effect name of the layer.
  62773. * @return The effect name
  62774. */
  62775. abstract getEffectName(): string;
  62776. /**
  62777. * Checks for the readiness of the element composing the layer.
  62778. * @param subMesh the mesh to check for
  62779. * @param useInstances specify whether or not to use instances to render the mesh
  62780. * @return true if ready otherwise, false
  62781. */
  62782. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62783. /**
  62784. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62785. * @returns true if the effect requires stencil during the main canvas render pass.
  62786. */
  62787. abstract needStencil(): boolean;
  62788. /**
  62789. * Create the merge effect. This is the shader use to blit the information back
  62790. * to the main canvas at the end of the scene rendering.
  62791. * @returns The effect containing the shader used to merge the effect on the main canvas
  62792. */
  62793. protected abstract _createMergeEffect(): Effect;
  62794. /**
  62795. * Creates the render target textures and post processes used in the effect layer.
  62796. */
  62797. protected abstract _createTextureAndPostProcesses(): void;
  62798. /**
  62799. * Implementation specific of rendering the generating effect on the main canvas.
  62800. * @param effect The effect used to render through
  62801. */
  62802. protected abstract _internalRender(effect: Effect): void;
  62803. /**
  62804. * Sets the required values for both the emissive texture and and the main color.
  62805. */
  62806. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62807. /**
  62808. * Free any resources and references associated to a mesh.
  62809. * Internal use
  62810. * @param mesh The mesh to free.
  62811. */
  62812. abstract _disposeMesh(mesh: Mesh): void;
  62813. /**
  62814. * Serializes this layer (Glow or Highlight for example)
  62815. * @returns a serialized layer object
  62816. */
  62817. abstract serialize?(): any;
  62818. /**
  62819. * Initializes the effect layer with the required options.
  62820. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62821. */
  62822. protected _init(options: Partial<IEffectLayerOptions>): void;
  62823. /**
  62824. * Generates the index buffer of the full screen quad blending to the main canvas.
  62825. */
  62826. private _generateIndexBuffer;
  62827. /**
  62828. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62829. */
  62830. private _generateVertexBuffer;
  62831. /**
  62832. * Sets the main texture desired size which is the closest power of two
  62833. * of the engine canvas size.
  62834. */
  62835. private _setMainTextureSize;
  62836. /**
  62837. * Creates the main texture for the effect layer.
  62838. */
  62839. protected _createMainTexture(): void;
  62840. /**
  62841. * Adds specific effects defines.
  62842. * @param defines The defines to add specifics to.
  62843. */
  62844. protected _addCustomEffectDefines(defines: string[]): void;
  62845. /**
  62846. * Checks for the readiness of the element composing the layer.
  62847. * @param subMesh the mesh to check for
  62848. * @param useInstances specify whether or not to use instances to render the mesh
  62849. * @param emissiveTexture the associated emissive texture used to generate the glow
  62850. * @return true if ready otherwise, false
  62851. */
  62852. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62853. /**
  62854. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62855. */
  62856. render(): void;
  62857. /**
  62858. * Determine if a given mesh will be used in the current effect.
  62859. * @param mesh mesh to test
  62860. * @returns true if the mesh will be used
  62861. */
  62862. hasMesh(mesh: AbstractMesh): boolean;
  62863. /**
  62864. * Returns true if the layer contains information to display, otherwise false.
  62865. * @returns true if the glow layer should be rendered
  62866. */
  62867. shouldRender(): boolean;
  62868. /**
  62869. * Returns true if the mesh should render, otherwise false.
  62870. * @param mesh The mesh to render
  62871. * @returns true if it should render otherwise false
  62872. */
  62873. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62874. /**
  62875. * Returns true if the mesh can be rendered, otherwise false.
  62876. * @param mesh The mesh to render
  62877. * @param material The material used on the mesh
  62878. * @returns true if it can be rendered otherwise false
  62879. */
  62880. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62881. /**
  62882. * Returns true if the mesh should render, otherwise false.
  62883. * @param mesh The mesh to render
  62884. * @returns true if it should render otherwise false
  62885. */
  62886. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62887. /**
  62888. * Renders the submesh passed in parameter to the generation map.
  62889. */
  62890. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62891. /**
  62892. * Defines whether the current material of the mesh should be use to render the effect.
  62893. * @param mesh defines the current mesh to render
  62894. */
  62895. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62896. /**
  62897. * Rebuild the required buffers.
  62898. * @hidden Internal use only.
  62899. */
  62900. _rebuild(): void;
  62901. /**
  62902. * Dispose only the render target textures and post process.
  62903. */
  62904. private _disposeTextureAndPostProcesses;
  62905. /**
  62906. * Dispose the highlight layer and free resources.
  62907. */
  62908. dispose(): void;
  62909. /**
  62910. * Gets the class name of the effect layer
  62911. * @returns the string with the class name of the effect layer
  62912. */
  62913. getClassName(): string;
  62914. /**
  62915. * Creates an effect layer from parsed effect layer data
  62916. * @param parsedEffectLayer defines effect layer data
  62917. * @param scene defines the current scene
  62918. * @param rootUrl defines the root URL containing the effect layer information
  62919. * @returns a parsed effect Layer
  62920. */
  62921. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62922. }
  62923. }
  62924. declare module BABYLON {
  62925. interface AbstractScene {
  62926. /**
  62927. * The list of effect layers (highlights/glow) added to the scene
  62928. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62929. * @see https://doc.babylonjs.com/how_to/glow_layer
  62930. */
  62931. effectLayers: Array<EffectLayer>;
  62932. /**
  62933. * Removes the given effect layer from this scene.
  62934. * @param toRemove defines the effect layer to remove
  62935. * @returns the index of the removed effect layer
  62936. */
  62937. removeEffectLayer(toRemove: EffectLayer): number;
  62938. /**
  62939. * Adds the given effect layer to this scene
  62940. * @param newEffectLayer defines the effect layer to add
  62941. */
  62942. addEffectLayer(newEffectLayer: EffectLayer): void;
  62943. }
  62944. /**
  62945. * Defines the layer scene component responsible to manage any effect layers
  62946. * in a given scene.
  62947. */
  62948. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62949. /**
  62950. * The component name helpfull to identify the component in the list of scene components.
  62951. */
  62952. readonly name: string;
  62953. /**
  62954. * The scene the component belongs to.
  62955. */
  62956. scene: Scene;
  62957. private _engine;
  62958. private _renderEffects;
  62959. private _needStencil;
  62960. private _previousStencilState;
  62961. /**
  62962. * Creates a new instance of the component for the given scene
  62963. * @param scene Defines the scene to register the component in
  62964. */
  62965. constructor(scene: Scene);
  62966. /**
  62967. * Registers the component in a given scene
  62968. */
  62969. register(): void;
  62970. /**
  62971. * Rebuilds the elements related to this component in case of
  62972. * context lost for instance.
  62973. */
  62974. rebuild(): void;
  62975. /**
  62976. * Serializes the component data to the specified json object
  62977. * @param serializationObject The object to serialize to
  62978. */
  62979. serialize(serializationObject: any): void;
  62980. /**
  62981. * Adds all the elements from the container to the scene
  62982. * @param container the container holding the elements
  62983. */
  62984. addFromContainer(container: AbstractScene): void;
  62985. /**
  62986. * Removes all the elements in the container from the scene
  62987. * @param container contains the elements to remove
  62988. * @param dispose if the removed element should be disposed (default: false)
  62989. */
  62990. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62991. /**
  62992. * Disposes the component and the associated ressources.
  62993. */
  62994. dispose(): void;
  62995. private _isReadyForMesh;
  62996. private _renderMainTexture;
  62997. private _setStencil;
  62998. private _setStencilBack;
  62999. private _draw;
  63000. private _drawCamera;
  63001. private _drawRenderingGroup;
  63002. }
  63003. }
  63004. declare module BABYLON {
  63005. /** @hidden */
  63006. export var glowMapMergePixelShader: {
  63007. name: string;
  63008. shader: string;
  63009. };
  63010. }
  63011. declare module BABYLON {
  63012. /** @hidden */
  63013. export var glowMapMergeVertexShader: {
  63014. name: string;
  63015. shader: string;
  63016. };
  63017. }
  63018. declare module BABYLON {
  63019. interface AbstractScene {
  63020. /**
  63021. * Return a the first highlight layer of the scene with a given name.
  63022. * @param name The name of the highlight layer to look for.
  63023. * @return The highlight layer if found otherwise null.
  63024. */
  63025. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63026. }
  63027. /**
  63028. * Glow layer options. This helps customizing the behaviour
  63029. * of the glow layer.
  63030. */
  63031. export interface IGlowLayerOptions {
  63032. /**
  63033. * Multiplication factor apply to the canvas size to compute the render target size
  63034. * used to generated the glowing objects (the smaller the faster).
  63035. */
  63036. mainTextureRatio: number;
  63037. /**
  63038. * Enforces a fixed size texture to ensure resize independant blur.
  63039. */
  63040. mainTextureFixedSize?: number;
  63041. /**
  63042. * How big is the kernel of the blur texture.
  63043. */
  63044. blurKernelSize: number;
  63045. /**
  63046. * The camera attached to the layer.
  63047. */
  63048. camera: Nullable<Camera>;
  63049. /**
  63050. * Enable MSAA by chosing the number of samples.
  63051. */
  63052. mainTextureSamples?: number;
  63053. /**
  63054. * The rendering group to draw the layer in.
  63055. */
  63056. renderingGroupId: number;
  63057. }
  63058. /**
  63059. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63060. *
  63061. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63062. *
  63063. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63064. */
  63065. export class GlowLayer extends EffectLayer {
  63066. /**
  63067. * Effect Name of the layer.
  63068. */
  63069. static readonly EffectName: string;
  63070. /**
  63071. * The default blur kernel size used for the glow.
  63072. */
  63073. static DefaultBlurKernelSize: number;
  63074. /**
  63075. * The default texture size ratio used for the glow.
  63076. */
  63077. static DefaultTextureRatio: number;
  63078. /**
  63079. * Sets the kernel size of the blur.
  63080. */
  63081. set blurKernelSize(value: number);
  63082. /**
  63083. * Gets the kernel size of the blur.
  63084. */
  63085. get blurKernelSize(): number;
  63086. /**
  63087. * Sets the glow intensity.
  63088. */
  63089. set intensity(value: number);
  63090. /**
  63091. * Gets the glow intensity.
  63092. */
  63093. get intensity(): number;
  63094. private _options;
  63095. private _intensity;
  63096. private _horizontalBlurPostprocess1;
  63097. private _verticalBlurPostprocess1;
  63098. private _horizontalBlurPostprocess2;
  63099. private _verticalBlurPostprocess2;
  63100. private _blurTexture1;
  63101. private _blurTexture2;
  63102. private _postProcesses1;
  63103. private _postProcesses2;
  63104. private _includedOnlyMeshes;
  63105. private _excludedMeshes;
  63106. private _meshesUsingTheirOwnMaterials;
  63107. /**
  63108. * Callback used to let the user override the color selection on a per mesh basis
  63109. */
  63110. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63111. /**
  63112. * Callback used to let the user override the texture selection on a per mesh basis
  63113. */
  63114. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63115. /**
  63116. * Instantiates a new glow Layer and references it to the scene.
  63117. * @param name The name of the layer
  63118. * @param scene The scene to use the layer in
  63119. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63120. */
  63121. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63122. /**
  63123. * Get the effect name of the layer.
  63124. * @return The effect name
  63125. */
  63126. getEffectName(): string;
  63127. /**
  63128. * Create the merge effect. This is the shader use to blit the information back
  63129. * to the main canvas at the end of the scene rendering.
  63130. */
  63131. protected _createMergeEffect(): Effect;
  63132. /**
  63133. * Creates the render target textures and post processes used in the glow layer.
  63134. */
  63135. protected _createTextureAndPostProcesses(): void;
  63136. /**
  63137. * Checks for the readiness of the element composing the layer.
  63138. * @param subMesh the mesh to check for
  63139. * @param useInstances specify wether or not to use instances to render the mesh
  63140. * @param emissiveTexture the associated emissive texture used to generate the glow
  63141. * @return true if ready otherwise, false
  63142. */
  63143. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63144. /**
  63145. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63146. */
  63147. needStencil(): boolean;
  63148. /**
  63149. * Returns true if the mesh can be rendered, otherwise false.
  63150. * @param mesh The mesh to render
  63151. * @param material The material used on the mesh
  63152. * @returns true if it can be rendered otherwise false
  63153. */
  63154. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63155. /**
  63156. * Implementation specific of rendering the generating effect on the main canvas.
  63157. * @param effect The effect used to render through
  63158. */
  63159. protected _internalRender(effect: Effect): void;
  63160. /**
  63161. * Sets the required values for both the emissive texture and and the main color.
  63162. */
  63163. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63164. /**
  63165. * Returns true if the mesh should render, otherwise false.
  63166. * @param mesh The mesh to render
  63167. * @returns true if it should render otherwise false
  63168. */
  63169. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63170. /**
  63171. * Adds specific effects defines.
  63172. * @param defines The defines to add specifics to.
  63173. */
  63174. protected _addCustomEffectDefines(defines: string[]): void;
  63175. /**
  63176. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63177. * @param mesh The mesh to exclude from the glow layer
  63178. */
  63179. addExcludedMesh(mesh: Mesh): void;
  63180. /**
  63181. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63182. * @param mesh The mesh to remove
  63183. */
  63184. removeExcludedMesh(mesh: Mesh): void;
  63185. /**
  63186. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63187. * @param mesh The mesh to include in the glow layer
  63188. */
  63189. addIncludedOnlyMesh(mesh: Mesh): void;
  63190. /**
  63191. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63192. * @param mesh The mesh to remove
  63193. */
  63194. removeIncludedOnlyMesh(mesh: Mesh): void;
  63195. /**
  63196. * Determine if a given mesh will be used in the glow layer
  63197. * @param mesh The mesh to test
  63198. * @returns true if the mesh will be highlighted by the current glow layer
  63199. */
  63200. hasMesh(mesh: AbstractMesh): boolean;
  63201. /**
  63202. * Defines whether the current material of the mesh should be use to render the effect.
  63203. * @param mesh defines the current mesh to render
  63204. */
  63205. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63206. /**
  63207. * Add a mesh to be rendered through its own material and not with emissive only.
  63208. * @param mesh The mesh for which we need to use its material
  63209. */
  63210. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63211. /**
  63212. * Remove a mesh from being rendered through its own material and not with emissive only.
  63213. * @param mesh The mesh for which we need to not use its material
  63214. */
  63215. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63216. /**
  63217. * Free any resources and references associated to a mesh.
  63218. * Internal use
  63219. * @param mesh The mesh to free.
  63220. * @hidden
  63221. */
  63222. _disposeMesh(mesh: Mesh): void;
  63223. /**
  63224. * Gets the class name of the effect layer
  63225. * @returns the string with the class name of the effect layer
  63226. */
  63227. getClassName(): string;
  63228. /**
  63229. * Serializes this glow layer
  63230. * @returns a serialized glow layer object
  63231. */
  63232. serialize(): any;
  63233. /**
  63234. * Creates a Glow Layer from parsed glow layer data
  63235. * @param parsedGlowLayer defines glow layer data
  63236. * @param scene defines the current scene
  63237. * @param rootUrl defines the root URL containing the glow layer information
  63238. * @returns a parsed Glow Layer
  63239. */
  63240. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63241. }
  63242. }
  63243. declare module BABYLON {
  63244. /** @hidden */
  63245. export var glowBlurPostProcessPixelShader: {
  63246. name: string;
  63247. shader: string;
  63248. };
  63249. }
  63250. declare module BABYLON {
  63251. interface AbstractScene {
  63252. /**
  63253. * Return a the first highlight layer of the scene with a given name.
  63254. * @param name The name of the highlight layer to look for.
  63255. * @return The highlight layer if found otherwise null.
  63256. */
  63257. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63258. }
  63259. /**
  63260. * Highlight layer options. This helps customizing the behaviour
  63261. * of the highlight layer.
  63262. */
  63263. export interface IHighlightLayerOptions {
  63264. /**
  63265. * Multiplication factor apply to the canvas size to compute the render target size
  63266. * used to generated the glowing objects (the smaller the faster).
  63267. */
  63268. mainTextureRatio: number;
  63269. /**
  63270. * Enforces a fixed size texture to ensure resize independant blur.
  63271. */
  63272. mainTextureFixedSize?: number;
  63273. /**
  63274. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63275. * of the picture to blur (the smaller the faster).
  63276. */
  63277. blurTextureSizeRatio: number;
  63278. /**
  63279. * How big in texel of the blur texture is the vertical blur.
  63280. */
  63281. blurVerticalSize: number;
  63282. /**
  63283. * How big in texel of the blur texture is the horizontal blur.
  63284. */
  63285. blurHorizontalSize: number;
  63286. /**
  63287. * Alpha blending mode used to apply the blur. Default is combine.
  63288. */
  63289. alphaBlendingMode: number;
  63290. /**
  63291. * The camera attached to the layer.
  63292. */
  63293. camera: Nullable<Camera>;
  63294. /**
  63295. * Should we display highlight as a solid stroke?
  63296. */
  63297. isStroke?: boolean;
  63298. /**
  63299. * The rendering group to draw the layer in.
  63300. */
  63301. renderingGroupId: number;
  63302. }
  63303. /**
  63304. * The highlight layer Helps adding a glow effect around a mesh.
  63305. *
  63306. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63307. * glowy meshes to your scene.
  63308. *
  63309. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63310. */
  63311. export class HighlightLayer extends EffectLayer {
  63312. name: string;
  63313. /**
  63314. * Effect Name of the highlight layer.
  63315. */
  63316. static readonly EffectName: string;
  63317. /**
  63318. * The neutral color used during the preparation of the glow effect.
  63319. * This is black by default as the blend operation is a blend operation.
  63320. */
  63321. static NeutralColor: Color4;
  63322. /**
  63323. * Stencil value used for glowing meshes.
  63324. */
  63325. static GlowingMeshStencilReference: number;
  63326. /**
  63327. * Stencil value used for the other meshes in the scene.
  63328. */
  63329. static NormalMeshStencilReference: number;
  63330. /**
  63331. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63332. */
  63333. innerGlow: boolean;
  63334. /**
  63335. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63336. */
  63337. outerGlow: boolean;
  63338. /**
  63339. * Specifies the horizontal size of the blur.
  63340. */
  63341. set blurHorizontalSize(value: number);
  63342. /**
  63343. * Specifies the vertical size of the blur.
  63344. */
  63345. set blurVerticalSize(value: number);
  63346. /**
  63347. * Gets the horizontal size of the blur.
  63348. */
  63349. get blurHorizontalSize(): number;
  63350. /**
  63351. * Gets the vertical size of the blur.
  63352. */
  63353. get blurVerticalSize(): number;
  63354. /**
  63355. * An event triggered when the highlight layer is being blurred.
  63356. */
  63357. onBeforeBlurObservable: Observable<HighlightLayer>;
  63358. /**
  63359. * An event triggered when the highlight layer has been blurred.
  63360. */
  63361. onAfterBlurObservable: Observable<HighlightLayer>;
  63362. private _instanceGlowingMeshStencilReference;
  63363. private _options;
  63364. private _downSamplePostprocess;
  63365. private _horizontalBlurPostprocess;
  63366. private _verticalBlurPostprocess;
  63367. private _blurTexture;
  63368. private _meshes;
  63369. private _excludedMeshes;
  63370. /**
  63371. * Instantiates a new highlight Layer and references it to the scene..
  63372. * @param name The name of the layer
  63373. * @param scene The scene to use the layer in
  63374. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63375. */
  63376. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63377. /**
  63378. * Get the effect name of the layer.
  63379. * @return The effect name
  63380. */
  63381. getEffectName(): string;
  63382. /**
  63383. * Create the merge effect. This is the shader use to blit the information back
  63384. * to the main canvas at the end of the scene rendering.
  63385. */
  63386. protected _createMergeEffect(): Effect;
  63387. /**
  63388. * Creates the render target textures and post processes used in the highlight layer.
  63389. */
  63390. protected _createTextureAndPostProcesses(): void;
  63391. /**
  63392. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63393. */
  63394. needStencil(): boolean;
  63395. /**
  63396. * Checks for the readiness of the element composing the layer.
  63397. * @param subMesh the mesh to check for
  63398. * @param useInstances specify wether or not to use instances to render the mesh
  63399. * @param emissiveTexture the associated emissive texture used to generate the glow
  63400. * @return true if ready otherwise, false
  63401. */
  63402. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63403. /**
  63404. * Implementation specific of rendering the generating effect on the main canvas.
  63405. * @param effect The effect used to render through
  63406. */
  63407. protected _internalRender(effect: Effect): void;
  63408. /**
  63409. * Returns true if the layer contains information to display, otherwise false.
  63410. */
  63411. shouldRender(): boolean;
  63412. /**
  63413. * Returns true if the mesh should render, otherwise false.
  63414. * @param mesh The mesh to render
  63415. * @returns true if it should render otherwise false
  63416. */
  63417. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63418. /**
  63419. * Returns true if the mesh can be rendered, otherwise false.
  63420. * @param mesh The mesh to render
  63421. * @param material The material used on the mesh
  63422. * @returns true if it can be rendered otherwise false
  63423. */
  63424. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63425. /**
  63426. * Adds specific effects defines.
  63427. * @param defines The defines to add specifics to.
  63428. */
  63429. protected _addCustomEffectDefines(defines: string[]): void;
  63430. /**
  63431. * Sets the required values for both the emissive texture and and the main color.
  63432. */
  63433. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63434. /**
  63435. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63436. * @param mesh The mesh to exclude from the highlight layer
  63437. */
  63438. addExcludedMesh(mesh: Mesh): void;
  63439. /**
  63440. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63441. * @param mesh The mesh to highlight
  63442. */
  63443. removeExcludedMesh(mesh: Mesh): void;
  63444. /**
  63445. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63446. * @param mesh mesh to test
  63447. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63448. */
  63449. hasMesh(mesh: AbstractMesh): boolean;
  63450. /**
  63451. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63452. * @param mesh The mesh to highlight
  63453. * @param color The color of the highlight
  63454. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63455. */
  63456. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63457. /**
  63458. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63459. * @param mesh The mesh to highlight
  63460. */
  63461. removeMesh(mesh: Mesh): void;
  63462. /**
  63463. * Remove all the meshes currently referenced in the highlight layer
  63464. */
  63465. removeAllMeshes(): void;
  63466. /**
  63467. * Force the stencil to the normal expected value for none glowing parts
  63468. */
  63469. private _defaultStencilReference;
  63470. /**
  63471. * Free any resources and references associated to a mesh.
  63472. * Internal use
  63473. * @param mesh The mesh to free.
  63474. * @hidden
  63475. */
  63476. _disposeMesh(mesh: Mesh): void;
  63477. /**
  63478. * Dispose the highlight layer and free resources.
  63479. */
  63480. dispose(): void;
  63481. /**
  63482. * Gets the class name of the effect layer
  63483. * @returns the string with the class name of the effect layer
  63484. */
  63485. getClassName(): string;
  63486. /**
  63487. * Serializes this Highlight layer
  63488. * @returns a serialized Highlight layer object
  63489. */
  63490. serialize(): any;
  63491. /**
  63492. * Creates a Highlight layer from parsed Highlight layer data
  63493. * @param parsedHightlightLayer defines the Highlight layer data
  63494. * @param scene defines the current scene
  63495. * @param rootUrl defines the root URL containing the Highlight layer information
  63496. * @returns a parsed Highlight layer
  63497. */
  63498. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63499. }
  63500. }
  63501. declare module BABYLON {
  63502. interface AbstractScene {
  63503. /**
  63504. * The list of layers (background and foreground) of the scene
  63505. */
  63506. layers: Array<Layer>;
  63507. }
  63508. /**
  63509. * Defines the layer scene component responsible to manage any layers
  63510. * in a given scene.
  63511. */
  63512. export class LayerSceneComponent implements ISceneComponent {
  63513. /**
  63514. * The component name helpfull to identify the component in the list of scene components.
  63515. */
  63516. readonly name: string;
  63517. /**
  63518. * The scene the component belongs to.
  63519. */
  63520. scene: Scene;
  63521. private _engine;
  63522. /**
  63523. * Creates a new instance of the component for the given scene
  63524. * @param scene Defines the scene to register the component in
  63525. */
  63526. constructor(scene: Scene);
  63527. /**
  63528. * Registers the component in a given scene
  63529. */
  63530. register(): void;
  63531. /**
  63532. * Rebuilds the elements related to this component in case of
  63533. * context lost for instance.
  63534. */
  63535. rebuild(): void;
  63536. /**
  63537. * Disposes the component and the associated ressources.
  63538. */
  63539. dispose(): void;
  63540. private _draw;
  63541. private _drawCameraPredicate;
  63542. private _drawCameraBackground;
  63543. private _drawCameraForeground;
  63544. private _drawRenderTargetPredicate;
  63545. private _drawRenderTargetBackground;
  63546. private _drawRenderTargetForeground;
  63547. /**
  63548. * Adds all the elements from the container to the scene
  63549. * @param container the container holding the elements
  63550. */
  63551. addFromContainer(container: AbstractScene): void;
  63552. /**
  63553. * Removes all the elements in the container from the scene
  63554. * @param container contains the elements to remove
  63555. * @param dispose if the removed element should be disposed (default: false)
  63556. */
  63557. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63558. }
  63559. }
  63560. declare module BABYLON {
  63561. /** @hidden */
  63562. export var layerPixelShader: {
  63563. name: string;
  63564. shader: string;
  63565. };
  63566. }
  63567. declare module BABYLON {
  63568. /** @hidden */
  63569. export var layerVertexShader: {
  63570. name: string;
  63571. shader: string;
  63572. };
  63573. }
  63574. declare module BABYLON {
  63575. /**
  63576. * This represents a full screen 2d layer.
  63577. * This can be useful to display a picture in the background of your scene for instance.
  63578. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63579. */
  63580. export class Layer {
  63581. /**
  63582. * Define the name of the layer.
  63583. */
  63584. name: string;
  63585. /**
  63586. * Define the texture the layer should display.
  63587. */
  63588. texture: Nullable<Texture>;
  63589. /**
  63590. * Is the layer in background or foreground.
  63591. */
  63592. isBackground: boolean;
  63593. /**
  63594. * Define the color of the layer (instead of texture).
  63595. */
  63596. color: Color4;
  63597. /**
  63598. * Define the scale of the layer in order to zoom in out of the texture.
  63599. */
  63600. scale: Vector2;
  63601. /**
  63602. * Define an offset for the layer in order to shift the texture.
  63603. */
  63604. offset: Vector2;
  63605. /**
  63606. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63607. */
  63608. alphaBlendingMode: number;
  63609. /**
  63610. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63611. * Alpha test will not mix with the background color in case of transparency.
  63612. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63613. */
  63614. alphaTest: boolean;
  63615. /**
  63616. * Define a mask to restrict the layer to only some of the scene cameras.
  63617. */
  63618. layerMask: number;
  63619. /**
  63620. * Define the list of render target the layer is visible into.
  63621. */
  63622. renderTargetTextures: RenderTargetTexture[];
  63623. /**
  63624. * Define if the layer is only used in renderTarget or if it also
  63625. * renders in the main frame buffer of the canvas.
  63626. */
  63627. renderOnlyInRenderTargetTextures: boolean;
  63628. private _scene;
  63629. private _vertexBuffers;
  63630. private _indexBuffer;
  63631. private _effect;
  63632. private _previousDefines;
  63633. /**
  63634. * An event triggered when the layer is disposed.
  63635. */
  63636. onDisposeObservable: Observable<Layer>;
  63637. private _onDisposeObserver;
  63638. /**
  63639. * Back compatibility with callback before the onDisposeObservable existed.
  63640. * The set callback will be triggered when the layer has been disposed.
  63641. */
  63642. set onDispose(callback: () => void);
  63643. /**
  63644. * An event triggered before rendering the scene
  63645. */
  63646. onBeforeRenderObservable: Observable<Layer>;
  63647. private _onBeforeRenderObserver;
  63648. /**
  63649. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63650. * The set callback will be triggered just before rendering the layer.
  63651. */
  63652. set onBeforeRender(callback: () => void);
  63653. /**
  63654. * An event triggered after rendering the scene
  63655. */
  63656. onAfterRenderObservable: Observable<Layer>;
  63657. private _onAfterRenderObserver;
  63658. /**
  63659. * Back compatibility with callback before the onAfterRenderObservable existed.
  63660. * The set callback will be triggered just after rendering the layer.
  63661. */
  63662. set onAfterRender(callback: () => void);
  63663. /**
  63664. * Instantiates a new layer.
  63665. * This represents a full screen 2d layer.
  63666. * This can be useful to display a picture in the background of your scene for instance.
  63667. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63668. * @param name Define the name of the layer in the scene
  63669. * @param imgUrl Define the url of the texture to display in the layer
  63670. * @param scene Define the scene the layer belongs to
  63671. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63672. * @param color Defines a color for the layer
  63673. */
  63674. constructor(
  63675. /**
  63676. * Define the name of the layer.
  63677. */
  63678. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63679. private _createIndexBuffer;
  63680. /** @hidden */
  63681. _rebuild(): void;
  63682. /**
  63683. * Renders the layer in the scene.
  63684. */
  63685. render(): void;
  63686. /**
  63687. * Disposes and releases the associated ressources.
  63688. */
  63689. dispose(): void;
  63690. }
  63691. }
  63692. declare module BABYLON {
  63693. /** @hidden */
  63694. export var lensFlarePixelShader: {
  63695. name: string;
  63696. shader: string;
  63697. };
  63698. }
  63699. declare module BABYLON {
  63700. /** @hidden */
  63701. export var lensFlareVertexShader: {
  63702. name: string;
  63703. shader: string;
  63704. };
  63705. }
  63706. declare module BABYLON {
  63707. /**
  63708. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63709. * It is usually composed of several `lensFlare`.
  63710. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63711. */
  63712. export class LensFlareSystem {
  63713. /**
  63714. * Define the name of the lens flare system
  63715. */
  63716. name: string;
  63717. /**
  63718. * List of lens flares used in this system.
  63719. */
  63720. lensFlares: LensFlare[];
  63721. /**
  63722. * Define a limit from the border the lens flare can be visible.
  63723. */
  63724. borderLimit: number;
  63725. /**
  63726. * Define a viewport border we do not want to see the lens flare in.
  63727. */
  63728. viewportBorder: number;
  63729. /**
  63730. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63731. */
  63732. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63733. /**
  63734. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63735. */
  63736. layerMask: number;
  63737. /**
  63738. * Define the id of the lens flare system in the scene.
  63739. * (equal to name by default)
  63740. */
  63741. id: string;
  63742. private _scene;
  63743. private _emitter;
  63744. private _vertexBuffers;
  63745. private _indexBuffer;
  63746. private _effect;
  63747. private _positionX;
  63748. private _positionY;
  63749. private _isEnabled;
  63750. /** @hidden */
  63751. static _SceneComponentInitialization: (scene: Scene) => void;
  63752. /**
  63753. * Instantiates a lens flare system.
  63754. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63755. * It is usually composed of several `lensFlare`.
  63756. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63757. * @param name Define the name of the lens flare system in the scene
  63758. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63759. * @param scene Define the scene the lens flare system belongs to
  63760. */
  63761. constructor(
  63762. /**
  63763. * Define the name of the lens flare system
  63764. */
  63765. name: string, emitter: any, scene: Scene);
  63766. /**
  63767. * Define if the lens flare system is enabled.
  63768. */
  63769. get isEnabled(): boolean;
  63770. set isEnabled(value: boolean);
  63771. /**
  63772. * Get the scene the effects belongs to.
  63773. * @returns the scene holding the lens flare system
  63774. */
  63775. getScene(): Scene;
  63776. /**
  63777. * Get the emitter of the lens flare system.
  63778. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63779. * @returns the emitter of the lens flare system
  63780. */
  63781. getEmitter(): any;
  63782. /**
  63783. * Set the emitter of the lens flare system.
  63784. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63785. * @param newEmitter Define the new emitter of the system
  63786. */
  63787. setEmitter(newEmitter: any): void;
  63788. /**
  63789. * Get the lens flare system emitter position.
  63790. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63791. * @returns the position
  63792. */
  63793. getEmitterPosition(): Vector3;
  63794. /**
  63795. * @hidden
  63796. */
  63797. computeEffectivePosition(globalViewport: Viewport): boolean;
  63798. /** @hidden */
  63799. _isVisible(): boolean;
  63800. /**
  63801. * @hidden
  63802. */
  63803. render(): boolean;
  63804. /**
  63805. * Dispose and release the lens flare with its associated resources.
  63806. */
  63807. dispose(): void;
  63808. /**
  63809. * Parse a lens flare system from a JSON repressentation
  63810. * @param parsedLensFlareSystem Define the JSON to parse
  63811. * @param scene Define the scene the parsed system should be instantiated in
  63812. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63813. * @returns the parsed system
  63814. */
  63815. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63816. /**
  63817. * Serialize the current Lens Flare System into a JSON representation.
  63818. * @returns the serialized JSON
  63819. */
  63820. serialize(): any;
  63821. }
  63822. }
  63823. declare module BABYLON {
  63824. /**
  63825. * This represents one of the lens effect in a `lensFlareSystem`.
  63826. * It controls one of the indiviual texture used in the effect.
  63827. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63828. */
  63829. export class LensFlare {
  63830. /**
  63831. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63832. */
  63833. size: number;
  63834. /**
  63835. * 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.
  63836. */
  63837. position: number;
  63838. /**
  63839. * Define the lens color.
  63840. */
  63841. color: Color3;
  63842. /**
  63843. * Define the lens texture.
  63844. */
  63845. texture: Nullable<Texture>;
  63846. /**
  63847. * Define the alpha mode to render this particular lens.
  63848. */
  63849. alphaMode: number;
  63850. private _system;
  63851. /**
  63852. * Creates a new Lens Flare.
  63853. * This represents one of the lens effect in a `lensFlareSystem`.
  63854. * It controls one of the indiviual texture used in the effect.
  63855. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63856. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63857. * @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.
  63858. * @param color Define the lens color
  63859. * @param imgUrl Define the lens texture url
  63860. * @param system Define the `lensFlareSystem` this flare is part of
  63861. * @returns The newly created Lens Flare
  63862. */
  63863. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63864. /**
  63865. * Instantiates a new Lens Flare.
  63866. * This represents one of the lens effect in a `lensFlareSystem`.
  63867. * It controls one of the indiviual texture used in the effect.
  63868. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63869. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63870. * @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.
  63871. * @param color Define the lens color
  63872. * @param imgUrl Define the lens texture url
  63873. * @param system Define the `lensFlareSystem` this flare is part of
  63874. */
  63875. constructor(
  63876. /**
  63877. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63878. */
  63879. size: number,
  63880. /**
  63881. * 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.
  63882. */
  63883. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63884. /**
  63885. * Dispose and release the lens flare with its associated resources.
  63886. */
  63887. dispose(): void;
  63888. }
  63889. }
  63890. declare module BABYLON {
  63891. interface AbstractScene {
  63892. /**
  63893. * The list of lens flare system added to the scene
  63894. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63895. */
  63896. lensFlareSystems: Array<LensFlareSystem>;
  63897. /**
  63898. * Removes the given lens flare system from this scene.
  63899. * @param toRemove The lens flare system to remove
  63900. * @returns The index of the removed lens flare system
  63901. */
  63902. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63903. /**
  63904. * Adds the given lens flare system to this scene
  63905. * @param newLensFlareSystem The lens flare system to add
  63906. */
  63907. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63908. /**
  63909. * Gets a lens flare system using its name
  63910. * @param name defines the name to look for
  63911. * @returns the lens flare system or null if not found
  63912. */
  63913. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63914. /**
  63915. * Gets a lens flare system using its id
  63916. * @param id defines the id to look for
  63917. * @returns the lens flare system or null if not found
  63918. */
  63919. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63920. }
  63921. /**
  63922. * Defines the lens flare scene component responsible to manage any lens flares
  63923. * in a given scene.
  63924. */
  63925. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63926. /**
  63927. * The component name helpfull to identify the component in the list of scene components.
  63928. */
  63929. readonly name: string;
  63930. /**
  63931. * The scene the component belongs to.
  63932. */
  63933. scene: Scene;
  63934. /**
  63935. * Creates a new instance of the component for the given scene
  63936. * @param scene Defines the scene to register the component in
  63937. */
  63938. constructor(scene: Scene);
  63939. /**
  63940. * Registers the component in a given scene
  63941. */
  63942. register(): void;
  63943. /**
  63944. * Rebuilds the elements related to this component in case of
  63945. * context lost for instance.
  63946. */
  63947. rebuild(): void;
  63948. /**
  63949. * Adds all the elements from the container to the scene
  63950. * @param container the container holding the elements
  63951. */
  63952. addFromContainer(container: AbstractScene): void;
  63953. /**
  63954. * Removes all the elements in the container from the scene
  63955. * @param container contains the elements to remove
  63956. * @param dispose if the removed element should be disposed (default: false)
  63957. */
  63958. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63959. /**
  63960. * Serializes the component data to the specified json object
  63961. * @param serializationObject The object to serialize to
  63962. */
  63963. serialize(serializationObject: any): void;
  63964. /**
  63965. * Disposes the component and the associated ressources.
  63966. */
  63967. dispose(): void;
  63968. private _draw;
  63969. }
  63970. }
  63971. declare module BABYLON {
  63972. /** @hidden */
  63973. export var depthPixelShader: {
  63974. name: string;
  63975. shader: string;
  63976. };
  63977. }
  63978. declare module BABYLON {
  63979. /** @hidden */
  63980. export var depthVertexShader: {
  63981. name: string;
  63982. shader: string;
  63983. };
  63984. }
  63985. declare module BABYLON {
  63986. /**
  63987. * This represents a depth renderer in Babylon.
  63988. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63989. */
  63990. export class DepthRenderer {
  63991. private _scene;
  63992. private _depthMap;
  63993. private _effect;
  63994. private readonly _storeNonLinearDepth;
  63995. private readonly _clearColor;
  63996. /** Get if the depth renderer is using packed depth or not */
  63997. readonly isPacked: boolean;
  63998. private _cachedDefines;
  63999. private _camera;
  64000. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64001. enabled: boolean;
  64002. /**
  64003. * Specifiess that the depth renderer will only be used within
  64004. * the camera it is created for.
  64005. * This can help forcing its rendering during the camera processing.
  64006. */
  64007. useOnlyInActiveCamera: boolean;
  64008. /** @hidden */
  64009. static _SceneComponentInitialization: (scene: Scene) => void;
  64010. /**
  64011. * Instantiates a depth renderer
  64012. * @param scene The scene the renderer belongs to
  64013. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64014. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64015. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64016. */
  64017. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64018. /**
  64019. * Creates the depth rendering effect and checks if the effect is ready.
  64020. * @param subMesh The submesh to be used to render the depth map of
  64021. * @param useInstances If multiple world instances should be used
  64022. * @returns if the depth renderer is ready to render the depth map
  64023. */
  64024. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64025. /**
  64026. * Gets the texture which the depth map will be written to.
  64027. * @returns The depth map texture
  64028. */
  64029. getDepthMap(): RenderTargetTexture;
  64030. /**
  64031. * Disposes of the depth renderer.
  64032. */
  64033. dispose(): void;
  64034. }
  64035. }
  64036. declare module BABYLON {
  64037. /** @hidden */
  64038. export var minmaxReduxPixelShader: {
  64039. name: string;
  64040. shader: string;
  64041. };
  64042. }
  64043. declare module BABYLON {
  64044. /**
  64045. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64046. * and maximum values from all values of the texture.
  64047. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64048. * The source values are read from the red channel of the texture.
  64049. */
  64050. export class MinMaxReducer {
  64051. /**
  64052. * Observable triggered when the computation has been performed
  64053. */
  64054. onAfterReductionPerformed: Observable<{
  64055. min: number;
  64056. max: number;
  64057. }>;
  64058. protected _camera: Camera;
  64059. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64060. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64061. protected _postProcessManager: PostProcessManager;
  64062. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64063. protected _forceFullscreenViewport: boolean;
  64064. /**
  64065. * Creates a min/max reducer
  64066. * @param camera The camera to use for the post processes
  64067. */
  64068. constructor(camera: Camera);
  64069. /**
  64070. * Gets the texture used to read the values from.
  64071. */
  64072. get sourceTexture(): Nullable<RenderTargetTexture>;
  64073. /**
  64074. * Sets the source texture to read the values from.
  64075. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64076. * because in such textures '1' value must not be taken into account to compute the maximum
  64077. * as this value is used to clear the texture.
  64078. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64079. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64080. * @param depthRedux Indicates if the texture is a depth texture or not
  64081. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64082. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64083. */
  64084. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64085. /**
  64086. * Defines the refresh rate of the computation.
  64087. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64088. */
  64089. get refreshRate(): number;
  64090. set refreshRate(value: number);
  64091. protected _activated: boolean;
  64092. /**
  64093. * Gets the activation status of the reducer
  64094. */
  64095. get activated(): boolean;
  64096. /**
  64097. * Activates the reduction computation.
  64098. * When activated, the observers registered in onAfterReductionPerformed are
  64099. * called after the compuation is performed
  64100. */
  64101. activate(): void;
  64102. /**
  64103. * Deactivates the reduction computation.
  64104. */
  64105. deactivate(): void;
  64106. /**
  64107. * Disposes the min/max reducer
  64108. * @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.
  64109. */
  64110. dispose(disposeAll?: boolean): void;
  64111. }
  64112. }
  64113. declare module BABYLON {
  64114. /**
  64115. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64116. */
  64117. export class DepthReducer extends MinMaxReducer {
  64118. private _depthRenderer;
  64119. private _depthRendererId;
  64120. /**
  64121. * Gets the depth renderer used for the computation.
  64122. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64123. */
  64124. get depthRenderer(): Nullable<DepthRenderer>;
  64125. /**
  64126. * Creates a depth reducer
  64127. * @param camera The camera used to render the depth texture
  64128. */
  64129. constructor(camera: Camera);
  64130. /**
  64131. * Sets the depth renderer to use to generate the depth map
  64132. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64133. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64134. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64135. */
  64136. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64137. /** @hidden */
  64138. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64139. /**
  64140. * Activates the reduction computation.
  64141. * When activated, the observers registered in onAfterReductionPerformed are
  64142. * called after the compuation is performed
  64143. */
  64144. activate(): void;
  64145. /**
  64146. * Deactivates the reduction computation.
  64147. */
  64148. deactivate(): void;
  64149. /**
  64150. * Disposes the depth reducer
  64151. * @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.
  64152. */
  64153. dispose(disposeAll?: boolean): void;
  64154. }
  64155. }
  64156. declare module BABYLON {
  64157. /**
  64158. * A CSM implementation allowing casting shadows on large scenes.
  64159. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64160. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64161. */
  64162. export class CascadedShadowGenerator extends ShadowGenerator {
  64163. private static readonly frustumCornersNDCSpace;
  64164. /**
  64165. * Name of the CSM class
  64166. */
  64167. static CLASSNAME: string;
  64168. /**
  64169. * Defines the default number of cascades used by the CSM.
  64170. */
  64171. static readonly DEFAULT_CASCADES_COUNT: number;
  64172. /**
  64173. * Defines the minimum number of cascades used by the CSM.
  64174. */
  64175. static readonly MIN_CASCADES_COUNT: number;
  64176. /**
  64177. * Defines the maximum number of cascades used by the CSM.
  64178. */
  64179. static readonly MAX_CASCADES_COUNT: number;
  64180. protected _validateFilter(filter: number): number;
  64181. /**
  64182. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64183. */
  64184. penumbraDarkness: number;
  64185. private _numCascades;
  64186. /**
  64187. * Gets or set the number of cascades used by the CSM.
  64188. */
  64189. get numCascades(): number;
  64190. set numCascades(value: number);
  64191. /**
  64192. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64193. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64194. */
  64195. stabilizeCascades: boolean;
  64196. private _freezeShadowCastersBoundingInfo;
  64197. private _freezeShadowCastersBoundingInfoObservable;
  64198. /**
  64199. * Enables or disables the shadow casters bounding info computation.
  64200. * If your shadow casters don't move, you can disable this feature.
  64201. * If it is enabled, the bounding box computation is done every frame.
  64202. */
  64203. get freezeShadowCastersBoundingInfo(): boolean;
  64204. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64205. private _scbiMin;
  64206. private _scbiMax;
  64207. protected _computeShadowCastersBoundingInfo(): void;
  64208. protected _shadowCastersBoundingInfo: BoundingInfo;
  64209. /**
  64210. * Gets or sets the shadow casters bounding info.
  64211. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64212. * so that the system won't overwrite the bounds you provide
  64213. */
  64214. get shadowCastersBoundingInfo(): BoundingInfo;
  64215. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64216. protected _breaksAreDirty: boolean;
  64217. protected _minDistance: number;
  64218. protected _maxDistance: number;
  64219. /**
  64220. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64221. *
  64222. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64223. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64224. * @param min minimal distance for the breaks (default to 0.)
  64225. * @param max maximal distance for the breaks (default to 1.)
  64226. */
  64227. setMinMaxDistance(min: number, max: number): void;
  64228. /** Gets the minimal distance used in the cascade break computation */
  64229. get minDistance(): number;
  64230. /** Gets the maximal distance used in the cascade break computation */
  64231. get maxDistance(): number;
  64232. /**
  64233. * Gets the class name of that object
  64234. * @returns "CascadedShadowGenerator"
  64235. */
  64236. getClassName(): string;
  64237. private _cascadeMinExtents;
  64238. private _cascadeMaxExtents;
  64239. /**
  64240. * Gets a cascade minimum extents
  64241. * @param cascadeIndex index of the cascade
  64242. * @returns the minimum cascade extents
  64243. */
  64244. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64245. /**
  64246. * Gets a cascade maximum extents
  64247. * @param cascadeIndex index of the cascade
  64248. * @returns the maximum cascade extents
  64249. */
  64250. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64251. private _cascades;
  64252. private _currentLayer;
  64253. private _viewSpaceFrustumsZ;
  64254. private _viewMatrices;
  64255. private _projectionMatrices;
  64256. private _transformMatrices;
  64257. private _transformMatricesAsArray;
  64258. private _frustumLengths;
  64259. private _lightSizeUVCorrection;
  64260. private _depthCorrection;
  64261. private _frustumCornersWorldSpace;
  64262. private _frustumCenter;
  64263. private _shadowCameraPos;
  64264. private _shadowMaxZ;
  64265. /**
  64266. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64267. * It defaults to camera.maxZ
  64268. */
  64269. get shadowMaxZ(): number;
  64270. /**
  64271. * Sets the shadow max z distance.
  64272. */
  64273. set shadowMaxZ(value: number);
  64274. protected _debug: boolean;
  64275. /**
  64276. * Gets or sets the debug flag.
  64277. * When enabled, the cascades are materialized by different colors on the screen.
  64278. */
  64279. get debug(): boolean;
  64280. set debug(dbg: boolean);
  64281. private _depthClamp;
  64282. /**
  64283. * Gets or sets the depth clamping value.
  64284. *
  64285. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64286. * to account for the shadow casters far away.
  64287. *
  64288. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64289. */
  64290. get depthClamp(): boolean;
  64291. set depthClamp(value: boolean);
  64292. private _cascadeBlendPercentage;
  64293. /**
  64294. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64295. * It defaults to 0.1 (10% blending).
  64296. */
  64297. get cascadeBlendPercentage(): number;
  64298. set cascadeBlendPercentage(value: number);
  64299. private _lambda;
  64300. /**
  64301. * Gets or set the lambda parameter.
  64302. * This parameter is used to split the camera frustum and create the cascades.
  64303. * 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.
  64304. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64305. */
  64306. get lambda(): number;
  64307. set lambda(value: number);
  64308. /**
  64309. * Gets the view matrix corresponding to a given cascade
  64310. * @param cascadeNum cascade to retrieve the view matrix from
  64311. * @returns the cascade view matrix
  64312. */
  64313. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64314. /**
  64315. * Gets the projection matrix corresponding to a given cascade
  64316. * @param cascadeNum cascade to retrieve the projection matrix from
  64317. * @returns the cascade projection matrix
  64318. */
  64319. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64320. /**
  64321. * Gets the transformation matrix corresponding to a given cascade
  64322. * @param cascadeNum cascade to retrieve the transformation matrix from
  64323. * @returns the cascade transformation matrix
  64324. */
  64325. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64326. private _depthRenderer;
  64327. /**
  64328. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64329. *
  64330. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64331. *
  64332. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64333. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64334. * @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
  64335. */
  64336. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64337. private _depthReducer;
  64338. private _autoCalcDepthBounds;
  64339. /**
  64340. * Gets or sets the autoCalcDepthBounds property.
  64341. *
  64342. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64343. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64344. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64345. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64346. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64347. */
  64348. get autoCalcDepthBounds(): boolean;
  64349. set autoCalcDepthBounds(value: boolean);
  64350. /**
  64351. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64352. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64353. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64354. * for setting the refresh rate on the renderer yourself!
  64355. */
  64356. get autoCalcDepthBoundsRefreshRate(): number;
  64357. set autoCalcDepthBoundsRefreshRate(value: number);
  64358. /**
  64359. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64360. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64361. * you change the camera near/far planes!
  64362. */
  64363. splitFrustum(): void;
  64364. private _splitFrustum;
  64365. private _computeMatrices;
  64366. private _computeFrustumInWorldSpace;
  64367. private _computeCascadeFrustum;
  64368. /**
  64369. * Support test.
  64370. */
  64371. static get IsSupported(): boolean;
  64372. /** @hidden */
  64373. static _SceneComponentInitialization: (scene: Scene) => void;
  64374. /**
  64375. * Creates a Cascaded Shadow Generator object.
  64376. * A ShadowGenerator is the required tool to use the shadows.
  64377. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64378. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64379. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64380. * @param light The directional light object generating the shadows.
  64381. * @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.
  64382. */
  64383. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64384. protected _initializeGenerator(): void;
  64385. protected _createTargetRenderTexture(): void;
  64386. protected _initializeShadowMap(): void;
  64387. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64388. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64389. /**
  64390. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64391. * @param defines Defines of the material we want to update
  64392. * @param lightIndex Index of the light in the enabled light list of the material
  64393. */
  64394. prepareDefines(defines: any, lightIndex: number): void;
  64395. /**
  64396. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64397. * defined in the generator but impacting the effect).
  64398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64399. * @param effect The effect we are binfing the information for
  64400. */
  64401. bindShadowLight(lightIndex: string, effect: Effect): void;
  64402. /**
  64403. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64404. * (eq to view projection * shadow projection matrices)
  64405. * @returns The transform matrix used to create the shadow map
  64406. */
  64407. getTransformMatrix(): Matrix;
  64408. /**
  64409. * Disposes the ShadowGenerator.
  64410. * Returns nothing.
  64411. */
  64412. dispose(): void;
  64413. /**
  64414. * Serializes the shadow generator setup to a json object.
  64415. * @returns The serialized JSON object
  64416. */
  64417. serialize(): any;
  64418. /**
  64419. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64420. * @param parsedShadowGenerator The JSON object to parse
  64421. * @param scene The scene to create the shadow map for
  64422. * @returns The parsed shadow generator
  64423. */
  64424. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64425. }
  64426. }
  64427. declare module BABYLON {
  64428. /**
  64429. * Defines the shadow generator component responsible to manage any shadow generators
  64430. * in a given scene.
  64431. */
  64432. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64433. /**
  64434. * The component name helpfull to identify the component in the list of scene components.
  64435. */
  64436. readonly name: string;
  64437. /**
  64438. * The scene the component belongs to.
  64439. */
  64440. scene: Scene;
  64441. /**
  64442. * Creates a new instance of the component for the given scene
  64443. * @param scene Defines the scene to register the component in
  64444. */
  64445. constructor(scene: Scene);
  64446. /**
  64447. * Registers the component in a given scene
  64448. */
  64449. register(): void;
  64450. /**
  64451. * Rebuilds the elements related to this component in case of
  64452. * context lost for instance.
  64453. */
  64454. rebuild(): void;
  64455. /**
  64456. * Serializes the component data to the specified json object
  64457. * @param serializationObject The object to serialize to
  64458. */
  64459. serialize(serializationObject: any): void;
  64460. /**
  64461. * Adds all the elements from the container to the scene
  64462. * @param container the container holding the elements
  64463. */
  64464. addFromContainer(container: AbstractScene): void;
  64465. /**
  64466. * Removes all the elements in the container from the scene
  64467. * @param container contains the elements to remove
  64468. * @param dispose if the removed element should be disposed (default: false)
  64469. */
  64470. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64471. /**
  64472. * Rebuilds the elements related to this component in case of
  64473. * context lost for instance.
  64474. */
  64475. dispose(): void;
  64476. private _gatherRenderTargets;
  64477. }
  64478. }
  64479. declare module BABYLON {
  64480. /**
  64481. * A point light is a light defined by an unique point in world space.
  64482. * The light is emitted in every direction from this point.
  64483. * A good example of a point light is a standard light bulb.
  64484. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64485. */
  64486. export class PointLight extends ShadowLight {
  64487. private _shadowAngle;
  64488. /**
  64489. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64490. * This specifies what angle the shadow will use to be created.
  64491. *
  64492. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64493. */
  64494. get shadowAngle(): number;
  64495. /**
  64496. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64497. * This specifies what angle the shadow will use to be created.
  64498. *
  64499. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64500. */
  64501. set shadowAngle(value: number);
  64502. /**
  64503. * Gets the direction if it has been set.
  64504. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64505. */
  64506. get direction(): Vector3;
  64507. /**
  64508. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64509. */
  64510. set direction(value: Vector3);
  64511. /**
  64512. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64513. * A PointLight emits the light in every direction.
  64514. * It can cast shadows.
  64515. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64516. * ```javascript
  64517. * var pointLight = new PointLight("pl", camera.position, scene);
  64518. * ```
  64519. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64520. * @param name The light friendly name
  64521. * @param position The position of the point light in the scene
  64522. * @param scene The scene the lights belongs to
  64523. */
  64524. constructor(name: string, position: Vector3, scene: Scene);
  64525. /**
  64526. * Returns the string "PointLight"
  64527. * @returns the class name
  64528. */
  64529. getClassName(): string;
  64530. /**
  64531. * Returns the integer 0.
  64532. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64533. */
  64534. getTypeID(): number;
  64535. /**
  64536. * Specifies wether or not the shadowmap should be a cube texture.
  64537. * @returns true if the shadowmap needs to be a cube texture.
  64538. */
  64539. needCube(): boolean;
  64540. /**
  64541. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64542. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64543. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64544. */
  64545. getShadowDirection(faceIndex?: number): Vector3;
  64546. /**
  64547. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64548. * - fov = PI / 2
  64549. * - aspect ratio : 1.0
  64550. * - z-near and far equal to the active camera minZ and maxZ.
  64551. * Returns the PointLight.
  64552. */
  64553. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64554. protected _buildUniformLayout(): void;
  64555. /**
  64556. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64557. * @param effect The effect to update
  64558. * @param lightIndex The index of the light in the effect to update
  64559. * @returns The point light
  64560. */
  64561. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64562. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64563. /**
  64564. * Prepares the list of defines specific to the light type.
  64565. * @param defines the list of defines
  64566. * @param lightIndex defines the index of the light for the effect
  64567. */
  64568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64569. }
  64570. }
  64571. declare module BABYLON {
  64572. /**
  64573. * Header information of HDR texture files.
  64574. */
  64575. export interface HDRInfo {
  64576. /**
  64577. * The height of the texture in pixels.
  64578. */
  64579. height: number;
  64580. /**
  64581. * The width of the texture in pixels.
  64582. */
  64583. width: number;
  64584. /**
  64585. * The index of the beginning of the data in the binary file.
  64586. */
  64587. dataPosition: number;
  64588. }
  64589. /**
  64590. * This groups tools to convert HDR texture to native colors array.
  64591. */
  64592. export class HDRTools {
  64593. private static Ldexp;
  64594. private static Rgbe2float;
  64595. private static readStringLine;
  64596. /**
  64597. * Reads header information from an RGBE texture stored in a native array.
  64598. * More information on this format are available here:
  64599. * https://en.wikipedia.org/wiki/RGBE_image_format
  64600. *
  64601. * @param uint8array The binary file stored in native array.
  64602. * @return The header information.
  64603. */
  64604. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64605. /**
  64606. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64607. * This RGBE texture needs to store the information as a panorama.
  64608. *
  64609. * More information on this format are available here:
  64610. * https://en.wikipedia.org/wiki/RGBE_image_format
  64611. *
  64612. * @param buffer The binary file stored in an array buffer.
  64613. * @param size The expected size of the extracted cubemap.
  64614. * @return The Cube Map information.
  64615. */
  64616. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64617. /**
  64618. * Returns the pixels data extracted from an RGBE texture.
  64619. * This pixels will be stored left to right up to down in the R G B order in one array.
  64620. *
  64621. * More information on this format are available here:
  64622. * https://en.wikipedia.org/wiki/RGBE_image_format
  64623. *
  64624. * @param uint8array The binary file stored in an array buffer.
  64625. * @param hdrInfo The header information of the file.
  64626. * @return The pixels data in RGB right to left up to down order.
  64627. */
  64628. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64629. private static RGBE_ReadPixels_RLE;
  64630. private static RGBE_ReadPixels_NOT_RLE;
  64631. }
  64632. }
  64633. declare module BABYLON {
  64634. /**
  64635. * Effect Render Options
  64636. */
  64637. export interface IEffectRendererOptions {
  64638. /**
  64639. * Defines the vertices positions.
  64640. */
  64641. positions?: number[];
  64642. /**
  64643. * Defines the indices.
  64644. */
  64645. indices?: number[];
  64646. }
  64647. /**
  64648. * Helper class to render one or more effects.
  64649. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64650. */
  64651. export class EffectRenderer {
  64652. private engine;
  64653. private static _DefaultOptions;
  64654. private _vertexBuffers;
  64655. private _indexBuffer;
  64656. private _fullscreenViewport;
  64657. /**
  64658. * Creates an effect renderer
  64659. * @param engine the engine to use for rendering
  64660. * @param options defines the options of the effect renderer
  64661. */
  64662. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64663. /**
  64664. * Sets the current viewport in normalized coordinates 0-1
  64665. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64666. */
  64667. setViewport(viewport?: Viewport): void;
  64668. /**
  64669. * Binds the embedded attributes buffer to the effect.
  64670. * @param effect Defines the effect to bind the attributes for
  64671. */
  64672. bindBuffers(effect: Effect): void;
  64673. /**
  64674. * Sets the current effect wrapper to use during draw.
  64675. * The effect needs to be ready before calling this api.
  64676. * This also sets the default full screen position attribute.
  64677. * @param effectWrapper Defines the effect to draw with
  64678. */
  64679. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64680. /**
  64681. * Restores engine states
  64682. */
  64683. restoreStates(): void;
  64684. /**
  64685. * Draws a full screen quad.
  64686. */
  64687. draw(): void;
  64688. private isRenderTargetTexture;
  64689. /**
  64690. * renders one or more effects to a specified texture
  64691. * @param effectWrapper the effect to renderer
  64692. * @param outputTexture texture to draw to, if null it will render to the screen.
  64693. */
  64694. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64695. /**
  64696. * Disposes of the effect renderer
  64697. */
  64698. dispose(): void;
  64699. }
  64700. /**
  64701. * Options to create an EffectWrapper
  64702. */
  64703. interface EffectWrapperCreationOptions {
  64704. /**
  64705. * Engine to use to create the effect
  64706. */
  64707. engine: ThinEngine;
  64708. /**
  64709. * Fragment shader for the effect
  64710. */
  64711. fragmentShader: string;
  64712. /**
  64713. * Use the shader store instead of direct source code
  64714. */
  64715. useShaderStore?: boolean;
  64716. /**
  64717. * Vertex shader for the effect
  64718. */
  64719. vertexShader?: string;
  64720. /**
  64721. * Attributes to use in the shader
  64722. */
  64723. attributeNames?: Array<string>;
  64724. /**
  64725. * Uniforms to use in the shader
  64726. */
  64727. uniformNames?: Array<string>;
  64728. /**
  64729. * Texture sampler names to use in the shader
  64730. */
  64731. samplerNames?: Array<string>;
  64732. /**
  64733. * Defines to use in the shader
  64734. */
  64735. defines?: Array<string>;
  64736. /**
  64737. * Callback when effect is compiled
  64738. */
  64739. onCompiled?: Nullable<(effect: Effect) => void>;
  64740. /**
  64741. * The friendly name of the effect displayed in Spector.
  64742. */
  64743. name?: string;
  64744. }
  64745. /**
  64746. * Wraps an effect to be used for rendering
  64747. */
  64748. export class EffectWrapper {
  64749. /**
  64750. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64751. */
  64752. onApplyObservable: Observable<{}>;
  64753. /**
  64754. * The underlying effect
  64755. */
  64756. effect: Effect;
  64757. /**
  64758. * Creates an effect to be renderer
  64759. * @param creationOptions options to create the effect
  64760. */
  64761. constructor(creationOptions: EffectWrapperCreationOptions);
  64762. /**
  64763. * Disposes of the effect wrapper
  64764. */
  64765. dispose(): void;
  64766. }
  64767. }
  64768. declare module BABYLON {
  64769. /** @hidden */
  64770. export var hdrFilteringVertexShader: {
  64771. name: string;
  64772. shader: string;
  64773. };
  64774. }
  64775. declare module BABYLON {
  64776. /** @hidden */
  64777. export var hdrFilteringPixelShader: {
  64778. name: string;
  64779. shader: string;
  64780. };
  64781. }
  64782. declare module BABYLON {
  64783. /**
  64784. * Options for texture filtering
  64785. */
  64786. interface IHDRFilteringOptions {
  64787. /**
  64788. * Scales pixel intensity for the input HDR map.
  64789. */
  64790. hdrScale?: number;
  64791. /**
  64792. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64793. */
  64794. quality?: number;
  64795. }
  64796. /**
  64797. * Filters HDR maps to get correct renderings of PBR reflections
  64798. */
  64799. export class HDRFiltering {
  64800. private _engine;
  64801. private _effectRenderer;
  64802. private _effectWrapper;
  64803. private _lodGenerationOffset;
  64804. private _lodGenerationScale;
  64805. /**
  64806. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64807. * you care about baking speed.
  64808. */
  64809. quality: number;
  64810. /**
  64811. * Scales pixel intensity for the input HDR map.
  64812. */
  64813. hdrScale: number;
  64814. /**
  64815. * Instantiates HDR filter for reflection maps
  64816. *
  64817. * @param engine Thin engine
  64818. * @param options Options
  64819. */
  64820. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64821. private _createRenderTarget;
  64822. private _prefilterInternal;
  64823. private _createEffect;
  64824. /**
  64825. * Get a value indicating if the filter is ready to be used
  64826. * @param texture Texture to filter
  64827. * @returns true if the filter is ready
  64828. */
  64829. isReady(texture: BaseTexture): boolean;
  64830. /**
  64831. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64832. * Prefiltering will be invoked at the end of next rendering pass.
  64833. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64834. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64835. * @param texture Texture to filter
  64836. * @param onFinished Callback when filtering is done
  64837. * @return Promise called when prefiltering is done
  64838. */
  64839. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64840. }
  64841. }
  64842. declare module BABYLON {
  64843. /**
  64844. * This represents a texture coming from an HDR input.
  64845. *
  64846. * The only supported format is currently panorama picture stored in RGBE format.
  64847. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64848. */
  64849. export class HDRCubeTexture extends BaseTexture {
  64850. private static _facesMapping;
  64851. private _generateHarmonics;
  64852. private _noMipmap;
  64853. private _prefilterOnLoad;
  64854. private _textureMatrix;
  64855. private _size;
  64856. private _onLoad;
  64857. private _onError;
  64858. /**
  64859. * The texture URL.
  64860. */
  64861. url: string;
  64862. protected _isBlocking: boolean;
  64863. /**
  64864. * Sets wether or not the texture is blocking during loading.
  64865. */
  64866. set isBlocking(value: boolean);
  64867. /**
  64868. * Gets wether or not the texture is blocking during loading.
  64869. */
  64870. get isBlocking(): boolean;
  64871. protected _rotationY: number;
  64872. /**
  64873. * Sets texture matrix rotation angle around Y axis in radians.
  64874. */
  64875. set rotationY(value: number);
  64876. /**
  64877. * Gets texture matrix rotation angle around Y axis radians.
  64878. */
  64879. get rotationY(): number;
  64880. /**
  64881. * Gets or sets the center of the bounding box associated with the cube texture
  64882. * It must define where the camera used to render the texture was set
  64883. */
  64884. boundingBoxPosition: Vector3;
  64885. private _boundingBoxSize;
  64886. /**
  64887. * Gets or sets the size of the bounding box associated with the cube texture
  64888. * When defined, the cubemap will switch to local mode
  64889. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64890. * @example https://www.babylonjs-playground.com/#RNASML
  64891. */
  64892. set boundingBoxSize(value: Vector3);
  64893. get boundingBoxSize(): Vector3;
  64894. /**
  64895. * Instantiates an HDRTexture from the following parameters.
  64896. *
  64897. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64898. * @param sceneOrEngine The scene or engine the texture will be used in
  64899. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64900. * @param noMipmap Forces to not generate the mipmap if true
  64901. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64902. * @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)
  64903. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64904. */
  64905. 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>);
  64906. /**
  64907. * Get the current class name of the texture useful for serialization or dynamic coding.
  64908. * @returns "HDRCubeTexture"
  64909. */
  64910. getClassName(): string;
  64911. /**
  64912. * Occurs when the file is raw .hdr file.
  64913. */
  64914. private loadTexture;
  64915. clone(): HDRCubeTexture;
  64916. delayLoad(): void;
  64917. /**
  64918. * Get the texture reflection matrix used to rotate/transform the reflection.
  64919. * @returns the reflection matrix
  64920. */
  64921. getReflectionTextureMatrix(): Matrix;
  64922. /**
  64923. * Set the texture reflection matrix used to rotate/transform the reflection.
  64924. * @param value Define the reflection matrix to set
  64925. */
  64926. setReflectionTextureMatrix(value: Matrix): void;
  64927. /**
  64928. * Parses a JSON representation of an HDR Texture in order to create the texture
  64929. * @param parsedTexture Define the JSON representation
  64930. * @param scene Define the scene the texture should be created in
  64931. * @param rootUrl Define the root url in case we need to load relative dependencies
  64932. * @returns the newly created texture after parsing
  64933. */
  64934. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64935. serialize(): any;
  64936. }
  64937. }
  64938. declare module BABYLON {
  64939. /**
  64940. * Class used to control physics engine
  64941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64942. */
  64943. export class PhysicsEngine implements IPhysicsEngine {
  64944. private _physicsPlugin;
  64945. /**
  64946. * Global value used to control the smallest number supported by the simulation
  64947. */
  64948. static Epsilon: number;
  64949. private _impostors;
  64950. private _joints;
  64951. private _subTimeStep;
  64952. /**
  64953. * Gets the gravity vector used by the simulation
  64954. */
  64955. gravity: Vector3;
  64956. /**
  64957. * Factory used to create the default physics plugin.
  64958. * @returns The default physics plugin
  64959. */
  64960. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64961. /**
  64962. * Creates a new Physics Engine
  64963. * @param gravity defines the gravity vector used by the simulation
  64964. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64965. */
  64966. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64967. /**
  64968. * Sets the gravity vector used by the simulation
  64969. * @param gravity defines the gravity vector to use
  64970. */
  64971. setGravity(gravity: Vector3): void;
  64972. /**
  64973. * Set the time step of the physics engine.
  64974. * Default is 1/60.
  64975. * To slow it down, enter 1/600 for example.
  64976. * To speed it up, 1/30
  64977. * @param newTimeStep defines the new timestep to apply to this world.
  64978. */
  64979. setTimeStep(newTimeStep?: number): void;
  64980. /**
  64981. * Get the time step of the physics engine.
  64982. * @returns the current time step
  64983. */
  64984. getTimeStep(): number;
  64985. /**
  64986. * Set the sub time step of the physics engine.
  64987. * Default is 0 meaning there is no sub steps
  64988. * To increase physics resolution precision, set a small value (like 1 ms)
  64989. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64990. */
  64991. setSubTimeStep(subTimeStep?: number): void;
  64992. /**
  64993. * Get the sub time step of the physics engine.
  64994. * @returns the current sub time step
  64995. */
  64996. getSubTimeStep(): number;
  64997. /**
  64998. * Release all resources
  64999. */
  65000. dispose(): void;
  65001. /**
  65002. * Gets the name of the current physics plugin
  65003. * @returns the name of the plugin
  65004. */
  65005. getPhysicsPluginName(): string;
  65006. /**
  65007. * Adding a new impostor for the impostor tracking.
  65008. * This will be done by the impostor itself.
  65009. * @param impostor the impostor to add
  65010. */
  65011. addImpostor(impostor: PhysicsImpostor): void;
  65012. /**
  65013. * Remove an impostor from the engine.
  65014. * This impostor and its mesh will not longer be updated by the physics engine.
  65015. * @param impostor the impostor to remove
  65016. */
  65017. removeImpostor(impostor: PhysicsImpostor): void;
  65018. /**
  65019. * Add a joint to the physics engine
  65020. * @param mainImpostor defines the main impostor to which the joint is added.
  65021. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65022. * @param joint defines the joint that will connect both impostors.
  65023. */
  65024. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65025. /**
  65026. * Removes a joint from the simulation
  65027. * @param mainImpostor defines the impostor used with the joint
  65028. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65029. * @param joint defines the joint to remove
  65030. */
  65031. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65032. /**
  65033. * Called by the scene. No need to call it.
  65034. * @param delta defines the timespam between frames
  65035. */
  65036. _step(delta: number): void;
  65037. /**
  65038. * Gets the current plugin used to run the simulation
  65039. * @returns current plugin
  65040. */
  65041. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65042. /**
  65043. * Gets the list of physic impostors
  65044. * @returns an array of PhysicsImpostor
  65045. */
  65046. getImpostors(): Array<PhysicsImpostor>;
  65047. /**
  65048. * Gets the impostor for a physics enabled object
  65049. * @param object defines the object impersonated by the impostor
  65050. * @returns the PhysicsImpostor or null if not found
  65051. */
  65052. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65053. /**
  65054. * Gets the impostor for a physics body object
  65055. * @param body defines physics body used by the impostor
  65056. * @returns the PhysicsImpostor or null if not found
  65057. */
  65058. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65059. /**
  65060. * Does a raycast in the physics world
  65061. * @param from when should the ray start?
  65062. * @param to when should the ray end?
  65063. * @returns PhysicsRaycastResult
  65064. */
  65065. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65066. }
  65067. }
  65068. declare module BABYLON {
  65069. /** @hidden */
  65070. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65071. private _useDeltaForWorldStep;
  65072. world: any;
  65073. name: string;
  65074. private _physicsMaterials;
  65075. private _fixedTimeStep;
  65076. private _cannonRaycastResult;
  65077. private _raycastResult;
  65078. private _physicsBodysToRemoveAfterStep;
  65079. private _firstFrame;
  65080. BJSCANNON: any;
  65081. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65082. setGravity(gravity: Vector3): void;
  65083. setTimeStep(timeStep: number): void;
  65084. getTimeStep(): number;
  65085. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65086. private _removeMarkedPhysicsBodiesFromWorld;
  65087. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65088. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65089. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65090. private _processChildMeshes;
  65091. removePhysicsBody(impostor: PhysicsImpostor): void;
  65092. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65093. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65094. private _addMaterial;
  65095. private _checkWithEpsilon;
  65096. private _createShape;
  65097. private _createHeightmap;
  65098. private _minus90X;
  65099. private _plus90X;
  65100. private _tmpPosition;
  65101. private _tmpDeltaPosition;
  65102. private _tmpUnityRotation;
  65103. private _updatePhysicsBodyTransformation;
  65104. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65105. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65106. isSupported(): boolean;
  65107. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65108. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65109. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65110. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65111. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65112. getBodyMass(impostor: PhysicsImpostor): number;
  65113. getBodyFriction(impostor: PhysicsImpostor): number;
  65114. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65115. getBodyRestitution(impostor: PhysicsImpostor): number;
  65116. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65117. sleepBody(impostor: PhysicsImpostor): void;
  65118. wakeUpBody(impostor: PhysicsImpostor): void;
  65119. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65120. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65121. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65122. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65123. getRadius(impostor: PhysicsImpostor): number;
  65124. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65125. dispose(): void;
  65126. private _extendNamespace;
  65127. /**
  65128. * Does a raycast in the physics world
  65129. * @param from when should the ray start?
  65130. * @param to when should the ray end?
  65131. * @returns PhysicsRaycastResult
  65132. */
  65133. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /** @hidden */
  65138. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65139. private _useDeltaForWorldStep;
  65140. world: any;
  65141. name: string;
  65142. BJSOIMO: any;
  65143. private _raycastResult;
  65144. private _fixedTimeStep;
  65145. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65146. setGravity(gravity: Vector3): void;
  65147. setTimeStep(timeStep: number): void;
  65148. getTimeStep(): number;
  65149. private _tmpImpostorsArray;
  65150. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65151. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65152. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65154. private _tmpPositionVector;
  65155. removePhysicsBody(impostor: PhysicsImpostor): void;
  65156. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65157. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65158. isSupported(): boolean;
  65159. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65160. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65161. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65162. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65163. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65164. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65165. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65166. getBodyMass(impostor: PhysicsImpostor): number;
  65167. getBodyFriction(impostor: PhysicsImpostor): number;
  65168. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65169. getBodyRestitution(impostor: PhysicsImpostor): number;
  65170. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65171. sleepBody(impostor: PhysicsImpostor): void;
  65172. wakeUpBody(impostor: PhysicsImpostor): void;
  65173. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65174. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65175. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65176. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65177. getRadius(impostor: PhysicsImpostor): number;
  65178. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65179. dispose(): void;
  65180. /**
  65181. * Does a raycast in the physics world
  65182. * @param from when should the ray start?
  65183. * @param to when should the ray end?
  65184. * @returns PhysicsRaycastResult
  65185. */
  65186. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65187. }
  65188. }
  65189. declare module BABYLON {
  65190. /**
  65191. * AmmoJS Physics plugin
  65192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65193. * @see https://github.com/kripken/ammo.js/
  65194. */
  65195. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65196. private _useDeltaForWorldStep;
  65197. /**
  65198. * Reference to the Ammo library
  65199. */
  65200. bjsAMMO: any;
  65201. /**
  65202. * Created ammoJS world which physics bodies are added to
  65203. */
  65204. world: any;
  65205. /**
  65206. * Name of the plugin
  65207. */
  65208. name: string;
  65209. private _timeStep;
  65210. private _fixedTimeStep;
  65211. private _maxSteps;
  65212. private _tmpQuaternion;
  65213. private _tmpAmmoTransform;
  65214. private _tmpAmmoQuaternion;
  65215. private _tmpAmmoConcreteContactResultCallback;
  65216. private _collisionConfiguration;
  65217. private _dispatcher;
  65218. private _overlappingPairCache;
  65219. private _solver;
  65220. private _softBodySolver;
  65221. private _tmpAmmoVectorA;
  65222. private _tmpAmmoVectorB;
  65223. private _tmpAmmoVectorC;
  65224. private _tmpAmmoVectorD;
  65225. private _tmpContactCallbackResult;
  65226. private _tmpAmmoVectorRCA;
  65227. private _tmpAmmoVectorRCB;
  65228. private _raycastResult;
  65229. private _tmpContactPoint;
  65230. private static readonly DISABLE_COLLISION_FLAG;
  65231. private static readonly KINEMATIC_FLAG;
  65232. private static readonly DISABLE_DEACTIVATION_FLAG;
  65233. /**
  65234. * Initializes the ammoJS plugin
  65235. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65236. * @param ammoInjection can be used to inject your own ammo reference
  65237. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65238. */
  65239. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65240. /**
  65241. * Sets the gravity of the physics world (m/(s^2))
  65242. * @param gravity Gravity to set
  65243. */
  65244. setGravity(gravity: Vector3): void;
  65245. /**
  65246. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65247. * @param timeStep timestep to use in seconds
  65248. */
  65249. setTimeStep(timeStep: number): void;
  65250. /**
  65251. * 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)
  65252. * @param fixedTimeStep fixedTimeStep to use in seconds
  65253. */
  65254. setFixedTimeStep(fixedTimeStep: number): void;
  65255. /**
  65256. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65257. * @param maxSteps the maximum number of steps by the physics engine per frame
  65258. */
  65259. setMaxSteps(maxSteps: number): void;
  65260. /**
  65261. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65262. * @returns the current timestep in seconds
  65263. */
  65264. getTimeStep(): number;
  65265. /**
  65266. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65267. */
  65268. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65269. private _isImpostorInContact;
  65270. private _isImpostorPairInContact;
  65271. private _stepSimulation;
  65272. /**
  65273. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65274. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65275. * After the step the babylon meshes are set to the position of the physics imposters
  65276. * @param delta amount of time to step forward
  65277. * @param impostors array of imposters to update before/after the step
  65278. */
  65279. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65280. /**
  65281. * Update babylon mesh to match physics world object
  65282. * @param impostor imposter to match
  65283. */
  65284. private _afterSoftStep;
  65285. /**
  65286. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65287. * @param impostor imposter to match
  65288. */
  65289. private _ropeStep;
  65290. /**
  65291. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65292. * @param impostor imposter to match
  65293. */
  65294. private _softbodyOrClothStep;
  65295. private _tmpMatrix;
  65296. /**
  65297. * Applies an impulse on the imposter
  65298. * @param impostor imposter to apply impulse to
  65299. * @param force amount of force to be applied to the imposter
  65300. * @param contactPoint the location to apply the impulse on the imposter
  65301. */
  65302. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65303. /**
  65304. * Applies a force on the imposter
  65305. * @param impostor imposter to apply force
  65306. * @param force amount of force to be applied to the imposter
  65307. * @param contactPoint the location to apply the force on the imposter
  65308. */
  65309. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65310. /**
  65311. * Creates a physics body using the plugin
  65312. * @param impostor the imposter to create the physics body on
  65313. */
  65314. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65315. /**
  65316. * Removes the physics body from the imposter and disposes of the body's memory
  65317. * @param impostor imposter to remove the physics body from
  65318. */
  65319. removePhysicsBody(impostor: PhysicsImpostor): void;
  65320. /**
  65321. * Generates a joint
  65322. * @param impostorJoint the imposter joint to create the joint with
  65323. */
  65324. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65325. /**
  65326. * Removes a joint
  65327. * @param impostorJoint the imposter joint to remove the joint from
  65328. */
  65329. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65330. private _addMeshVerts;
  65331. /**
  65332. * Initialise the soft body vertices to match its object's (mesh) vertices
  65333. * Softbody vertices (nodes) are in world space and to match this
  65334. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65335. * @param impostor to create the softbody for
  65336. */
  65337. private _softVertexData;
  65338. /**
  65339. * Create an impostor's soft body
  65340. * @param impostor to create the softbody for
  65341. */
  65342. private _createSoftbody;
  65343. /**
  65344. * Create cloth for an impostor
  65345. * @param impostor to create the softbody for
  65346. */
  65347. private _createCloth;
  65348. /**
  65349. * Create rope for an impostor
  65350. * @param impostor to create the softbody for
  65351. */
  65352. private _createRope;
  65353. /**
  65354. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65355. * @param impostor to create the custom physics shape for
  65356. */
  65357. private _createCustom;
  65358. private _addHullVerts;
  65359. private _createShape;
  65360. /**
  65361. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65362. * @param impostor imposter containing the physics body and babylon object
  65363. */
  65364. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65365. /**
  65366. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65367. * @param impostor imposter containing the physics body and babylon object
  65368. * @param newPosition new position
  65369. * @param newRotation new rotation
  65370. */
  65371. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65372. /**
  65373. * If this plugin is supported
  65374. * @returns true if its supported
  65375. */
  65376. isSupported(): boolean;
  65377. /**
  65378. * Sets the linear velocity of the physics body
  65379. * @param impostor imposter to set the velocity on
  65380. * @param velocity velocity to set
  65381. */
  65382. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65383. /**
  65384. * Sets the angular velocity of the physics body
  65385. * @param impostor imposter to set the velocity on
  65386. * @param velocity velocity to set
  65387. */
  65388. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65389. /**
  65390. * gets the linear velocity
  65391. * @param impostor imposter to get linear velocity from
  65392. * @returns linear velocity
  65393. */
  65394. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65395. /**
  65396. * gets the angular velocity
  65397. * @param impostor imposter to get angular velocity from
  65398. * @returns angular velocity
  65399. */
  65400. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65401. /**
  65402. * Sets the mass of physics body
  65403. * @param impostor imposter to set the mass on
  65404. * @param mass mass to set
  65405. */
  65406. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65407. /**
  65408. * Gets the mass of the physics body
  65409. * @param impostor imposter to get the mass from
  65410. * @returns mass
  65411. */
  65412. getBodyMass(impostor: PhysicsImpostor): number;
  65413. /**
  65414. * Gets friction of the impostor
  65415. * @param impostor impostor to get friction from
  65416. * @returns friction value
  65417. */
  65418. getBodyFriction(impostor: PhysicsImpostor): number;
  65419. /**
  65420. * Sets friction of the impostor
  65421. * @param impostor impostor to set friction on
  65422. * @param friction friction value
  65423. */
  65424. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65425. /**
  65426. * Gets restitution of the impostor
  65427. * @param impostor impostor to get restitution from
  65428. * @returns restitution value
  65429. */
  65430. getBodyRestitution(impostor: PhysicsImpostor): number;
  65431. /**
  65432. * Sets resitution of the impostor
  65433. * @param impostor impostor to set resitution on
  65434. * @param restitution resitution value
  65435. */
  65436. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65437. /**
  65438. * Gets pressure inside the impostor
  65439. * @param impostor impostor to get pressure from
  65440. * @returns pressure value
  65441. */
  65442. getBodyPressure(impostor: PhysicsImpostor): number;
  65443. /**
  65444. * Sets pressure inside a soft body impostor
  65445. * Cloth and rope must remain 0 pressure
  65446. * @param impostor impostor to set pressure on
  65447. * @param pressure pressure value
  65448. */
  65449. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65450. /**
  65451. * Gets stiffness of the impostor
  65452. * @param impostor impostor to get stiffness from
  65453. * @returns pressure value
  65454. */
  65455. getBodyStiffness(impostor: PhysicsImpostor): number;
  65456. /**
  65457. * Sets stiffness of the impostor
  65458. * @param impostor impostor to set stiffness on
  65459. * @param stiffness stiffness value from 0 to 1
  65460. */
  65461. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65462. /**
  65463. * Gets velocityIterations of the impostor
  65464. * @param impostor impostor to get velocity iterations from
  65465. * @returns velocityIterations value
  65466. */
  65467. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65468. /**
  65469. * Sets velocityIterations of the impostor
  65470. * @param impostor impostor to set velocity iterations on
  65471. * @param velocityIterations velocityIterations value
  65472. */
  65473. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65474. /**
  65475. * Gets positionIterations of the impostor
  65476. * @param impostor impostor to get position iterations from
  65477. * @returns positionIterations value
  65478. */
  65479. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65480. /**
  65481. * Sets positionIterations of the impostor
  65482. * @param impostor impostor to set position on
  65483. * @param positionIterations positionIterations value
  65484. */
  65485. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65486. /**
  65487. * Append an anchor to a cloth object
  65488. * @param impostor is the cloth impostor to add anchor to
  65489. * @param otherImpostor is the rigid impostor to anchor to
  65490. * @param width ratio across width from 0 to 1
  65491. * @param height ratio up height from 0 to 1
  65492. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65493. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65494. */
  65495. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65496. /**
  65497. * Append an hook to a rope object
  65498. * @param impostor is the rope impostor to add hook to
  65499. * @param otherImpostor is the rigid impostor to hook to
  65500. * @param length ratio along the rope from 0 to 1
  65501. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65502. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65503. */
  65504. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65505. /**
  65506. * Sleeps the physics body and stops it from being active
  65507. * @param impostor impostor to sleep
  65508. */
  65509. sleepBody(impostor: PhysicsImpostor): void;
  65510. /**
  65511. * Activates the physics body
  65512. * @param impostor impostor to activate
  65513. */
  65514. wakeUpBody(impostor: PhysicsImpostor): void;
  65515. /**
  65516. * Updates the distance parameters of the joint
  65517. * @param joint joint to update
  65518. * @param maxDistance maximum distance of the joint
  65519. * @param minDistance minimum distance of the joint
  65520. */
  65521. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65522. /**
  65523. * Sets a motor on the joint
  65524. * @param joint joint to set motor on
  65525. * @param speed speed of the motor
  65526. * @param maxForce maximum force of the motor
  65527. * @param motorIndex index of the motor
  65528. */
  65529. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65530. /**
  65531. * Sets the motors limit
  65532. * @param joint joint to set limit on
  65533. * @param upperLimit upper limit
  65534. * @param lowerLimit lower limit
  65535. */
  65536. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65537. /**
  65538. * Syncs the position and rotation of a mesh with the impostor
  65539. * @param mesh mesh to sync
  65540. * @param impostor impostor to update the mesh with
  65541. */
  65542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65543. /**
  65544. * Gets the radius of the impostor
  65545. * @param impostor impostor to get radius from
  65546. * @returns the radius
  65547. */
  65548. getRadius(impostor: PhysicsImpostor): number;
  65549. /**
  65550. * Gets the box size of the impostor
  65551. * @param impostor impostor to get box size from
  65552. * @param result the resulting box size
  65553. */
  65554. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65555. /**
  65556. * Disposes of the impostor
  65557. */
  65558. dispose(): void;
  65559. /**
  65560. * Does a raycast in the physics world
  65561. * @param from when should the ray start?
  65562. * @param to when should the ray end?
  65563. * @returns PhysicsRaycastResult
  65564. */
  65565. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65566. }
  65567. }
  65568. declare module BABYLON {
  65569. interface AbstractScene {
  65570. /**
  65571. * The list of reflection probes added to the scene
  65572. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65573. */
  65574. reflectionProbes: Array<ReflectionProbe>;
  65575. /**
  65576. * Removes the given reflection probe from this scene.
  65577. * @param toRemove The reflection probe to remove
  65578. * @returns The index of the removed reflection probe
  65579. */
  65580. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65581. /**
  65582. * Adds the given reflection probe to this scene.
  65583. * @param newReflectionProbe The reflection probe to add
  65584. */
  65585. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65586. }
  65587. /**
  65588. * Class used to generate realtime reflection / refraction cube textures
  65589. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65590. */
  65591. export class ReflectionProbe {
  65592. /** defines the name of the probe */
  65593. name: string;
  65594. private _scene;
  65595. private _renderTargetTexture;
  65596. private _projectionMatrix;
  65597. private _viewMatrix;
  65598. private _target;
  65599. private _add;
  65600. private _attachedMesh;
  65601. private _invertYAxis;
  65602. /** Gets or sets probe position (center of the cube map) */
  65603. position: Vector3;
  65604. /**
  65605. * Creates a new reflection probe
  65606. * @param name defines the name of the probe
  65607. * @param size defines the texture resolution (for each face)
  65608. * @param scene defines the hosting scene
  65609. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65610. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65611. */
  65612. constructor(
  65613. /** defines the name of the probe */
  65614. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65615. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65616. get samples(): number;
  65617. set samples(value: number);
  65618. /** Gets or sets the refresh rate to use (on every frame by default) */
  65619. get refreshRate(): number;
  65620. set refreshRate(value: number);
  65621. /**
  65622. * Gets the hosting scene
  65623. * @returns a Scene
  65624. */
  65625. getScene(): Scene;
  65626. /** Gets the internal CubeTexture used to render to */
  65627. get cubeTexture(): RenderTargetTexture;
  65628. /** Gets the list of meshes to render */
  65629. get renderList(): Nullable<AbstractMesh[]>;
  65630. /**
  65631. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65632. * @param mesh defines the mesh to attach to
  65633. */
  65634. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65635. /**
  65636. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65637. * @param renderingGroupId The rendering group id corresponding to its index
  65638. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65639. */
  65640. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65641. /**
  65642. * Clean all associated resources
  65643. */
  65644. dispose(): void;
  65645. /**
  65646. * Converts the reflection probe information to a readable string for debug purpose.
  65647. * @param fullDetails Supports for multiple levels of logging within scene loading
  65648. * @returns the human readable reflection probe info
  65649. */
  65650. toString(fullDetails?: boolean): string;
  65651. /**
  65652. * Get the class name of the relfection probe.
  65653. * @returns "ReflectionProbe"
  65654. */
  65655. getClassName(): string;
  65656. /**
  65657. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65658. * @returns The JSON representation of the texture
  65659. */
  65660. serialize(): any;
  65661. /**
  65662. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65663. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65664. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65665. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65666. * @returns The parsed reflection probe if successful
  65667. */
  65668. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65669. }
  65670. }
  65671. declare module BABYLON {
  65672. /** @hidden */
  65673. export var _BabylonLoaderRegistered: boolean;
  65674. /**
  65675. * Helps setting up some configuration for the babylon file loader.
  65676. */
  65677. export class BabylonFileLoaderConfiguration {
  65678. /**
  65679. * The loader does not allow injecting custom physix engine into the plugins.
  65680. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65681. * So you could set this variable to your engine import to make it work.
  65682. */
  65683. static LoaderInjectedPhysicsEngine: any;
  65684. }
  65685. }
  65686. declare module BABYLON {
  65687. /**
  65688. * A material to use for fast depth-only rendering.
  65689. */
  65690. export class OcclusionMaterial extends ShaderMaterial {
  65691. constructor(name: string, scene: Scene);
  65692. }
  65693. }
  65694. declare module BABYLON {
  65695. /**
  65696. * The Physically based simple base material of BJS.
  65697. *
  65698. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65699. * It is used as the base class for both the specGloss and metalRough conventions.
  65700. */
  65701. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65702. /**
  65703. * Number of Simultaneous lights allowed on the material.
  65704. */
  65705. maxSimultaneousLights: number;
  65706. /**
  65707. * If sets to true, disables all the lights affecting the material.
  65708. */
  65709. disableLighting: boolean;
  65710. /**
  65711. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65712. */
  65713. environmentTexture: BaseTexture;
  65714. /**
  65715. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65716. */
  65717. invertNormalMapX: boolean;
  65718. /**
  65719. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65720. */
  65721. invertNormalMapY: boolean;
  65722. /**
  65723. * Normal map used in the model.
  65724. */
  65725. normalTexture: BaseTexture;
  65726. /**
  65727. * Emissivie color used to self-illuminate the model.
  65728. */
  65729. emissiveColor: Color3;
  65730. /**
  65731. * Emissivie texture used to self-illuminate the model.
  65732. */
  65733. emissiveTexture: BaseTexture;
  65734. /**
  65735. * Occlusion Channel Strenght.
  65736. */
  65737. occlusionStrength: number;
  65738. /**
  65739. * Occlusion Texture of the material (adding extra occlusion effects).
  65740. */
  65741. occlusionTexture: BaseTexture;
  65742. /**
  65743. * Defines the alpha limits in alpha test mode.
  65744. */
  65745. alphaCutOff: number;
  65746. /**
  65747. * Gets the current double sided mode.
  65748. */
  65749. get doubleSided(): boolean;
  65750. /**
  65751. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65752. */
  65753. set doubleSided(value: boolean);
  65754. /**
  65755. * Stores the pre-calculated light information of a mesh in a texture.
  65756. */
  65757. lightmapTexture: BaseTexture;
  65758. /**
  65759. * If true, the light map contains occlusion information instead of lighting info.
  65760. */
  65761. useLightmapAsShadowmap: boolean;
  65762. /**
  65763. * Instantiates a new PBRMaterial instance.
  65764. *
  65765. * @param name The material name
  65766. * @param scene The scene the material will be use in.
  65767. */
  65768. constructor(name: string, scene: Scene);
  65769. getClassName(): string;
  65770. }
  65771. }
  65772. declare module BABYLON {
  65773. /**
  65774. * The PBR material of BJS following the metal roughness convention.
  65775. *
  65776. * This fits to the PBR convention in the GLTF definition:
  65777. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65778. */
  65779. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65780. /**
  65781. * The base color has two different interpretations depending on the value of metalness.
  65782. * When the material is a metal, the base color is the specific measured reflectance value
  65783. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65784. * of the material.
  65785. */
  65786. baseColor: Color3;
  65787. /**
  65788. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65789. * well as opacity information in the alpha channel.
  65790. */
  65791. baseTexture: BaseTexture;
  65792. /**
  65793. * Specifies the metallic scalar value of the material.
  65794. * Can also be used to scale the metalness values of the metallic texture.
  65795. */
  65796. metallic: number;
  65797. /**
  65798. * Specifies the roughness scalar value of the material.
  65799. * Can also be used to scale the roughness values of the metallic texture.
  65800. */
  65801. roughness: number;
  65802. /**
  65803. * Texture containing both the metallic value in the B channel and the
  65804. * roughness value in the G channel to keep better precision.
  65805. */
  65806. metallicRoughnessTexture: BaseTexture;
  65807. /**
  65808. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65809. *
  65810. * @param name The material name
  65811. * @param scene The scene the material will be use in.
  65812. */
  65813. constructor(name: string, scene: Scene);
  65814. /**
  65815. * Return the currrent class name of the material.
  65816. */
  65817. getClassName(): string;
  65818. /**
  65819. * Makes a duplicate of the current material.
  65820. * @param name - name to use for the new material.
  65821. */
  65822. clone(name: string): PBRMetallicRoughnessMaterial;
  65823. /**
  65824. * Serialize the material to a parsable JSON object.
  65825. */
  65826. serialize(): any;
  65827. /**
  65828. * Parses a JSON object correponding to the serialize function.
  65829. */
  65830. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65831. }
  65832. }
  65833. declare module BABYLON {
  65834. /**
  65835. * The PBR material of BJS following the specular glossiness convention.
  65836. *
  65837. * This fits to the PBR convention in the GLTF definition:
  65838. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65839. */
  65840. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65841. /**
  65842. * Specifies the diffuse color of the material.
  65843. */
  65844. diffuseColor: Color3;
  65845. /**
  65846. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65847. * channel.
  65848. */
  65849. diffuseTexture: BaseTexture;
  65850. /**
  65851. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65852. */
  65853. specularColor: Color3;
  65854. /**
  65855. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65856. */
  65857. glossiness: number;
  65858. /**
  65859. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65860. */
  65861. specularGlossinessTexture: BaseTexture;
  65862. /**
  65863. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65864. */
  65865. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65866. /**
  65867. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65868. *
  65869. * @param name The material name
  65870. * @param scene The scene the material will be use in.
  65871. */
  65872. constructor(name: string, scene: Scene);
  65873. /**
  65874. * Return the currrent class name of the material.
  65875. */
  65876. getClassName(): string;
  65877. /**
  65878. * Makes a duplicate of the current material.
  65879. * @param name - name to use for the new material.
  65880. */
  65881. clone(name: string): PBRSpecularGlossinessMaterial;
  65882. /**
  65883. * Serialize the material to a parsable JSON object.
  65884. */
  65885. serialize(): any;
  65886. /**
  65887. * Parses a JSON object correponding to the serialize function.
  65888. */
  65889. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65890. }
  65891. }
  65892. declare module BABYLON {
  65893. /**
  65894. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65895. * It can help converting any input color in a desired output one. This can then be used to create effects
  65896. * from sepia, black and white to sixties or futuristic rendering...
  65897. *
  65898. * The only supported format is currently 3dl.
  65899. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65900. */
  65901. export class ColorGradingTexture extends BaseTexture {
  65902. /**
  65903. * The texture URL.
  65904. */
  65905. url: string;
  65906. /**
  65907. * Empty line regex stored for GC.
  65908. */
  65909. private static _noneEmptyLineRegex;
  65910. private _textureMatrix;
  65911. private _onLoad;
  65912. /**
  65913. * Instantiates a ColorGradingTexture from the following parameters.
  65914. *
  65915. * @param url The location of the color gradind data (currently only supporting 3dl)
  65916. * @param sceneOrEngine The scene or engine the texture will be used in
  65917. * @param onLoad defines a callback triggered when the texture has been loaded
  65918. */
  65919. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65920. /**
  65921. * Fires the onload event from the constructor if requested.
  65922. */
  65923. private _triggerOnLoad;
  65924. /**
  65925. * Returns the texture matrix used in most of the material.
  65926. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65927. */
  65928. getTextureMatrix(): Matrix;
  65929. /**
  65930. * Occurs when the file being loaded is a .3dl LUT file.
  65931. */
  65932. private load3dlTexture;
  65933. /**
  65934. * Starts the loading process of the texture.
  65935. */
  65936. private loadTexture;
  65937. /**
  65938. * Clones the color gradind texture.
  65939. */
  65940. clone(): ColorGradingTexture;
  65941. /**
  65942. * Called during delayed load for textures.
  65943. */
  65944. delayLoad(): void;
  65945. /**
  65946. * Parses a color grading texture serialized by Babylon.
  65947. * @param parsedTexture The texture information being parsedTexture
  65948. * @param scene The scene to load the texture in
  65949. * @param rootUrl The root url of the data assets to load
  65950. * @return A color gradind texture
  65951. */
  65952. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65953. /**
  65954. * Serializes the LUT texture to json format.
  65955. */
  65956. serialize(): any;
  65957. }
  65958. }
  65959. declare module BABYLON {
  65960. /**
  65961. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65962. */
  65963. export class EquiRectangularCubeTexture extends BaseTexture {
  65964. /** The six faces of the cube. */
  65965. private static _FacesMapping;
  65966. private _noMipmap;
  65967. private _onLoad;
  65968. private _onError;
  65969. /** The size of the cubemap. */
  65970. private _size;
  65971. /** The buffer of the image. */
  65972. private _buffer;
  65973. /** The width of the input image. */
  65974. private _width;
  65975. /** The height of the input image. */
  65976. private _height;
  65977. /** The URL to the image. */
  65978. url: string;
  65979. /**
  65980. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65981. * @param url The location of the image
  65982. * @param scene The scene the texture will be used in
  65983. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65984. * @param noMipmap Forces to not generate the mipmap if true
  65985. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65986. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65987. * @param onLoad — defines a callback called when texture is loaded
  65988. * @param onError — defines a callback called if there is an error
  65989. */
  65990. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65991. /**
  65992. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65993. */
  65994. private loadImage;
  65995. /**
  65996. * Convert the image buffer into a cubemap and create a CubeTexture.
  65997. */
  65998. private loadTexture;
  65999. /**
  66000. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66001. * @param buffer The ArrayBuffer that should be converted.
  66002. * @returns The buffer as Float32Array.
  66003. */
  66004. private getFloat32ArrayFromArrayBuffer;
  66005. /**
  66006. * Get the current class name of the texture useful for serialization or dynamic coding.
  66007. * @returns "EquiRectangularCubeTexture"
  66008. */
  66009. getClassName(): string;
  66010. /**
  66011. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66012. * @returns A clone of the current EquiRectangularCubeTexture.
  66013. */
  66014. clone(): EquiRectangularCubeTexture;
  66015. }
  66016. }
  66017. declare module BABYLON {
  66018. /**
  66019. * Defines the options related to the creation of an HtmlElementTexture
  66020. */
  66021. export interface IHtmlElementTextureOptions {
  66022. /**
  66023. * Defines wether mip maps should be created or not.
  66024. */
  66025. generateMipMaps?: boolean;
  66026. /**
  66027. * Defines the sampling mode of the texture.
  66028. */
  66029. samplingMode?: number;
  66030. /**
  66031. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66032. */
  66033. engine: Nullable<ThinEngine>;
  66034. /**
  66035. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66036. */
  66037. scene: Nullable<Scene>;
  66038. }
  66039. /**
  66040. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66041. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66042. * is automatically managed.
  66043. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66044. * in your application.
  66045. *
  66046. * As the update is not automatic, you need to call them manually.
  66047. */
  66048. export class HtmlElementTexture extends BaseTexture {
  66049. /**
  66050. * The texture URL.
  66051. */
  66052. element: HTMLVideoElement | HTMLCanvasElement;
  66053. private static readonly DefaultOptions;
  66054. private _textureMatrix;
  66055. private _isVideo;
  66056. private _generateMipMaps;
  66057. private _samplingMode;
  66058. /**
  66059. * Instantiates a HtmlElementTexture from the following parameters.
  66060. *
  66061. * @param name Defines the name of the texture
  66062. * @param element Defines the video or canvas the texture is filled with
  66063. * @param options Defines the other none mandatory texture creation options
  66064. */
  66065. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66066. private _createInternalTexture;
  66067. /**
  66068. * Returns the texture matrix used in most of the material.
  66069. */
  66070. getTextureMatrix(): Matrix;
  66071. /**
  66072. * Updates the content of the texture.
  66073. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66074. */
  66075. update(invertY?: Nullable<boolean>): void;
  66076. }
  66077. }
  66078. declare module BABYLON {
  66079. /**
  66080. * Based on jsTGALoader - Javascript loader for TGA file
  66081. * By Vincent Thibault
  66082. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66083. */
  66084. export class TGATools {
  66085. private static _TYPE_INDEXED;
  66086. private static _TYPE_RGB;
  66087. private static _TYPE_GREY;
  66088. private static _TYPE_RLE_INDEXED;
  66089. private static _TYPE_RLE_RGB;
  66090. private static _TYPE_RLE_GREY;
  66091. private static _ORIGIN_MASK;
  66092. private static _ORIGIN_SHIFT;
  66093. private static _ORIGIN_BL;
  66094. private static _ORIGIN_BR;
  66095. private static _ORIGIN_UL;
  66096. private static _ORIGIN_UR;
  66097. /**
  66098. * Gets the header of a TGA file
  66099. * @param data defines the TGA data
  66100. * @returns the header
  66101. */
  66102. static GetTGAHeader(data: Uint8Array): any;
  66103. /**
  66104. * Uploads TGA content to a Babylon Texture
  66105. * @hidden
  66106. */
  66107. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66108. /** @hidden */
  66109. 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;
  66110. /** @hidden */
  66111. 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;
  66112. /** @hidden */
  66113. 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;
  66114. /** @hidden */
  66115. 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;
  66116. /** @hidden */
  66117. 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;
  66118. /** @hidden */
  66119. 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;
  66120. }
  66121. }
  66122. declare module BABYLON {
  66123. /**
  66124. * Implementation of the TGA Texture Loader.
  66125. * @hidden
  66126. */
  66127. export class _TGATextureLoader implements IInternalTextureLoader {
  66128. /**
  66129. * Defines wether the loader supports cascade loading the different faces.
  66130. */
  66131. readonly supportCascades: boolean;
  66132. /**
  66133. * This returns if the loader support the current file information.
  66134. * @param extension defines the file extension of the file being loaded
  66135. * @returns true if the loader can load the specified file
  66136. */
  66137. canLoad(extension: string): boolean;
  66138. /**
  66139. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66140. * @param data contains the texture data
  66141. * @param texture defines the BabylonJS internal texture
  66142. * @param createPolynomials will be true if polynomials have been requested
  66143. * @param onLoad defines the callback to trigger once the texture is ready
  66144. * @param onError defines the callback to trigger in case of error
  66145. */
  66146. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66147. /**
  66148. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66149. * @param data contains the texture data
  66150. * @param texture defines the BabylonJS internal texture
  66151. * @param callback defines the method to call once ready to upload
  66152. */
  66153. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66154. }
  66155. }
  66156. declare module BABYLON {
  66157. /**
  66158. * Info about the .basis files
  66159. */
  66160. class BasisFileInfo {
  66161. /**
  66162. * If the file has alpha
  66163. */
  66164. hasAlpha: boolean;
  66165. /**
  66166. * Info about each image of the basis file
  66167. */
  66168. images: Array<{
  66169. levels: Array<{
  66170. width: number;
  66171. height: number;
  66172. transcodedPixels: ArrayBufferView;
  66173. }>;
  66174. }>;
  66175. }
  66176. /**
  66177. * Result of transcoding a basis file
  66178. */
  66179. class TranscodeResult {
  66180. /**
  66181. * Info about the .basis file
  66182. */
  66183. fileInfo: BasisFileInfo;
  66184. /**
  66185. * Format to use when loading the file
  66186. */
  66187. format: number;
  66188. }
  66189. /**
  66190. * Configuration options for the Basis transcoder
  66191. */
  66192. export class BasisTranscodeConfiguration {
  66193. /**
  66194. * Supported compression formats used to determine the supported output format of the transcoder
  66195. */
  66196. supportedCompressionFormats?: {
  66197. /**
  66198. * etc1 compression format
  66199. */
  66200. etc1?: boolean;
  66201. /**
  66202. * s3tc compression format
  66203. */
  66204. s3tc?: boolean;
  66205. /**
  66206. * pvrtc compression format
  66207. */
  66208. pvrtc?: boolean;
  66209. /**
  66210. * etc2 compression format
  66211. */
  66212. etc2?: boolean;
  66213. };
  66214. /**
  66215. * If mipmap levels should be loaded for transcoded images (Default: true)
  66216. */
  66217. loadMipmapLevels?: boolean;
  66218. /**
  66219. * Index of a single image to load (Default: all images)
  66220. */
  66221. loadSingleImage?: number;
  66222. }
  66223. /**
  66224. * Used to load .Basis files
  66225. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66226. */
  66227. export class BasisTools {
  66228. private static _IgnoreSupportedFormats;
  66229. /**
  66230. * URL to use when loading the basis transcoder
  66231. */
  66232. static JSModuleURL: string;
  66233. /**
  66234. * URL to use when loading the wasm module for the transcoder
  66235. */
  66236. static WasmModuleURL: string;
  66237. /**
  66238. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66239. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66240. * @returns internal format corresponding to the Basis format
  66241. */
  66242. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66243. private static _WorkerPromise;
  66244. private static _Worker;
  66245. private static _actionId;
  66246. private static _CreateWorkerAsync;
  66247. /**
  66248. * Transcodes a loaded image file to compressed pixel data
  66249. * @param data image data to transcode
  66250. * @param config configuration options for the transcoding
  66251. * @returns a promise resulting in the transcoded image
  66252. */
  66253. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66254. /**
  66255. * Loads a texture from the transcode result
  66256. * @param texture texture load to
  66257. * @param transcodeResult the result of transcoding the basis file to load from
  66258. */
  66259. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66260. }
  66261. }
  66262. declare module BABYLON {
  66263. /**
  66264. * Loader for .basis file format
  66265. */
  66266. export class _BasisTextureLoader implements IInternalTextureLoader {
  66267. /**
  66268. * Defines whether the loader supports cascade loading the different faces.
  66269. */
  66270. readonly supportCascades: boolean;
  66271. /**
  66272. * This returns if the loader support the current file information.
  66273. * @param extension defines the file extension of the file being loaded
  66274. * @returns true if the loader can load the specified file
  66275. */
  66276. canLoad(extension: string): boolean;
  66277. /**
  66278. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66279. * @param data contains the texture data
  66280. * @param texture defines the BabylonJS internal texture
  66281. * @param createPolynomials will be true if polynomials have been requested
  66282. * @param onLoad defines the callback to trigger once the texture is ready
  66283. * @param onError defines the callback to trigger in case of error
  66284. */
  66285. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66286. /**
  66287. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66288. * @param data contains the texture data
  66289. * @param texture defines the BabylonJS internal texture
  66290. * @param callback defines the method to call once ready to upload
  66291. */
  66292. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66293. }
  66294. }
  66295. declare module BABYLON {
  66296. /**
  66297. * Defines the basic options interface of a TexturePacker Frame
  66298. */
  66299. export interface ITexturePackerFrame {
  66300. /**
  66301. * The frame ID
  66302. */
  66303. id: number;
  66304. /**
  66305. * The frames Scale
  66306. */
  66307. scale: Vector2;
  66308. /**
  66309. * The Frames offset
  66310. */
  66311. offset: Vector2;
  66312. }
  66313. /**
  66314. * This is a support class for frame Data on texture packer sets.
  66315. */
  66316. export class TexturePackerFrame implements ITexturePackerFrame {
  66317. /**
  66318. * The frame ID
  66319. */
  66320. id: number;
  66321. /**
  66322. * The frames Scale
  66323. */
  66324. scale: Vector2;
  66325. /**
  66326. * The Frames offset
  66327. */
  66328. offset: Vector2;
  66329. /**
  66330. * Initializes a texture package frame.
  66331. * @param id The numerical frame identifier
  66332. * @param scale Scalar Vector2 for UV frame
  66333. * @param offset Vector2 for the frame position in UV units.
  66334. * @returns TexturePackerFrame
  66335. */
  66336. constructor(id: number, scale: Vector2, offset: Vector2);
  66337. }
  66338. }
  66339. declare module BABYLON {
  66340. /**
  66341. * Defines the basic options interface of a TexturePacker
  66342. */
  66343. export interface ITexturePackerOptions {
  66344. /**
  66345. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66346. */
  66347. map?: string[];
  66348. /**
  66349. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66350. */
  66351. uvsIn?: string;
  66352. /**
  66353. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66354. */
  66355. uvsOut?: string;
  66356. /**
  66357. * number representing the layout style. Defaults to LAYOUT_STRIP
  66358. */
  66359. layout?: number;
  66360. /**
  66361. * number of columns if using custom column count layout(2). This defaults to 4.
  66362. */
  66363. colnum?: number;
  66364. /**
  66365. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66366. */
  66367. updateInputMeshes?: boolean;
  66368. /**
  66369. * boolean flag to dispose all the source textures. Defaults to true.
  66370. */
  66371. disposeSources?: boolean;
  66372. /**
  66373. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66374. */
  66375. fillBlanks?: boolean;
  66376. /**
  66377. * string value representing the context fill style color. Defaults to 'black'.
  66378. */
  66379. customFillColor?: string;
  66380. /**
  66381. * Width and Height Value of each Frame in the TexturePacker Sets
  66382. */
  66383. frameSize?: number;
  66384. /**
  66385. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66386. */
  66387. paddingRatio?: number;
  66388. /**
  66389. * Number that declares the fill method for the padding gutter.
  66390. */
  66391. paddingMode?: number;
  66392. /**
  66393. * If in SUBUV_COLOR padding mode what color to use.
  66394. */
  66395. paddingColor?: Color3 | Color4;
  66396. }
  66397. /**
  66398. * Defines the basic interface of a TexturePacker JSON File
  66399. */
  66400. export interface ITexturePackerJSON {
  66401. /**
  66402. * The frame ID
  66403. */
  66404. name: string;
  66405. /**
  66406. * The base64 channel data
  66407. */
  66408. sets: any;
  66409. /**
  66410. * The options of the Packer
  66411. */
  66412. options: ITexturePackerOptions;
  66413. /**
  66414. * The frame data of the Packer
  66415. */
  66416. frames: Array<number>;
  66417. }
  66418. /**
  66419. * This is a support class that generates a series of packed texture sets.
  66420. * @see https://doc.babylonjs.com/babylon101/materials
  66421. */
  66422. export class TexturePacker {
  66423. /** Packer Layout Constant 0 */
  66424. static readonly LAYOUT_STRIP: number;
  66425. /** Packer Layout Constant 1 */
  66426. static readonly LAYOUT_POWER2: number;
  66427. /** Packer Layout Constant 2 */
  66428. static readonly LAYOUT_COLNUM: number;
  66429. /** Packer Layout Constant 0 */
  66430. static readonly SUBUV_WRAP: number;
  66431. /** Packer Layout Constant 1 */
  66432. static readonly SUBUV_EXTEND: number;
  66433. /** Packer Layout Constant 2 */
  66434. static readonly SUBUV_COLOR: number;
  66435. /** The Name of the Texture Package */
  66436. name: string;
  66437. /** The scene scope of the TexturePacker */
  66438. scene: Scene;
  66439. /** The Meshes to target */
  66440. meshes: AbstractMesh[];
  66441. /** Arguments passed with the Constructor */
  66442. options: ITexturePackerOptions;
  66443. /** The promise that is started upon initialization */
  66444. promise: Nullable<Promise<TexturePacker | string>>;
  66445. /** The Container object for the channel sets that are generated */
  66446. sets: object;
  66447. /** The Container array for the frames that are generated */
  66448. frames: TexturePackerFrame[];
  66449. /** The expected number of textures the system is parsing. */
  66450. private _expecting;
  66451. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66452. private _paddingValue;
  66453. /**
  66454. * Initializes a texture package series from an array of meshes or a single mesh.
  66455. * @param name The name of the package
  66456. * @param meshes The target meshes to compose the package from
  66457. * @param options The arguments that texture packer should follow while building.
  66458. * @param scene The scene which the textures are scoped to.
  66459. * @returns TexturePacker
  66460. */
  66461. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66462. /**
  66463. * Starts the package process
  66464. * @param resolve The promises resolution function
  66465. * @returns TexturePacker
  66466. */
  66467. private _createFrames;
  66468. /**
  66469. * Calculates the Size of the Channel Sets
  66470. * @returns Vector2
  66471. */
  66472. private _calculateSize;
  66473. /**
  66474. * Calculates the UV data for the frames.
  66475. * @param baseSize the base frameSize
  66476. * @param padding the base frame padding
  66477. * @param dtSize size of the Dynamic Texture for that channel
  66478. * @param dtUnits is 1/dtSize
  66479. * @param update flag to update the input meshes
  66480. */
  66481. private _calculateMeshUVFrames;
  66482. /**
  66483. * Calculates the frames Offset.
  66484. * @param index of the frame
  66485. * @returns Vector2
  66486. */
  66487. private _getFrameOffset;
  66488. /**
  66489. * Updates a Mesh to the frame data
  66490. * @param mesh that is the target
  66491. * @param frameID or the frame index
  66492. */
  66493. private _updateMeshUV;
  66494. /**
  66495. * Updates a Meshes materials to use the texture packer channels
  66496. * @param m is the mesh to target
  66497. * @param force all channels on the packer to be set.
  66498. */
  66499. private _updateTextureReferences;
  66500. /**
  66501. * Public method to set a Mesh to a frame
  66502. * @param m that is the target
  66503. * @param frameID or the frame index
  66504. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66505. */
  66506. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66507. /**
  66508. * Starts the async promise to compile the texture packer.
  66509. * @returns Promise<void>
  66510. */
  66511. processAsync(): Promise<void>;
  66512. /**
  66513. * Disposes all textures associated with this packer
  66514. */
  66515. dispose(): void;
  66516. /**
  66517. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66518. * @param imageType is the image type to use.
  66519. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66520. */
  66521. download(imageType?: string, quality?: number): void;
  66522. /**
  66523. * Public method to load a texturePacker JSON file.
  66524. * @param data of the JSON file in string format.
  66525. */
  66526. updateFromJSON(data: string): void;
  66527. }
  66528. }
  66529. declare module BABYLON {
  66530. /**
  66531. * 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.
  66532. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66533. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66534. */
  66535. export class CustomProceduralTexture extends ProceduralTexture {
  66536. private _animate;
  66537. private _time;
  66538. private _config;
  66539. private _texturePath;
  66540. /**
  66541. * Instantiates a new Custom Procedural Texture.
  66542. * 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.
  66543. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66544. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66545. * @param name Define the name of the texture
  66546. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66547. * @param size Define the size of the texture to create
  66548. * @param scene Define the scene the texture belongs to
  66549. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66550. * @param generateMipMaps Define if the texture should creates mip maps or not
  66551. */
  66552. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66553. private _loadJson;
  66554. /**
  66555. * Is the texture ready to be used ? (rendered at least once)
  66556. * @returns true if ready, otherwise, false.
  66557. */
  66558. isReady(): boolean;
  66559. /**
  66560. * Render the texture to its associated render target.
  66561. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66562. */
  66563. render(useCameraPostProcess?: boolean): void;
  66564. /**
  66565. * Update the list of dependant textures samplers in the shader.
  66566. */
  66567. updateTextures(): void;
  66568. /**
  66569. * Update the uniform values of the procedural texture in the shader.
  66570. */
  66571. updateShaderUniforms(): void;
  66572. /**
  66573. * Define if the texture animates or not.
  66574. */
  66575. get animate(): boolean;
  66576. set animate(value: boolean);
  66577. }
  66578. }
  66579. declare module BABYLON {
  66580. /** @hidden */
  66581. export var noisePixelShader: {
  66582. name: string;
  66583. shader: string;
  66584. };
  66585. }
  66586. declare module BABYLON {
  66587. /**
  66588. * Class used to generate noise procedural textures
  66589. */
  66590. export class NoiseProceduralTexture extends ProceduralTexture {
  66591. /** Gets or sets the start time (default is 0) */
  66592. time: number;
  66593. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66594. brightness: number;
  66595. /** Defines the number of octaves to process */
  66596. octaves: number;
  66597. /** Defines the level of persistence (0.8 by default) */
  66598. persistence: number;
  66599. /** Gets or sets animation speed factor (default is 1) */
  66600. animationSpeedFactor: number;
  66601. /**
  66602. * Creates a new NoiseProceduralTexture
  66603. * @param name defines the name fo the texture
  66604. * @param size defines the size of the texture (default is 256)
  66605. * @param scene defines the hosting scene
  66606. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66607. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66608. */
  66609. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66610. private _updateShaderUniforms;
  66611. protected _getDefines(): string;
  66612. /** Generate the current state of the procedural texture */
  66613. render(useCameraPostProcess?: boolean): void;
  66614. /**
  66615. * Serializes this noise procedural texture
  66616. * @returns a serialized noise procedural texture object
  66617. */
  66618. serialize(): any;
  66619. /**
  66620. * Clone the texture.
  66621. * @returns the cloned texture
  66622. */
  66623. clone(): NoiseProceduralTexture;
  66624. /**
  66625. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66626. * @param parsedTexture defines parsed texture data
  66627. * @param scene defines the current scene
  66628. * @param rootUrl defines the root URL containing noise procedural texture information
  66629. * @returns a parsed NoiseProceduralTexture
  66630. */
  66631. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66632. }
  66633. }
  66634. declare module BABYLON {
  66635. /**
  66636. * Raw cube texture where the raw buffers are passed in
  66637. */
  66638. export class RawCubeTexture extends CubeTexture {
  66639. /**
  66640. * Creates a cube texture where the raw buffers are passed in.
  66641. * @param scene defines the scene the texture is attached to
  66642. * @param data defines the array of data to use to create each face
  66643. * @param size defines the size of the textures
  66644. * @param format defines the format of the data
  66645. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66646. * @param generateMipMaps defines if the engine should generate the mip levels
  66647. * @param invertY defines if data must be stored with Y axis inverted
  66648. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66649. * @param compression defines the compression used (null by default)
  66650. */
  66651. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66652. /**
  66653. * Updates the raw cube texture.
  66654. * @param data defines the data to store
  66655. * @param format defines the data format
  66656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66657. * @param invertY defines if data must be stored with Y axis inverted
  66658. * @param compression defines the compression used (null by default)
  66659. * @param level defines which level of the texture to update
  66660. */
  66661. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66662. /**
  66663. * Updates a raw cube texture with RGBD encoded data.
  66664. * @param data defines the array of data [mipmap][face] to use to create each face
  66665. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66666. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66667. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66668. * @returns a promsie that resolves when the operation is complete
  66669. */
  66670. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66671. /**
  66672. * Clones the raw cube texture.
  66673. * @return a new cube texture
  66674. */
  66675. clone(): CubeTexture;
  66676. /** @hidden */
  66677. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66678. }
  66679. }
  66680. declare module BABYLON {
  66681. /**
  66682. * Class used to store 2D array textures containing user data
  66683. */
  66684. export class RawTexture2DArray extends Texture {
  66685. /** Gets or sets the texture format to use */
  66686. format: number;
  66687. /**
  66688. * Create a new RawTexture2DArray
  66689. * @param data defines the data of the texture
  66690. * @param width defines the width of the texture
  66691. * @param height defines the height of the texture
  66692. * @param depth defines the number of layers of the texture
  66693. * @param format defines the texture format to use
  66694. * @param scene defines the hosting scene
  66695. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66696. * @param invertY defines if texture must be stored with Y axis inverted
  66697. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66698. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66699. */
  66700. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66701. /** Gets or sets the texture format to use */
  66702. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66703. /**
  66704. * Update the texture with new data
  66705. * @param data defines the data to store in the texture
  66706. */
  66707. update(data: ArrayBufferView): void;
  66708. }
  66709. }
  66710. declare module BABYLON {
  66711. /**
  66712. * Class used to store 3D textures containing user data
  66713. */
  66714. export class RawTexture3D extends Texture {
  66715. /** Gets or sets the texture format to use */
  66716. format: number;
  66717. /**
  66718. * Create a new RawTexture3D
  66719. * @param data defines the data of the texture
  66720. * @param width defines the width of the texture
  66721. * @param height defines the height of the texture
  66722. * @param depth defines the depth of the texture
  66723. * @param format defines the texture format to use
  66724. * @param scene defines the hosting scene
  66725. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66726. * @param invertY defines if texture must be stored with Y axis inverted
  66727. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66729. */
  66730. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66731. /** Gets or sets the texture format to use */
  66732. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66733. /**
  66734. * Update the texture with new data
  66735. * @param data defines the data to store in the texture
  66736. */
  66737. update(data: ArrayBufferView): void;
  66738. }
  66739. }
  66740. declare module BABYLON {
  66741. /**
  66742. * Creates a refraction texture used by refraction channel of the standard material.
  66743. * It is like a mirror but to see through a material.
  66744. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66745. */
  66746. export class RefractionTexture extends RenderTargetTexture {
  66747. /**
  66748. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66749. * 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.
  66750. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66751. */
  66752. refractionPlane: Plane;
  66753. /**
  66754. * Define how deep under the surface we should see.
  66755. */
  66756. depth: number;
  66757. /**
  66758. * Creates a refraction texture used by refraction channel of the standard material.
  66759. * It is like a mirror but to see through a material.
  66760. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66761. * @param name Define the texture name
  66762. * @param size Define the size of the underlying texture
  66763. * @param scene Define the scene the refraction belongs to
  66764. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66765. */
  66766. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66767. /**
  66768. * Clone the refraction texture.
  66769. * @returns the cloned texture
  66770. */
  66771. clone(): RefractionTexture;
  66772. /**
  66773. * Serialize the texture to a JSON representation you could use in Parse later on
  66774. * @returns the serialized JSON representation
  66775. */
  66776. serialize(): any;
  66777. }
  66778. }
  66779. declare module BABYLON {
  66780. /**
  66781. * Block used to add support for vertex skinning (bones)
  66782. */
  66783. export class BonesBlock extends NodeMaterialBlock {
  66784. /**
  66785. * Creates a new BonesBlock
  66786. * @param name defines the block name
  66787. */
  66788. constructor(name: string);
  66789. /**
  66790. * Initialize the block and prepare the context for build
  66791. * @param state defines the state that will be used for the build
  66792. */
  66793. initialize(state: NodeMaterialBuildState): void;
  66794. /**
  66795. * Gets the current class name
  66796. * @returns the class name
  66797. */
  66798. getClassName(): string;
  66799. /**
  66800. * Gets the matrix indices input component
  66801. */
  66802. get matricesIndices(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the matrix weights input component
  66805. */
  66806. get matricesWeights(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the extra matrix indices input component
  66809. */
  66810. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66811. /**
  66812. * Gets the extra matrix weights input component
  66813. */
  66814. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66815. /**
  66816. * Gets the world input component
  66817. */
  66818. get world(): NodeMaterialConnectionPoint;
  66819. /**
  66820. * Gets the output component
  66821. */
  66822. get output(): NodeMaterialConnectionPoint;
  66823. autoConfigure(material: NodeMaterial): void;
  66824. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66827. protected _buildBlock(state: NodeMaterialBuildState): this;
  66828. }
  66829. }
  66830. declare module BABYLON {
  66831. /**
  66832. * Block used to add support for instances
  66833. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66834. */
  66835. export class InstancesBlock extends NodeMaterialBlock {
  66836. /**
  66837. * Creates a new InstancesBlock
  66838. * @param name defines the block name
  66839. */
  66840. constructor(name: string);
  66841. /**
  66842. * Gets the current class name
  66843. * @returns the class name
  66844. */
  66845. getClassName(): string;
  66846. /**
  66847. * Gets the first world row input component
  66848. */
  66849. get world0(): NodeMaterialConnectionPoint;
  66850. /**
  66851. * Gets the second world row input component
  66852. */
  66853. get world1(): NodeMaterialConnectionPoint;
  66854. /**
  66855. * Gets the third world row input component
  66856. */
  66857. get world2(): NodeMaterialConnectionPoint;
  66858. /**
  66859. * Gets the forth world row input component
  66860. */
  66861. get world3(): NodeMaterialConnectionPoint;
  66862. /**
  66863. * Gets the world input component
  66864. */
  66865. get world(): NodeMaterialConnectionPoint;
  66866. /**
  66867. * Gets the output component
  66868. */
  66869. get output(): NodeMaterialConnectionPoint;
  66870. /**
  66871. * Gets the isntanceID component
  66872. */
  66873. get instanceID(): NodeMaterialConnectionPoint;
  66874. autoConfigure(material: NodeMaterial): void;
  66875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66876. protected _buildBlock(state: NodeMaterialBuildState): this;
  66877. }
  66878. }
  66879. declare module BABYLON {
  66880. /**
  66881. * Block used to add morph targets support to vertex shader
  66882. */
  66883. export class MorphTargetsBlock extends NodeMaterialBlock {
  66884. private _repeatableContentAnchor;
  66885. /**
  66886. * Create a new MorphTargetsBlock
  66887. * @param name defines the block name
  66888. */
  66889. constructor(name: string);
  66890. /**
  66891. * Gets the current class name
  66892. * @returns the class name
  66893. */
  66894. getClassName(): string;
  66895. /**
  66896. * Gets the position input component
  66897. */
  66898. get position(): NodeMaterialConnectionPoint;
  66899. /**
  66900. * Gets the normal input component
  66901. */
  66902. get normal(): NodeMaterialConnectionPoint;
  66903. /**
  66904. * Gets the tangent input component
  66905. */
  66906. get tangent(): NodeMaterialConnectionPoint;
  66907. /**
  66908. * Gets the tangent input component
  66909. */
  66910. get uv(): NodeMaterialConnectionPoint;
  66911. /**
  66912. * Gets the position output component
  66913. */
  66914. get positionOutput(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the normal output component
  66917. */
  66918. get normalOutput(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the tangent output component
  66921. */
  66922. get tangentOutput(): NodeMaterialConnectionPoint;
  66923. /**
  66924. * Gets the tangent output component
  66925. */
  66926. get uvOutput(): NodeMaterialConnectionPoint;
  66927. initialize(state: NodeMaterialBuildState): void;
  66928. autoConfigure(material: NodeMaterial): void;
  66929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66931. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66932. protected _buildBlock(state: NodeMaterialBuildState): this;
  66933. }
  66934. }
  66935. declare module BABYLON {
  66936. /**
  66937. * Block used to get data information from a light
  66938. */
  66939. export class LightInformationBlock extends NodeMaterialBlock {
  66940. private _lightDataUniformName;
  66941. private _lightColorUniformName;
  66942. private _lightTypeDefineName;
  66943. /**
  66944. * Gets or sets the light associated with this block
  66945. */
  66946. light: Nullable<Light>;
  66947. /**
  66948. * Creates a new LightInformationBlock
  66949. * @param name defines the block name
  66950. */
  66951. constructor(name: string);
  66952. /**
  66953. * Gets the current class name
  66954. * @returns the class name
  66955. */
  66956. getClassName(): string;
  66957. /**
  66958. * Gets the world position input component
  66959. */
  66960. get worldPosition(): NodeMaterialConnectionPoint;
  66961. /**
  66962. * Gets the direction output component
  66963. */
  66964. get direction(): NodeMaterialConnectionPoint;
  66965. /**
  66966. * Gets the direction output component
  66967. */
  66968. get color(): NodeMaterialConnectionPoint;
  66969. /**
  66970. * Gets the direction output component
  66971. */
  66972. get intensity(): NodeMaterialConnectionPoint;
  66973. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66975. protected _buildBlock(state: NodeMaterialBuildState): this;
  66976. serialize(): any;
  66977. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66978. }
  66979. }
  66980. declare module BABYLON {
  66981. /**
  66982. * Block used to add image processing support to fragment shader
  66983. */
  66984. export class ImageProcessingBlock extends NodeMaterialBlock {
  66985. /**
  66986. * Create a new ImageProcessingBlock
  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 color input component
  66997. */
  66998. get color(): NodeMaterialConnectionPoint;
  66999. /**
  67000. * Gets the output component
  67001. */
  67002. get output(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Initialize the block and prepare the context for build
  67005. * @param state defines the state that will be used for the build
  67006. */
  67007. initialize(state: NodeMaterialBuildState): void;
  67008. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67011. protected _buildBlock(state: NodeMaterialBuildState): this;
  67012. }
  67013. }
  67014. declare module BABYLON {
  67015. /**
  67016. * Block used to pertub normals based on a normal map
  67017. */
  67018. export class PerturbNormalBlock extends NodeMaterialBlock {
  67019. private _tangentSpaceParameterName;
  67020. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67021. invertX: boolean;
  67022. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67023. invertY: boolean;
  67024. /**
  67025. * Create a new PerturbNormalBlock
  67026. * @param name defines the block name
  67027. */
  67028. constructor(name: string);
  67029. /**
  67030. * Gets the current class name
  67031. * @returns the class name
  67032. */
  67033. getClassName(): string;
  67034. /**
  67035. * Gets the world position input component
  67036. */
  67037. get worldPosition(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the world normal input component
  67040. */
  67041. get worldNormal(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the world tangent input component
  67044. */
  67045. get worldTangent(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the uv input component
  67048. */
  67049. get uv(): NodeMaterialConnectionPoint;
  67050. /**
  67051. * Gets the normal map color input component
  67052. */
  67053. get normalMapColor(): NodeMaterialConnectionPoint;
  67054. /**
  67055. * Gets the strength input component
  67056. */
  67057. get strength(): NodeMaterialConnectionPoint;
  67058. /**
  67059. * Gets the output component
  67060. */
  67061. get output(): NodeMaterialConnectionPoint;
  67062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67064. autoConfigure(material: NodeMaterial): void;
  67065. protected _buildBlock(state: NodeMaterialBuildState): this;
  67066. protected _dumpPropertiesCode(): string;
  67067. serialize(): any;
  67068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67069. }
  67070. }
  67071. declare module BABYLON {
  67072. /**
  67073. * Block used to discard a pixel if a value is smaller than a cutoff
  67074. */
  67075. export class DiscardBlock extends NodeMaterialBlock {
  67076. /**
  67077. * Create a new DiscardBlock
  67078. * @param name defines the block name
  67079. */
  67080. constructor(name: string);
  67081. /**
  67082. * Gets the current class name
  67083. * @returns the class name
  67084. */
  67085. getClassName(): string;
  67086. /**
  67087. * Gets the color input component
  67088. */
  67089. get value(): NodeMaterialConnectionPoint;
  67090. /**
  67091. * Gets the cutoff input component
  67092. */
  67093. get cutoff(): NodeMaterialConnectionPoint;
  67094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67095. }
  67096. }
  67097. declare module BABYLON {
  67098. /**
  67099. * Block used to test if the fragment shader is front facing
  67100. */
  67101. export class FrontFacingBlock extends NodeMaterialBlock {
  67102. /**
  67103. * Creates a new FrontFacingBlock
  67104. * @param name defines the block name
  67105. */
  67106. constructor(name: string);
  67107. /**
  67108. * Gets the current class name
  67109. * @returns the class name
  67110. */
  67111. getClassName(): string;
  67112. /**
  67113. * Gets the output component
  67114. */
  67115. get output(): NodeMaterialConnectionPoint;
  67116. protected _buildBlock(state: NodeMaterialBuildState): this;
  67117. }
  67118. }
  67119. declare module BABYLON {
  67120. /**
  67121. * Block used to get the derivative value on x and y of a given input
  67122. */
  67123. export class DerivativeBlock extends NodeMaterialBlock {
  67124. /**
  67125. * Create a new DerivativeBlock
  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 input component
  67136. */
  67137. get input(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the derivative output on x
  67140. */
  67141. get dx(): NodeMaterialConnectionPoint;
  67142. /**
  67143. * Gets the derivative output on y
  67144. */
  67145. get dy(): NodeMaterialConnectionPoint;
  67146. protected _buildBlock(state: NodeMaterialBuildState): this;
  67147. }
  67148. }
  67149. declare module BABYLON {
  67150. /**
  67151. * Block used to make gl_FragCoord available
  67152. */
  67153. export class FragCoordBlock extends NodeMaterialBlock {
  67154. /**
  67155. * Creates a new FragCoordBlock
  67156. * @param name defines the block name
  67157. */
  67158. constructor(name: string);
  67159. /**
  67160. * Gets the current class name
  67161. * @returns the class name
  67162. */
  67163. getClassName(): string;
  67164. /**
  67165. * Gets the xy component
  67166. */
  67167. get xy(): NodeMaterialConnectionPoint;
  67168. /**
  67169. * Gets the xyz component
  67170. */
  67171. get xyz(): NodeMaterialConnectionPoint;
  67172. /**
  67173. * Gets the xyzw component
  67174. */
  67175. get xyzw(): NodeMaterialConnectionPoint;
  67176. /**
  67177. * Gets the x component
  67178. */
  67179. get x(): NodeMaterialConnectionPoint;
  67180. /**
  67181. * Gets the y component
  67182. */
  67183. get y(): NodeMaterialConnectionPoint;
  67184. /**
  67185. * Gets the z component
  67186. */
  67187. get z(): NodeMaterialConnectionPoint;
  67188. /**
  67189. * Gets the w component
  67190. */
  67191. get output(): NodeMaterialConnectionPoint;
  67192. protected writeOutputs(state: NodeMaterialBuildState): string;
  67193. protected _buildBlock(state: NodeMaterialBuildState): this;
  67194. }
  67195. }
  67196. declare module BABYLON {
  67197. /**
  67198. * Block used to get the screen sizes
  67199. */
  67200. export class ScreenSizeBlock extends NodeMaterialBlock {
  67201. private _varName;
  67202. private _scene;
  67203. /**
  67204. * Creates a new ScreenSizeBlock
  67205. * @param name defines the block name
  67206. */
  67207. constructor(name: string);
  67208. /**
  67209. * Gets the current class name
  67210. * @returns the class name
  67211. */
  67212. getClassName(): string;
  67213. /**
  67214. * Gets the xy component
  67215. */
  67216. get xy(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the x component
  67219. */
  67220. get x(): NodeMaterialConnectionPoint;
  67221. /**
  67222. * Gets the y component
  67223. */
  67224. get y(): NodeMaterialConnectionPoint;
  67225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67226. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67227. protected _buildBlock(state: NodeMaterialBuildState): this;
  67228. }
  67229. }
  67230. declare module BABYLON {
  67231. /**
  67232. * Block used to add support for scene fog
  67233. */
  67234. export class FogBlock extends NodeMaterialBlock {
  67235. private _fogDistanceName;
  67236. private _fogParameters;
  67237. /**
  67238. * Create a new FogBlock
  67239. * @param name defines the block name
  67240. */
  67241. constructor(name: string);
  67242. /**
  67243. * Gets the current class name
  67244. * @returns the class name
  67245. */
  67246. getClassName(): string;
  67247. /**
  67248. * Gets the world position input component
  67249. */
  67250. get worldPosition(): NodeMaterialConnectionPoint;
  67251. /**
  67252. * Gets the view input component
  67253. */
  67254. get view(): NodeMaterialConnectionPoint;
  67255. /**
  67256. * Gets the color input component
  67257. */
  67258. get input(): NodeMaterialConnectionPoint;
  67259. /**
  67260. * Gets the fog color input component
  67261. */
  67262. get fogColor(): NodeMaterialConnectionPoint;
  67263. /**
  67264. * Gets the output component
  67265. */
  67266. get output(): NodeMaterialConnectionPoint;
  67267. autoConfigure(material: NodeMaterial): void;
  67268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67269. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67270. protected _buildBlock(state: NodeMaterialBuildState): this;
  67271. }
  67272. }
  67273. declare module BABYLON {
  67274. /**
  67275. * Block used to add light in the fragment shader
  67276. */
  67277. export class LightBlock extends NodeMaterialBlock {
  67278. private _lightId;
  67279. /**
  67280. * Gets or sets the light associated with this block
  67281. */
  67282. light: Nullable<Light>;
  67283. /**
  67284. * Create a new LightBlock
  67285. * @param name defines the block name
  67286. */
  67287. constructor(name: string);
  67288. /**
  67289. * Gets the current class name
  67290. * @returns the class name
  67291. */
  67292. getClassName(): string;
  67293. /**
  67294. * Gets the world position input component
  67295. */
  67296. get worldPosition(): NodeMaterialConnectionPoint;
  67297. /**
  67298. * Gets the world normal input component
  67299. */
  67300. get worldNormal(): NodeMaterialConnectionPoint;
  67301. /**
  67302. * Gets the camera (or eye) position component
  67303. */
  67304. get cameraPosition(): NodeMaterialConnectionPoint;
  67305. /**
  67306. * Gets the glossiness component
  67307. */
  67308. get glossiness(): NodeMaterialConnectionPoint;
  67309. /**
  67310. * Gets the glossinness power component
  67311. */
  67312. get glossPower(): NodeMaterialConnectionPoint;
  67313. /**
  67314. * Gets the diffuse color component
  67315. */
  67316. get diffuseColor(): NodeMaterialConnectionPoint;
  67317. /**
  67318. * Gets the specular color component
  67319. */
  67320. get specularColor(): NodeMaterialConnectionPoint;
  67321. /**
  67322. * Gets the view matrix component
  67323. */
  67324. get view(): NodeMaterialConnectionPoint;
  67325. /**
  67326. * Gets the diffuse output component
  67327. */
  67328. get diffuseOutput(): NodeMaterialConnectionPoint;
  67329. /**
  67330. * Gets the specular output component
  67331. */
  67332. get specularOutput(): NodeMaterialConnectionPoint;
  67333. /**
  67334. * Gets the shadow output component
  67335. */
  67336. get shadow(): NodeMaterialConnectionPoint;
  67337. autoConfigure(material: NodeMaterial): void;
  67338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67339. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67341. private _injectVertexCode;
  67342. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67343. serialize(): any;
  67344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67345. }
  67346. }
  67347. declare module BABYLON {
  67348. /**
  67349. * Block used to read a reflection texture from a sampler
  67350. */
  67351. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67352. /**
  67353. * Create a new ReflectionTextureBlock
  67354. * @param name defines the block name
  67355. */
  67356. constructor(name: string);
  67357. /**
  67358. * Gets the current class name
  67359. * @returns the class name
  67360. */
  67361. getClassName(): string;
  67362. /**
  67363. * Gets the world position input component
  67364. */
  67365. get position(): NodeMaterialConnectionPoint;
  67366. /**
  67367. * Gets the world position input component
  67368. */
  67369. get worldPosition(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the world normal input component
  67372. */
  67373. get worldNormal(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the world input component
  67376. */
  67377. get world(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the camera (or eye) position component
  67380. */
  67381. get cameraPosition(): NodeMaterialConnectionPoint;
  67382. /**
  67383. * Gets the view input component
  67384. */
  67385. get view(): NodeMaterialConnectionPoint;
  67386. /**
  67387. * Gets the rgb output component
  67388. */
  67389. get rgb(): NodeMaterialConnectionPoint;
  67390. /**
  67391. * Gets the rgba output component
  67392. */
  67393. get rgba(): NodeMaterialConnectionPoint;
  67394. /**
  67395. * Gets the r output component
  67396. */
  67397. get r(): NodeMaterialConnectionPoint;
  67398. /**
  67399. * Gets the g output component
  67400. */
  67401. get g(): NodeMaterialConnectionPoint;
  67402. /**
  67403. * Gets the b output component
  67404. */
  67405. get b(): NodeMaterialConnectionPoint;
  67406. /**
  67407. * Gets the a output component
  67408. */
  67409. get a(): NodeMaterialConnectionPoint;
  67410. autoConfigure(material: NodeMaterial): void;
  67411. protected _buildBlock(state: NodeMaterialBuildState): this;
  67412. }
  67413. }
  67414. declare module BABYLON {
  67415. /**
  67416. * Block used to add 2 vectors
  67417. */
  67418. export class AddBlock extends NodeMaterialBlock {
  67419. /**
  67420. * Creates a new AddBlock
  67421. * @param name defines the block name
  67422. */
  67423. constructor(name: string);
  67424. /**
  67425. * Gets the current class name
  67426. * @returns the class name
  67427. */
  67428. getClassName(): string;
  67429. /**
  67430. * Gets the left operand input component
  67431. */
  67432. get left(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the right operand input component
  67435. */
  67436. get right(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the output component
  67439. */
  67440. get output(): NodeMaterialConnectionPoint;
  67441. protected _buildBlock(state: NodeMaterialBuildState): this;
  67442. }
  67443. }
  67444. declare module BABYLON {
  67445. /**
  67446. * Block used to scale a vector by a float
  67447. */
  67448. export class ScaleBlock extends NodeMaterialBlock {
  67449. /**
  67450. * Creates a new ScaleBlock
  67451. * @param name defines the block name
  67452. */
  67453. constructor(name: string);
  67454. /**
  67455. * Gets the current class name
  67456. * @returns the class name
  67457. */
  67458. getClassName(): string;
  67459. /**
  67460. * Gets the input component
  67461. */
  67462. get input(): NodeMaterialConnectionPoint;
  67463. /**
  67464. * Gets the factor input component
  67465. */
  67466. get factor(): NodeMaterialConnectionPoint;
  67467. /**
  67468. * Gets the output component
  67469. */
  67470. get output(): NodeMaterialConnectionPoint;
  67471. protected _buildBlock(state: NodeMaterialBuildState): this;
  67472. }
  67473. }
  67474. declare module BABYLON {
  67475. /**
  67476. * Block used to clamp a float
  67477. */
  67478. export class ClampBlock extends NodeMaterialBlock {
  67479. /** Gets or sets the minimum range */
  67480. minimum: number;
  67481. /** Gets or sets the maximum range */
  67482. maximum: number;
  67483. /**
  67484. * Creates a new ClampBlock
  67485. * @param name defines the block name
  67486. */
  67487. constructor(name: string);
  67488. /**
  67489. * Gets the current class name
  67490. * @returns the class name
  67491. */
  67492. getClassName(): string;
  67493. /**
  67494. * Gets the value input component
  67495. */
  67496. get value(): NodeMaterialConnectionPoint;
  67497. /**
  67498. * Gets the output component
  67499. */
  67500. get output(): NodeMaterialConnectionPoint;
  67501. protected _buildBlock(state: NodeMaterialBuildState): this;
  67502. protected _dumpPropertiesCode(): string;
  67503. serialize(): any;
  67504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67505. }
  67506. }
  67507. declare module BABYLON {
  67508. /**
  67509. * Block used to apply a cross product between 2 vectors
  67510. */
  67511. export class CrossBlock extends NodeMaterialBlock {
  67512. /**
  67513. * Creates a new CrossBlock
  67514. * @param name defines the block name
  67515. */
  67516. constructor(name: string);
  67517. /**
  67518. * Gets the current class name
  67519. * @returns the class name
  67520. */
  67521. getClassName(): string;
  67522. /**
  67523. * Gets the left operand input component
  67524. */
  67525. get left(): NodeMaterialConnectionPoint;
  67526. /**
  67527. * Gets the right operand input component
  67528. */
  67529. get right(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the output component
  67532. */
  67533. get output(): NodeMaterialConnectionPoint;
  67534. protected _buildBlock(state: NodeMaterialBuildState): this;
  67535. }
  67536. }
  67537. declare module BABYLON {
  67538. /**
  67539. * Block used to apply a dot product between 2 vectors
  67540. */
  67541. export class DotBlock extends NodeMaterialBlock {
  67542. /**
  67543. * Creates a new DotBlock
  67544. * @param name defines the block name
  67545. */
  67546. constructor(name: string);
  67547. /**
  67548. * Gets the current class name
  67549. * @returns the class name
  67550. */
  67551. getClassName(): string;
  67552. /**
  67553. * Gets the left operand input component
  67554. */
  67555. get left(): NodeMaterialConnectionPoint;
  67556. /**
  67557. * Gets the right operand input component
  67558. */
  67559. get right(): NodeMaterialConnectionPoint;
  67560. /**
  67561. * Gets the output component
  67562. */
  67563. get output(): NodeMaterialConnectionPoint;
  67564. protected _buildBlock(state: NodeMaterialBuildState): this;
  67565. }
  67566. }
  67567. declare module BABYLON {
  67568. /**
  67569. * Block used to normalize a vector
  67570. */
  67571. export class NormalizeBlock extends NodeMaterialBlock {
  67572. /**
  67573. * Creates a new NormalizeBlock
  67574. * @param name defines the block name
  67575. */
  67576. constructor(name: string);
  67577. /**
  67578. * Gets the current class name
  67579. * @returns the class name
  67580. */
  67581. getClassName(): string;
  67582. /**
  67583. * Gets the input component
  67584. */
  67585. get input(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the output component
  67588. */
  67589. get output(): NodeMaterialConnectionPoint;
  67590. protected _buildBlock(state: NodeMaterialBuildState): this;
  67591. }
  67592. }
  67593. declare module BABYLON {
  67594. /**
  67595. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67596. */
  67597. export class ColorMergerBlock extends NodeMaterialBlock {
  67598. /**
  67599. * Create a new ColorMergerBlock
  67600. * @param name defines the block name
  67601. */
  67602. constructor(name: string);
  67603. /**
  67604. * Gets the current class name
  67605. * @returns the class name
  67606. */
  67607. getClassName(): string;
  67608. /**
  67609. * Gets the rgb component (input)
  67610. */
  67611. get rgbIn(): NodeMaterialConnectionPoint;
  67612. /**
  67613. * Gets the r component (input)
  67614. */
  67615. get r(): NodeMaterialConnectionPoint;
  67616. /**
  67617. * Gets the g component (input)
  67618. */
  67619. get g(): NodeMaterialConnectionPoint;
  67620. /**
  67621. * Gets the b component (input)
  67622. */
  67623. get b(): NodeMaterialConnectionPoint;
  67624. /**
  67625. * Gets the a component (input)
  67626. */
  67627. get a(): NodeMaterialConnectionPoint;
  67628. /**
  67629. * Gets the rgba component (output)
  67630. */
  67631. get rgba(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the rgb component (output)
  67634. */
  67635. get rgbOut(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the rgb component (output)
  67638. * @deprecated Please use rgbOut instead.
  67639. */
  67640. get rgb(): NodeMaterialConnectionPoint;
  67641. protected _buildBlock(state: NodeMaterialBuildState): this;
  67642. }
  67643. }
  67644. declare module BABYLON {
  67645. /**
  67646. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67647. */
  67648. export class VectorSplitterBlock extends NodeMaterialBlock {
  67649. /**
  67650. * Create a new VectorSplitterBlock
  67651. * @param name defines the block name
  67652. */
  67653. constructor(name: string);
  67654. /**
  67655. * Gets the current class name
  67656. * @returns the class name
  67657. */
  67658. getClassName(): string;
  67659. /**
  67660. * Gets the xyzw component (input)
  67661. */
  67662. get xyzw(): NodeMaterialConnectionPoint;
  67663. /**
  67664. * Gets the xyz component (input)
  67665. */
  67666. get xyzIn(): NodeMaterialConnectionPoint;
  67667. /**
  67668. * Gets the xy component (input)
  67669. */
  67670. get xyIn(): NodeMaterialConnectionPoint;
  67671. /**
  67672. * Gets the xyz component (output)
  67673. */
  67674. get xyzOut(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the xy component (output)
  67677. */
  67678. get xyOut(): NodeMaterialConnectionPoint;
  67679. /**
  67680. * Gets the x component (output)
  67681. */
  67682. get x(): NodeMaterialConnectionPoint;
  67683. /**
  67684. * Gets the y component (output)
  67685. */
  67686. get y(): NodeMaterialConnectionPoint;
  67687. /**
  67688. * Gets the z component (output)
  67689. */
  67690. get z(): NodeMaterialConnectionPoint;
  67691. /**
  67692. * Gets the w component (output)
  67693. */
  67694. get w(): NodeMaterialConnectionPoint;
  67695. protected _inputRename(name: string): string;
  67696. protected _outputRename(name: string): string;
  67697. protected _buildBlock(state: NodeMaterialBuildState): this;
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /**
  67702. * Block used to lerp between 2 values
  67703. */
  67704. export class LerpBlock extends NodeMaterialBlock {
  67705. /**
  67706. * Creates a new LerpBlock
  67707. * @param name defines the block name
  67708. */
  67709. constructor(name: string);
  67710. /**
  67711. * Gets the current class name
  67712. * @returns the class name
  67713. */
  67714. getClassName(): string;
  67715. /**
  67716. * Gets the left operand input component
  67717. */
  67718. get left(): NodeMaterialConnectionPoint;
  67719. /**
  67720. * Gets the right operand input component
  67721. */
  67722. get right(): NodeMaterialConnectionPoint;
  67723. /**
  67724. * Gets the gradient operand input component
  67725. */
  67726. get gradient(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the output component
  67729. */
  67730. get output(): NodeMaterialConnectionPoint;
  67731. protected _buildBlock(state: NodeMaterialBuildState): this;
  67732. }
  67733. }
  67734. declare module BABYLON {
  67735. /**
  67736. * Block used to divide 2 vectors
  67737. */
  67738. export class DivideBlock extends NodeMaterialBlock {
  67739. /**
  67740. * Creates a new DivideBlock
  67741. * @param name defines the block name
  67742. */
  67743. constructor(name: string);
  67744. /**
  67745. * Gets the current class name
  67746. * @returns the class name
  67747. */
  67748. getClassName(): string;
  67749. /**
  67750. * Gets the left operand input component
  67751. */
  67752. get left(): NodeMaterialConnectionPoint;
  67753. /**
  67754. * Gets the right operand input component
  67755. */
  67756. get right(): NodeMaterialConnectionPoint;
  67757. /**
  67758. * Gets the output component
  67759. */
  67760. get output(): NodeMaterialConnectionPoint;
  67761. protected _buildBlock(state: NodeMaterialBuildState): this;
  67762. }
  67763. }
  67764. declare module BABYLON {
  67765. /**
  67766. * Block used to subtract 2 vectors
  67767. */
  67768. export class SubtractBlock extends NodeMaterialBlock {
  67769. /**
  67770. * Creates a new SubtractBlock
  67771. * @param name defines the block name
  67772. */
  67773. constructor(name: string);
  67774. /**
  67775. * Gets the current class name
  67776. * @returns the class name
  67777. */
  67778. getClassName(): string;
  67779. /**
  67780. * Gets the left operand input component
  67781. */
  67782. get left(): NodeMaterialConnectionPoint;
  67783. /**
  67784. * Gets the right operand input component
  67785. */
  67786. get right(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the output component
  67789. */
  67790. get output(): NodeMaterialConnectionPoint;
  67791. protected _buildBlock(state: NodeMaterialBuildState): this;
  67792. }
  67793. }
  67794. declare module BABYLON {
  67795. /**
  67796. * Block used to step a value
  67797. */
  67798. export class StepBlock extends NodeMaterialBlock {
  67799. /**
  67800. * Creates a new StepBlock
  67801. * @param name defines the block name
  67802. */
  67803. constructor(name: string);
  67804. /**
  67805. * Gets the current class name
  67806. * @returns the class name
  67807. */
  67808. getClassName(): string;
  67809. /**
  67810. * Gets the value operand input component
  67811. */
  67812. get value(): NodeMaterialConnectionPoint;
  67813. /**
  67814. * Gets the edge operand input component
  67815. */
  67816. get edge(): NodeMaterialConnectionPoint;
  67817. /**
  67818. * Gets the output component
  67819. */
  67820. get output(): NodeMaterialConnectionPoint;
  67821. protected _buildBlock(state: NodeMaterialBuildState): this;
  67822. }
  67823. }
  67824. declare module BABYLON {
  67825. /**
  67826. * Block used to get the opposite (1 - x) of a value
  67827. */
  67828. export class OneMinusBlock extends NodeMaterialBlock {
  67829. /**
  67830. * Creates a new OneMinusBlock
  67831. * @param name defines the block name
  67832. */
  67833. constructor(name: string);
  67834. /**
  67835. * Gets the current class name
  67836. * @returns the class name
  67837. */
  67838. getClassName(): string;
  67839. /**
  67840. * Gets the input component
  67841. */
  67842. get input(): NodeMaterialConnectionPoint;
  67843. /**
  67844. * Gets the output component
  67845. */
  67846. get output(): NodeMaterialConnectionPoint;
  67847. protected _buildBlock(state: NodeMaterialBuildState): this;
  67848. }
  67849. }
  67850. declare module BABYLON {
  67851. /**
  67852. * Block used to get the view direction
  67853. */
  67854. export class ViewDirectionBlock extends NodeMaterialBlock {
  67855. /**
  67856. * Creates a new ViewDirectionBlock
  67857. * @param name defines the block name
  67858. */
  67859. constructor(name: string);
  67860. /**
  67861. * Gets the current class name
  67862. * @returns the class name
  67863. */
  67864. getClassName(): string;
  67865. /**
  67866. * Gets the world position component
  67867. */
  67868. get worldPosition(): NodeMaterialConnectionPoint;
  67869. /**
  67870. * Gets the camera position component
  67871. */
  67872. get cameraPosition(): NodeMaterialConnectionPoint;
  67873. /**
  67874. * Gets the output component
  67875. */
  67876. get output(): NodeMaterialConnectionPoint;
  67877. autoConfigure(material: NodeMaterial): void;
  67878. protected _buildBlock(state: NodeMaterialBuildState): this;
  67879. }
  67880. }
  67881. declare module BABYLON {
  67882. /**
  67883. * Block used to compute fresnel value
  67884. */
  67885. export class FresnelBlock extends NodeMaterialBlock {
  67886. /**
  67887. * Create a new FresnelBlock
  67888. * @param name defines the block name
  67889. */
  67890. constructor(name: string);
  67891. /**
  67892. * Gets the current class name
  67893. * @returns the class name
  67894. */
  67895. getClassName(): string;
  67896. /**
  67897. * Gets the world normal input component
  67898. */
  67899. get worldNormal(): NodeMaterialConnectionPoint;
  67900. /**
  67901. * Gets the view direction input component
  67902. */
  67903. get viewDirection(): NodeMaterialConnectionPoint;
  67904. /**
  67905. * Gets the bias input component
  67906. */
  67907. get bias(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the camera (or eye) position component
  67910. */
  67911. get power(): NodeMaterialConnectionPoint;
  67912. /**
  67913. * Gets the fresnel output component
  67914. */
  67915. get fresnel(): NodeMaterialConnectionPoint;
  67916. autoConfigure(material: NodeMaterial): void;
  67917. protected _buildBlock(state: NodeMaterialBuildState): this;
  67918. }
  67919. }
  67920. declare module BABYLON {
  67921. /**
  67922. * Block used to get the max of 2 values
  67923. */
  67924. export class MaxBlock extends NodeMaterialBlock {
  67925. /**
  67926. * Creates a new MaxBlock
  67927. * @param name defines the block name
  67928. */
  67929. constructor(name: string);
  67930. /**
  67931. * Gets the current class name
  67932. * @returns the class name
  67933. */
  67934. getClassName(): string;
  67935. /**
  67936. * Gets the left operand input component
  67937. */
  67938. get left(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the right operand input component
  67941. */
  67942. get right(): 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 min of 2 values
  67953. */
  67954. export class MinBlock extends NodeMaterialBlock {
  67955. /**
  67956. * Creates a new MinBlock
  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 left operand input component
  67967. */
  67968. get left(): NodeMaterialConnectionPoint;
  67969. /**
  67970. * Gets the right operand input component
  67971. */
  67972. get right(): NodeMaterialConnectionPoint;
  67973. /**
  67974. * Gets the output component
  67975. */
  67976. get output(): NodeMaterialConnectionPoint;
  67977. protected _buildBlock(state: NodeMaterialBuildState): this;
  67978. }
  67979. }
  67980. declare module BABYLON {
  67981. /**
  67982. * Block used to get the distance between 2 values
  67983. */
  67984. export class DistanceBlock extends NodeMaterialBlock {
  67985. /**
  67986. * Creates a new DistanceBlock
  67987. * @param name defines the block name
  67988. */
  67989. constructor(name: string);
  67990. /**
  67991. * Gets the current class name
  67992. * @returns the class name
  67993. */
  67994. getClassName(): string;
  67995. /**
  67996. * Gets the left operand input component
  67997. */
  67998. get left(): NodeMaterialConnectionPoint;
  67999. /**
  68000. * Gets the right operand input component
  68001. */
  68002. get right(): NodeMaterialConnectionPoint;
  68003. /**
  68004. * Gets the output component
  68005. */
  68006. get output(): NodeMaterialConnectionPoint;
  68007. protected _buildBlock(state: NodeMaterialBuildState): this;
  68008. }
  68009. }
  68010. declare module BABYLON {
  68011. /**
  68012. * Block used to get the length of a vector
  68013. */
  68014. export class LengthBlock extends NodeMaterialBlock {
  68015. /**
  68016. * Creates a new LengthBlock
  68017. * @param name defines the block name
  68018. */
  68019. constructor(name: string);
  68020. /**
  68021. * Gets the current class name
  68022. * @returns the class name
  68023. */
  68024. getClassName(): string;
  68025. /**
  68026. * Gets the value input component
  68027. */
  68028. get value(): NodeMaterialConnectionPoint;
  68029. /**
  68030. * Gets the output component
  68031. */
  68032. get output(): NodeMaterialConnectionPoint;
  68033. protected _buildBlock(state: NodeMaterialBuildState): this;
  68034. }
  68035. }
  68036. declare module BABYLON {
  68037. /**
  68038. * Block used to get negative version of a value (i.e. x * -1)
  68039. */
  68040. export class NegateBlock extends NodeMaterialBlock {
  68041. /**
  68042. * Creates a new NegateBlock
  68043. * @param name defines the block name
  68044. */
  68045. constructor(name: string);
  68046. /**
  68047. * Gets the current class name
  68048. * @returns the class name
  68049. */
  68050. getClassName(): string;
  68051. /**
  68052. * Gets the value input component
  68053. */
  68054. get value(): NodeMaterialConnectionPoint;
  68055. /**
  68056. * Gets the output component
  68057. */
  68058. get output(): NodeMaterialConnectionPoint;
  68059. protected _buildBlock(state: NodeMaterialBuildState): this;
  68060. }
  68061. }
  68062. declare module BABYLON {
  68063. /**
  68064. * Block used to get the value of the first parameter raised to the power of the second
  68065. */
  68066. export class PowBlock extends NodeMaterialBlock {
  68067. /**
  68068. * Creates a new PowBlock
  68069. * @param name defines the block name
  68070. */
  68071. constructor(name: string);
  68072. /**
  68073. * Gets the current class name
  68074. * @returns the class name
  68075. */
  68076. getClassName(): string;
  68077. /**
  68078. * Gets the value operand input component
  68079. */
  68080. get value(): NodeMaterialConnectionPoint;
  68081. /**
  68082. * Gets the power operand input component
  68083. */
  68084. get power(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the output component
  68087. */
  68088. get output(): NodeMaterialConnectionPoint;
  68089. protected _buildBlock(state: NodeMaterialBuildState): this;
  68090. }
  68091. }
  68092. declare module BABYLON {
  68093. /**
  68094. * Block used to get a random number
  68095. */
  68096. export class RandomNumberBlock extends NodeMaterialBlock {
  68097. /**
  68098. * Creates a new RandomNumberBlock
  68099. * @param name defines the block name
  68100. */
  68101. constructor(name: string);
  68102. /**
  68103. * Gets the current class name
  68104. * @returns the class name
  68105. */
  68106. getClassName(): string;
  68107. /**
  68108. * Gets the seed input component
  68109. */
  68110. get seed(): NodeMaterialConnectionPoint;
  68111. /**
  68112. * Gets the output component
  68113. */
  68114. get output(): NodeMaterialConnectionPoint;
  68115. protected _buildBlock(state: NodeMaterialBuildState): this;
  68116. }
  68117. }
  68118. declare module BABYLON {
  68119. /**
  68120. * Block used to compute arc tangent of 2 values
  68121. */
  68122. export class ArcTan2Block extends NodeMaterialBlock {
  68123. /**
  68124. * Creates a new ArcTan2Block
  68125. * @param name defines the block name
  68126. */
  68127. constructor(name: string);
  68128. /**
  68129. * Gets the current class name
  68130. * @returns the class name
  68131. */
  68132. getClassName(): string;
  68133. /**
  68134. * Gets the x operand input component
  68135. */
  68136. get x(): NodeMaterialConnectionPoint;
  68137. /**
  68138. * Gets the y operand input component
  68139. */
  68140. get y(): NodeMaterialConnectionPoint;
  68141. /**
  68142. * Gets the output component
  68143. */
  68144. get output(): NodeMaterialConnectionPoint;
  68145. protected _buildBlock(state: NodeMaterialBuildState): this;
  68146. }
  68147. }
  68148. declare module BABYLON {
  68149. /**
  68150. * Block used to smooth step a value
  68151. */
  68152. export class SmoothStepBlock extends NodeMaterialBlock {
  68153. /**
  68154. * Creates a new SmoothStepBlock
  68155. * @param name defines the block name
  68156. */
  68157. constructor(name: string);
  68158. /**
  68159. * Gets the current class name
  68160. * @returns the class name
  68161. */
  68162. getClassName(): string;
  68163. /**
  68164. * Gets the value operand input component
  68165. */
  68166. get value(): NodeMaterialConnectionPoint;
  68167. /**
  68168. * Gets the first edge operand input component
  68169. */
  68170. get edge0(): NodeMaterialConnectionPoint;
  68171. /**
  68172. * Gets the second edge operand input component
  68173. */
  68174. get edge1(): NodeMaterialConnectionPoint;
  68175. /**
  68176. * Gets the output component
  68177. */
  68178. get output(): NodeMaterialConnectionPoint;
  68179. protected _buildBlock(state: NodeMaterialBuildState): this;
  68180. }
  68181. }
  68182. declare module BABYLON {
  68183. /**
  68184. * Block used to get the reciprocal (1 / x) of a value
  68185. */
  68186. export class ReciprocalBlock extends NodeMaterialBlock {
  68187. /**
  68188. * Creates a new ReciprocalBlock
  68189. * @param name defines the block name
  68190. */
  68191. constructor(name: string);
  68192. /**
  68193. * Gets the current class name
  68194. * @returns the class name
  68195. */
  68196. getClassName(): string;
  68197. /**
  68198. * Gets the input component
  68199. */
  68200. get input(): NodeMaterialConnectionPoint;
  68201. /**
  68202. * Gets the output component
  68203. */
  68204. get output(): NodeMaterialConnectionPoint;
  68205. protected _buildBlock(state: NodeMaterialBuildState): this;
  68206. }
  68207. }
  68208. declare module BABYLON {
  68209. /**
  68210. * Block used to replace a color by another one
  68211. */
  68212. export class ReplaceColorBlock extends NodeMaterialBlock {
  68213. /**
  68214. * Creates a new ReplaceColorBlock
  68215. * @param name defines the block name
  68216. */
  68217. constructor(name: string);
  68218. /**
  68219. * Gets the current class name
  68220. * @returns the class name
  68221. */
  68222. getClassName(): string;
  68223. /**
  68224. * Gets the value input component
  68225. */
  68226. get value(): NodeMaterialConnectionPoint;
  68227. /**
  68228. * Gets the reference input component
  68229. */
  68230. get reference(): NodeMaterialConnectionPoint;
  68231. /**
  68232. * Gets the distance input component
  68233. */
  68234. get distance(): NodeMaterialConnectionPoint;
  68235. /**
  68236. * Gets the replacement input component
  68237. */
  68238. get replacement(): NodeMaterialConnectionPoint;
  68239. /**
  68240. * Gets the output component
  68241. */
  68242. get output(): NodeMaterialConnectionPoint;
  68243. protected _buildBlock(state: NodeMaterialBuildState): this;
  68244. }
  68245. }
  68246. declare module BABYLON {
  68247. /**
  68248. * Block used to posterize a value
  68249. * @see https://en.wikipedia.org/wiki/Posterization
  68250. */
  68251. export class PosterizeBlock extends NodeMaterialBlock {
  68252. /**
  68253. * Creates a new PosterizeBlock
  68254. * @param name defines the block name
  68255. */
  68256. constructor(name: string);
  68257. /**
  68258. * Gets the current class name
  68259. * @returns the class name
  68260. */
  68261. getClassName(): string;
  68262. /**
  68263. * Gets the value input component
  68264. */
  68265. get value(): NodeMaterialConnectionPoint;
  68266. /**
  68267. * Gets the steps input component
  68268. */
  68269. get steps(): NodeMaterialConnectionPoint;
  68270. /**
  68271. * Gets the output component
  68272. */
  68273. get output(): NodeMaterialConnectionPoint;
  68274. protected _buildBlock(state: NodeMaterialBuildState): this;
  68275. }
  68276. }
  68277. declare module BABYLON {
  68278. /**
  68279. * Operations supported by the Wave block
  68280. */
  68281. export enum WaveBlockKind {
  68282. /** SawTooth */
  68283. SawTooth = 0,
  68284. /** Square */
  68285. Square = 1,
  68286. /** Triangle */
  68287. Triangle = 2
  68288. }
  68289. /**
  68290. * Block used to apply wave operation to floats
  68291. */
  68292. export class WaveBlock extends NodeMaterialBlock {
  68293. /**
  68294. * Gets or sets the kibnd of wave to be applied by the block
  68295. */
  68296. kind: WaveBlockKind;
  68297. /**
  68298. * Creates a new WaveBlock
  68299. * @param name defines the block name
  68300. */
  68301. constructor(name: string);
  68302. /**
  68303. * Gets the current class name
  68304. * @returns the class name
  68305. */
  68306. getClassName(): string;
  68307. /**
  68308. * Gets the input component
  68309. */
  68310. get input(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the output component
  68313. */
  68314. get output(): NodeMaterialConnectionPoint;
  68315. protected _buildBlock(state: NodeMaterialBuildState): this;
  68316. serialize(): any;
  68317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68318. }
  68319. }
  68320. declare module BABYLON {
  68321. /**
  68322. * Class used to store a color step for the GradientBlock
  68323. */
  68324. export class GradientBlockColorStep {
  68325. private _step;
  68326. /**
  68327. * Gets value indicating which step this color is associated with (between 0 and 1)
  68328. */
  68329. get step(): number;
  68330. /**
  68331. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68332. */
  68333. set step(val: number);
  68334. private _color;
  68335. /**
  68336. * Gets the color associated with this step
  68337. */
  68338. get color(): Color3;
  68339. /**
  68340. * Sets the color associated with this step
  68341. */
  68342. set color(val: Color3);
  68343. /**
  68344. * Creates a new GradientBlockColorStep
  68345. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68346. * @param color defines the color associated with this step
  68347. */
  68348. constructor(step: number, color: Color3);
  68349. }
  68350. /**
  68351. * Block used to return a color from a gradient based on an input value between 0 and 1
  68352. */
  68353. export class GradientBlock extends NodeMaterialBlock {
  68354. /**
  68355. * Gets or sets the list of color steps
  68356. */
  68357. colorSteps: GradientBlockColorStep[];
  68358. /** Gets an observable raised when the value is changed */
  68359. onValueChangedObservable: Observable<GradientBlock>;
  68360. /** calls observable when the value is changed*/
  68361. colorStepsUpdated(): void;
  68362. /**
  68363. * Creates a new GradientBlock
  68364. * @param name defines the block name
  68365. */
  68366. constructor(name: string);
  68367. /**
  68368. * Gets the current class name
  68369. * @returns the class name
  68370. */
  68371. getClassName(): string;
  68372. /**
  68373. * Gets the gradient input component
  68374. */
  68375. get gradient(): NodeMaterialConnectionPoint;
  68376. /**
  68377. * Gets the output component
  68378. */
  68379. get output(): NodeMaterialConnectionPoint;
  68380. private _writeColorConstant;
  68381. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68382. serialize(): any;
  68383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68384. protected _dumpPropertiesCode(): string;
  68385. }
  68386. }
  68387. declare module BABYLON {
  68388. /**
  68389. * Block used to normalize lerp between 2 values
  68390. */
  68391. export class NLerpBlock extends NodeMaterialBlock {
  68392. /**
  68393. * Creates a new NLerpBlock
  68394. * @param name defines the block name
  68395. */
  68396. constructor(name: string);
  68397. /**
  68398. * Gets the current class name
  68399. * @returns the class name
  68400. */
  68401. getClassName(): string;
  68402. /**
  68403. * Gets the left operand input component
  68404. */
  68405. get left(): NodeMaterialConnectionPoint;
  68406. /**
  68407. * Gets the right operand input component
  68408. */
  68409. get right(): NodeMaterialConnectionPoint;
  68410. /**
  68411. * Gets the gradient operand input component
  68412. */
  68413. get gradient(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Gets the output component
  68416. */
  68417. get output(): NodeMaterialConnectionPoint;
  68418. protected _buildBlock(state: NodeMaterialBuildState): this;
  68419. }
  68420. }
  68421. declare module BABYLON {
  68422. /**
  68423. * block used to Generate a Worley Noise 3D Noise Pattern
  68424. */
  68425. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68426. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68427. manhattanDistance: boolean;
  68428. /**
  68429. * Creates a new WorleyNoise3DBlock
  68430. * @param name defines the block name
  68431. */
  68432. constructor(name: string);
  68433. /**
  68434. * Gets the current class name
  68435. * @returns the class name
  68436. */
  68437. getClassName(): string;
  68438. /**
  68439. * Gets the seed input component
  68440. */
  68441. get seed(): NodeMaterialConnectionPoint;
  68442. /**
  68443. * Gets the jitter input component
  68444. */
  68445. get jitter(): NodeMaterialConnectionPoint;
  68446. /**
  68447. * Gets the output component
  68448. */
  68449. get output(): NodeMaterialConnectionPoint;
  68450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68451. /**
  68452. * Exposes the properties to the UI?
  68453. */
  68454. protected _dumpPropertiesCode(): string;
  68455. /**
  68456. * Exposes the properties to the Seralize?
  68457. */
  68458. serialize(): any;
  68459. /**
  68460. * Exposes the properties to the deseralize?
  68461. */
  68462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68463. }
  68464. }
  68465. declare module BABYLON {
  68466. /**
  68467. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68468. */
  68469. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68470. /**
  68471. * Creates a new SimplexPerlin3DBlock
  68472. * @param name defines the block name
  68473. */
  68474. constructor(name: string);
  68475. /**
  68476. * Gets the current class name
  68477. * @returns the class name
  68478. */
  68479. getClassName(): string;
  68480. /**
  68481. * Gets the seed operand input component
  68482. */
  68483. get seed(): NodeMaterialConnectionPoint;
  68484. /**
  68485. * Gets the output component
  68486. */
  68487. get output(): NodeMaterialConnectionPoint;
  68488. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68489. }
  68490. }
  68491. declare module BABYLON {
  68492. /**
  68493. * Block used to blend normals
  68494. */
  68495. export class NormalBlendBlock extends NodeMaterialBlock {
  68496. /**
  68497. * Creates a new NormalBlendBlock
  68498. * @param name defines the block name
  68499. */
  68500. constructor(name: string);
  68501. /**
  68502. * Gets the current class name
  68503. * @returns the class name
  68504. */
  68505. getClassName(): string;
  68506. /**
  68507. * Gets the first input component
  68508. */
  68509. get normalMap0(): NodeMaterialConnectionPoint;
  68510. /**
  68511. * Gets the second input component
  68512. */
  68513. get normalMap1(): 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 rotate a 2d vector by a given angle
  68524. */
  68525. export class Rotate2dBlock extends NodeMaterialBlock {
  68526. /**
  68527. * Creates a new Rotate2dBlock
  68528. * @param name defines the block name
  68529. */
  68530. constructor(name: string);
  68531. /**
  68532. * Gets the current class name
  68533. * @returns the class name
  68534. */
  68535. getClassName(): string;
  68536. /**
  68537. * Gets the input vector
  68538. */
  68539. get input(): NodeMaterialConnectionPoint;
  68540. /**
  68541. * Gets the input angle
  68542. */
  68543. get angle(): NodeMaterialConnectionPoint;
  68544. /**
  68545. * Gets the output component
  68546. */
  68547. get output(): NodeMaterialConnectionPoint;
  68548. autoConfigure(material: NodeMaterial): void;
  68549. protected _buildBlock(state: NodeMaterialBuildState): this;
  68550. }
  68551. }
  68552. declare module BABYLON {
  68553. /**
  68554. * Block used to get the reflected vector from a direction and a normal
  68555. */
  68556. export class ReflectBlock extends NodeMaterialBlock {
  68557. /**
  68558. * Creates a new ReflectBlock
  68559. * @param name defines the block name
  68560. */
  68561. constructor(name: string);
  68562. /**
  68563. * Gets the current class name
  68564. * @returns the class name
  68565. */
  68566. getClassName(): string;
  68567. /**
  68568. * Gets the incident component
  68569. */
  68570. get incident(): NodeMaterialConnectionPoint;
  68571. /**
  68572. * Gets the normal component
  68573. */
  68574. get normal(): NodeMaterialConnectionPoint;
  68575. /**
  68576. * Gets the output component
  68577. */
  68578. get output(): NodeMaterialConnectionPoint;
  68579. protected _buildBlock(state: NodeMaterialBuildState): this;
  68580. }
  68581. }
  68582. declare module BABYLON {
  68583. /**
  68584. * Block used to get the refracted vector from a direction and a normal
  68585. */
  68586. export class RefractBlock extends NodeMaterialBlock {
  68587. /**
  68588. * Creates a new RefractBlock
  68589. * @param name defines the block name
  68590. */
  68591. constructor(name: string);
  68592. /**
  68593. * Gets the current class name
  68594. * @returns the class name
  68595. */
  68596. getClassName(): string;
  68597. /**
  68598. * Gets the incident component
  68599. */
  68600. get incident(): NodeMaterialConnectionPoint;
  68601. /**
  68602. * Gets the normal component
  68603. */
  68604. get normal(): NodeMaterialConnectionPoint;
  68605. /**
  68606. * Gets the index of refraction component
  68607. */
  68608. get ior(): NodeMaterialConnectionPoint;
  68609. /**
  68610. * Gets the output component
  68611. */
  68612. get output(): NodeMaterialConnectionPoint;
  68613. protected _buildBlock(state: NodeMaterialBuildState): this;
  68614. }
  68615. }
  68616. declare module BABYLON {
  68617. /**
  68618. * Block used to desaturate a color
  68619. */
  68620. export class DesaturateBlock extends NodeMaterialBlock {
  68621. /**
  68622. * Creates a new DesaturateBlock
  68623. * @param name defines the block name
  68624. */
  68625. constructor(name: string);
  68626. /**
  68627. * Gets the current class name
  68628. * @returns the class name
  68629. */
  68630. getClassName(): string;
  68631. /**
  68632. * Gets the color operand input component
  68633. */
  68634. get color(): NodeMaterialConnectionPoint;
  68635. /**
  68636. * Gets the level operand input component
  68637. */
  68638. get level(): NodeMaterialConnectionPoint;
  68639. /**
  68640. * Gets the output component
  68641. */
  68642. get output(): NodeMaterialConnectionPoint;
  68643. protected _buildBlock(state: NodeMaterialBuildState): this;
  68644. }
  68645. }
  68646. declare module BABYLON {
  68647. /**
  68648. * Block used to implement the reflection module of the PBR material
  68649. */
  68650. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68651. /** @hidden */
  68652. _defineLODReflectionAlpha: string;
  68653. /** @hidden */
  68654. _defineLinearSpecularReflection: string;
  68655. private _vEnvironmentIrradianceName;
  68656. /** @hidden */
  68657. _vReflectionMicrosurfaceInfosName: string;
  68658. /** @hidden */
  68659. _vReflectionInfosName: string;
  68660. /** @hidden */
  68661. _vReflectionFilteringInfoName: string;
  68662. private _scene;
  68663. /**
  68664. * The properties below are set by the main PBR block prior to calling methods of this class.
  68665. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68666. * It's less burden on the user side in the editor part.
  68667. */
  68668. /** @hidden */
  68669. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68670. /** @hidden */
  68671. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68672. /** @hidden */
  68673. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68674. /** @hidden */
  68675. viewConnectionPoint: NodeMaterialConnectionPoint;
  68676. /**
  68677. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68678. * diffuse part of the IBL.
  68679. */
  68680. useSphericalHarmonics: boolean;
  68681. /**
  68682. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68683. */
  68684. forceIrradianceInFragment: boolean;
  68685. /**
  68686. * Create a new ReflectionBlock
  68687. * @param name defines the block name
  68688. */
  68689. constructor(name: string);
  68690. /**
  68691. * Gets the current class name
  68692. * @returns the class name
  68693. */
  68694. getClassName(): string;
  68695. /**
  68696. * Gets the position input component
  68697. */
  68698. get position(): NodeMaterialConnectionPoint;
  68699. /**
  68700. * Gets the world position input component
  68701. */
  68702. get worldPosition(): NodeMaterialConnectionPoint;
  68703. /**
  68704. * Gets the world normal input component
  68705. */
  68706. get worldNormal(): NodeMaterialConnectionPoint;
  68707. /**
  68708. * Gets the world input component
  68709. */
  68710. get world(): NodeMaterialConnectionPoint;
  68711. /**
  68712. * Gets the camera (or eye) position component
  68713. */
  68714. get cameraPosition(): NodeMaterialConnectionPoint;
  68715. /**
  68716. * Gets the view input component
  68717. */
  68718. get view(): NodeMaterialConnectionPoint;
  68719. /**
  68720. * Gets the color input component
  68721. */
  68722. get color(): NodeMaterialConnectionPoint;
  68723. /**
  68724. * Gets the reflection object output component
  68725. */
  68726. get reflection(): NodeMaterialConnectionPoint;
  68727. /**
  68728. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68729. */
  68730. get hasTexture(): boolean;
  68731. /**
  68732. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68733. */
  68734. get reflectionColor(): string;
  68735. protected _getTexture(): Nullable<BaseTexture>;
  68736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68738. /**
  68739. * Gets the code to inject in the vertex shader
  68740. * @param state current state of the node material building
  68741. * @returns the shader code
  68742. */
  68743. handleVertexSide(state: NodeMaterialBuildState): string;
  68744. /**
  68745. * Gets the main code of the block (fragment side)
  68746. * @param state current state of the node material building
  68747. * @param normalVarName name of the existing variable corresponding to the normal
  68748. * @returns the shader code
  68749. */
  68750. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68751. protected _buildBlock(state: NodeMaterialBuildState): this;
  68752. protected _dumpPropertiesCode(): string;
  68753. serialize(): any;
  68754. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68755. }
  68756. }
  68757. declare module BABYLON {
  68758. /**
  68759. * Block used to implement the sheen module of the PBR material
  68760. */
  68761. export class SheenBlock extends NodeMaterialBlock {
  68762. /**
  68763. * Create a new SheenBlock
  68764. * @param name defines the block name
  68765. */
  68766. constructor(name: string);
  68767. /**
  68768. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68769. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68770. * making it easier to setup and tweak the effect
  68771. */
  68772. albedoScaling: boolean;
  68773. /**
  68774. * Defines if the sheen is linked to the sheen color.
  68775. */
  68776. linkSheenWithAlbedo: boolean;
  68777. /**
  68778. * Initialize the block and prepare the context for build
  68779. * @param state defines the state that will be used for the build
  68780. */
  68781. initialize(state: NodeMaterialBuildState): void;
  68782. /**
  68783. * Gets the current class name
  68784. * @returns the class name
  68785. */
  68786. getClassName(): string;
  68787. /**
  68788. * Gets the intensity input component
  68789. */
  68790. get intensity(): NodeMaterialConnectionPoint;
  68791. /**
  68792. * Gets the color input component
  68793. */
  68794. get color(): NodeMaterialConnectionPoint;
  68795. /**
  68796. * Gets the roughness input component
  68797. */
  68798. get roughness(): NodeMaterialConnectionPoint;
  68799. /**
  68800. * Gets the sheen object output component
  68801. */
  68802. get sheen(): NodeMaterialConnectionPoint;
  68803. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68804. /**
  68805. * Gets the main code of the block (fragment side)
  68806. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68807. * @returns the shader code
  68808. */
  68809. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68810. protected _buildBlock(state: NodeMaterialBuildState): this;
  68811. protected _dumpPropertiesCode(): string;
  68812. serialize(): any;
  68813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68814. }
  68815. }
  68816. declare module BABYLON {
  68817. /**
  68818. * Block used to implement the anisotropy module of the PBR material
  68819. */
  68820. export class AnisotropyBlock extends NodeMaterialBlock {
  68821. /**
  68822. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68823. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68824. * It's less burden on the user side in the editor part.
  68825. */
  68826. /** @hidden */
  68827. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68828. /** @hidden */
  68829. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68830. /**
  68831. * Create a new AnisotropyBlock
  68832. * @param name defines the block name
  68833. */
  68834. constructor(name: string);
  68835. /**
  68836. * Initialize the block and prepare the context for build
  68837. * @param state defines the state that will be used for the build
  68838. */
  68839. initialize(state: NodeMaterialBuildState): void;
  68840. /**
  68841. * Gets the current class name
  68842. * @returns the class name
  68843. */
  68844. getClassName(): string;
  68845. /**
  68846. * Gets the intensity input component
  68847. */
  68848. get intensity(): NodeMaterialConnectionPoint;
  68849. /**
  68850. * Gets the direction input component
  68851. */
  68852. get direction(): NodeMaterialConnectionPoint;
  68853. /**
  68854. * Gets the uv input component
  68855. */
  68856. get uv(): NodeMaterialConnectionPoint;
  68857. /**
  68858. * Gets the worldTangent input component
  68859. */
  68860. get worldTangent(): NodeMaterialConnectionPoint;
  68861. /**
  68862. * Gets the anisotropy object output component
  68863. */
  68864. get anisotropy(): NodeMaterialConnectionPoint;
  68865. private _generateTBNSpace;
  68866. /**
  68867. * Gets the main code of the block (fragment side)
  68868. * @param state current state of the node material building
  68869. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68870. * @returns the shader code
  68871. */
  68872. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68874. protected _buildBlock(state: NodeMaterialBuildState): this;
  68875. }
  68876. }
  68877. declare module BABYLON {
  68878. /**
  68879. * Block used to implement the clear coat module of the PBR material
  68880. */
  68881. export class ClearCoatBlock extends NodeMaterialBlock {
  68882. private _scene;
  68883. /**
  68884. * Create a new ClearCoatBlock
  68885. * @param name defines the block name
  68886. */
  68887. constructor(name: string);
  68888. /**
  68889. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68890. */
  68891. remapF0OnInterfaceChange: boolean;
  68892. /**
  68893. * Initialize the block and prepare the context for build
  68894. * @param state defines the state that will be used for the build
  68895. */
  68896. initialize(state: NodeMaterialBuildState): void;
  68897. /**
  68898. * Gets the current class name
  68899. * @returns the class name
  68900. */
  68901. getClassName(): string;
  68902. /**
  68903. * Gets the intensity input component
  68904. */
  68905. get intensity(): NodeMaterialConnectionPoint;
  68906. /**
  68907. * Gets the roughness input component
  68908. */
  68909. get roughness(): NodeMaterialConnectionPoint;
  68910. /**
  68911. * Gets the ior input component
  68912. */
  68913. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68914. /**
  68915. * Gets the bump texture input component
  68916. */
  68917. get normalMapColor(): NodeMaterialConnectionPoint;
  68918. /**
  68919. * Gets the uv input component
  68920. */
  68921. get uv(): NodeMaterialConnectionPoint;
  68922. /**
  68923. * Gets the tint color input component
  68924. */
  68925. get tintColor(): NodeMaterialConnectionPoint;
  68926. /**
  68927. * Gets the tint "at distance" input component
  68928. */
  68929. get tintAtDistance(): NodeMaterialConnectionPoint;
  68930. /**
  68931. * Gets the tint thickness input component
  68932. */
  68933. get tintThickness(): NodeMaterialConnectionPoint;
  68934. /**
  68935. * Gets the world tangent input component
  68936. */
  68937. get worldTangent(): NodeMaterialConnectionPoint;
  68938. /**
  68939. * Gets the clear coat object output component
  68940. */
  68941. get clearcoat(): NodeMaterialConnectionPoint;
  68942. autoConfigure(material: NodeMaterial): void;
  68943. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68944. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68945. private _generateTBNSpace;
  68946. /**
  68947. * Gets the main code of the block (fragment side)
  68948. * @param state current state of the node material building
  68949. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68950. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68951. * @param worldPosVarName name of the variable holding the world position
  68952. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68953. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68954. * @param worldNormalVarName name of the variable holding the world normal
  68955. * @returns the shader code
  68956. */
  68957. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68958. protected _buildBlock(state: NodeMaterialBuildState): this;
  68959. protected _dumpPropertiesCode(): string;
  68960. serialize(): any;
  68961. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68962. }
  68963. }
  68964. declare module BABYLON {
  68965. /**
  68966. * Block used to implement the sub surface module of the PBR material
  68967. */
  68968. export class SubSurfaceBlock extends NodeMaterialBlock {
  68969. /**
  68970. * Create a new SubSurfaceBlock
  68971. * @param name defines the block name
  68972. */
  68973. constructor(name: string);
  68974. /**
  68975. * Initialize the block and prepare the context for build
  68976. * @param state defines the state that will be used for the build
  68977. */
  68978. initialize(state: NodeMaterialBuildState): void;
  68979. /**
  68980. * Gets the current class name
  68981. * @returns the class name
  68982. */
  68983. getClassName(): string;
  68984. /**
  68985. * Gets the thickness component
  68986. */
  68987. get thickness(): NodeMaterialConnectionPoint;
  68988. /**
  68989. * Gets the tint color input component
  68990. */
  68991. get tintColor(): NodeMaterialConnectionPoint;
  68992. /**
  68993. * Gets the translucency intensity input component
  68994. */
  68995. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68996. /**
  68997. * Gets the translucency diffusion distance input component
  68998. */
  68999. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69000. /**
  69001. * Gets the refraction object parameters
  69002. */
  69003. get refraction(): NodeMaterialConnectionPoint;
  69004. /**
  69005. * Gets the sub surface object output component
  69006. */
  69007. get subsurface(): NodeMaterialConnectionPoint;
  69008. autoConfigure(material: NodeMaterial): void;
  69009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69010. /**
  69011. * Gets the main code of the block (fragment side)
  69012. * @param state current state of the node material building
  69013. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69014. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69015. * @param worldPosVarName name of the variable holding the world position
  69016. * @returns the shader code
  69017. */
  69018. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69019. protected _buildBlock(state: NodeMaterialBuildState): this;
  69020. }
  69021. }
  69022. declare module BABYLON {
  69023. /**
  69024. * Block used to implement the PBR metallic/roughness model
  69025. */
  69026. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69027. /**
  69028. * Gets or sets the light associated with this block
  69029. */
  69030. light: Nullable<Light>;
  69031. private _lightId;
  69032. private _scene;
  69033. private _environmentBRDFTexture;
  69034. private _environmentBrdfSamplerName;
  69035. private _vNormalWName;
  69036. private _invertNormalName;
  69037. private _metallicReflectanceColor;
  69038. private _metallicF0Factor;
  69039. private _vMetallicReflectanceFactorsName;
  69040. /**
  69041. * Create a new ReflectionBlock
  69042. * @param name defines the block name
  69043. */
  69044. constructor(name: string);
  69045. /**
  69046. * Intensity of the direct lights e.g. the four lights available in your scene.
  69047. * This impacts both the direct diffuse and specular highlights.
  69048. */
  69049. directIntensity: number;
  69050. /**
  69051. * Intensity of the environment e.g. how much the environment will light the object
  69052. * either through harmonics for rough material or through the refelction for shiny ones.
  69053. */
  69054. environmentIntensity: number;
  69055. /**
  69056. * This is a special control allowing the reduction of the specular highlights coming from the
  69057. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69058. */
  69059. specularIntensity: number;
  69060. /**
  69061. * Defines the falloff type used in this material.
  69062. * It by default is Physical.
  69063. */
  69064. lightFalloff: number;
  69065. /**
  69066. * Specifies that alpha test should be used
  69067. */
  69068. useAlphaTest: boolean;
  69069. /**
  69070. * Defines the alpha limits in alpha test mode.
  69071. */
  69072. alphaTestCutoff: number;
  69073. /**
  69074. * Specifies that alpha blending should be used
  69075. */
  69076. useAlphaBlending: boolean;
  69077. /**
  69078. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69079. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69080. */
  69081. useRadianceOverAlpha: boolean;
  69082. /**
  69083. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69084. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69085. */
  69086. useSpecularOverAlpha: boolean;
  69087. /**
  69088. * Enables specular anti aliasing in the PBR shader.
  69089. * It will both interacts on the Geometry for analytical and IBL lighting.
  69090. * It also prefilter the roughness map based on the bump values.
  69091. */
  69092. enableSpecularAntiAliasing: boolean;
  69093. /**
  69094. * Enables realtime filtering on the texture.
  69095. */
  69096. realTimeFiltering: boolean;
  69097. /**
  69098. * Quality switch for realtime filtering
  69099. */
  69100. realTimeFilteringQuality: number;
  69101. /**
  69102. * Defines if the material uses energy conservation.
  69103. */
  69104. useEnergyConservation: boolean;
  69105. /**
  69106. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69107. * too much the area relying on ambient texture to define their ambient occlusion.
  69108. */
  69109. useRadianceOcclusion: boolean;
  69110. /**
  69111. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69112. * makes the reflect vector face the model (under horizon).
  69113. */
  69114. useHorizonOcclusion: boolean;
  69115. /**
  69116. * If set to true, no lighting calculations will be applied.
  69117. */
  69118. unlit: boolean;
  69119. /**
  69120. * Force normal to face away from face.
  69121. */
  69122. forceNormalForward: boolean;
  69123. /**
  69124. * Defines the material debug mode.
  69125. * It helps seeing only some components of the material while troubleshooting.
  69126. */
  69127. debugMode: number;
  69128. /**
  69129. * Specify from where on screen the debug mode should start.
  69130. * The value goes from -1 (full screen) to 1 (not visible)
  69131. * It helps with side by side comparison against the final render
  69132. * This defaults to 0
  69133. */
  69134. debugLimit: number;
  69135. /**
  69136. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69137. * You can use the factor to better multiply the final value.
  69138. */
  69139. debugFactor: number;
  69140. /**
  69141. * Initialize the block and prepare the context for build
  69142. * @param state defines the state that will be used for the build
  69143. */
  69144. initialize(state: NodeMaterialBuildState): void;
  69145. /**
  69146. * Gets the current class name
  69147. * @returns the class name
  69148. */
  69149. getClassName(): string;
  69150. /**
  69151. * Gets the world position input component
  69152. */
  69153. get worldPosition(): NodeMaterialConnectionPoint;
  69154. /**
  69155. * Gets the world normal input component
  69156. */
  69157. get worldNormal(): NodeMaterialConnectionPoint;
  69158. /**
  69159. * Gets the view matrix parameter
  69160. */
  69161. get view(): NodeMaterialConnectionPoint;
  69162. /**
  69163. * Gets the camera position input component
  69164. */
  69165. get cameraPosition(): NodeMaterialConnectionPoint;
  69166. /**
  69167. * Gets the perturbed normal input component
  69168. */
  69169. get perturbedNormal(): NodeMaterialConnectionPoint;
  69170. /**
  69171. * Gets the base color input component
  69172. */
  69173. get baseColor(): NodeMaterialConnectionPoint;
  69174. /**
  69175. * Gets the metallic input component
  69176. */
  69177. get metallic(): NodeMaterialConnectionPoint;
  69178. /**
  69179. * Gets the roughness input component
  69180. */
  69181. get roughness(): NodeMaterialConnectionPoint;
  69182. /**
  69183. * Gets the ambient occlusion input component
  69184. */
  69185. get ambientOcc(): NodeMaterialConnectionPoint;
  69186. /**
  69187. * Gets the opacity input component
  69188. */
  69189. get opacity(): NodeMaterialConnectionPoint;
  69190. /**
  69191. * Gets the index of refraction input component
  69192. */
  69193. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69194. /**
  69195. * Gets the ambient color input component
  69196. */
  69197. get ambientColor(): NodeMaterialConnectionPoint;
  69198. /**
  69199. * Gets the reflection object parameters
  69200. */
  69201. get reflection(): NodeMaterialConnectionPoint;
  69202. /**
  69203. * Gets the clear coat object parameters
  69204. */
  69205. get clearcoat(): NodeMaterialConnectionPoint;
  69206. /**
  69207. * Gets the sheen object parameters
  69208. */
  69209. get sheen(): NodeMaterialConnectionPoint;
  69210. /**
  69211. * Gets the sub surface object parameters
  69212. */
  69213. get subsurface(): NodeMaterialConnectionPoint;
  69214. /**
  69215. * Gets the anisotropy object parameters
  69216. */
  69217. get anisotropy(): NodeMaterialConnectionPoint;
  69218. /**
  69219. * Gets the ambient output component
  69220. */
  69221. get ambientClr(): NodeMaterialConnectionPoint;
  69222. /**
  69223. * Gets the diffuse output component
  69224. */
  69225. get diffuseDir(): NodeMaterialConnectionPoint;
  69226. /**
  69227. * Gets the specular output component
  69228. */
  69229. get specularDir(): NodeMaterialConnectionPoint;
  69230. /**
  69231. * Gets the clear coat output component
  69232. */
  69233. get clearcoatDir(): NodeMaterialConnectionPoint;
  69234. /**
  69235. * Gets the sheen output component
  69236. */
  69237. get sheenDir(): NodeMaterialConnectionPoint;
  69238. /**
  69239. * Gets the indirect diffuse output component
  69240. */
  69241. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69242. /**
  69243. * Gets the indirect specular output component
  69244. */
  69245. get specularIndirect(): NodeMaterialConnectionPoint;
  69246. /**
  69247. * Gets the indirect clear coat output component
  69248. */
  69249. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69250. /**
  69251. * Gets the indirect sheen output component
  69252. */
  69253. get sheenIndirect(): NodeMaterialConnectionPoint;
  69254. /**
  69255. * Gets the refraction output component
  69256. */
  69257. get refraction(): NodeMaterialConnectionPoint;
  69258. /**
  69259. * Gets the global lighting output component
  69260. */
  69261. get lighting(): NodeMaterialConnectionPoint;
  69262. /**
  69263. * Gets the shadow output component
  69264. */
  69265. get shadow(): NodeMaterialConnectionPoint;
  69266. /**
  69267. * Gets the alpha output component
  69268. */
  69269. get alpha(): NodeMaterialConnectionPoint;
  69270. autoConfigure(material: NodeMaterial): void;
  69271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69272. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69273. isReady(): boolean;
  69274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69275. private _injectVertexCode;
  69276. private _getAlbedoOpacityCode;
  69277. private _getAmbientOcclusionCode;
  69278. private _getReflectivityCode;
  69279. protected _buildBlock(state: NodeMaterialBuildState): this;
  69280. protected _dumpPropertiesCode(): string;
  69281. serialize(): any;
  69282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69283. }
  69284. }
  69285. declare module BABYLON {
  69286. /**
  69287. * Block used to compute value of one parameter modulo another
  69288. */
  69289. export class ModBlock extends NodeMaterialBlock {
  69290. /**
  69291. * Creates a new ModBlock
  69292. * @param name defines the block name
  69293. */
  69294. constructor(name: string);
  69295. /**
  69296. * Gets the current class name
  69297. * @returns the class name
  69298. */
  69299. getClassName(): string;
  69300. /**
  69301. * Gets the left operand input component
  69302. */
  69303. get left(): NodeMaterialConnectionPoint;
  69304. /**
  69305. * Gets the right operand input component
  69306. */
  69307. get right(): NodeMaterialConnectionPoint;
  69308. /**
  69309. * Gets the output component
  69310. */
  69311. get output(): NodeMaterialConnectionPoint;
  69312. protected _buildBlock(state: NodeMaterialBuildState): this;
  69313. }
  69314. }
  69315. declare module BABYLON {
  69316. /**
  69317. * Configuration for Draco compression
  69318. */
  69319. export interface IDracoCompressionConfiguration {
  69320. /**
  69321. * Configuration for the decoder.
  69322. */
  69323. decoder: {
  69324. /**
  69325. * The url to the WebAssembly module.
  69326. */
  69327. wasmUrl?: string;
  69328. /**
  69329. * The url to the WebAssembly binary.
  69330. */
  69331. wasmBinaryUrl?: string;
  69332. /**
  69333. * The url to the fallback JavaScript module.
  69334. */
  69335. fallbackUrl?: string;
  69336. };
  69337. }
  69338. /**
  69339. * Draco compression (https://google.github.io/draco/)
  69340. *
  69341. * This class wraps the Draco module.
  69342. *
  69343. * **Encoder**
  69344. *
  69345. * The encoder is not currently implemented.
  69346. *
  69347. * **Decoder**
  69348. *
  69349. * 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.
  69350. *
  69351. * To update the configuration, use the following code:
  69352. * ```javascript
  69353. * DracoCompression.Configuration = {
  69354. * decoder: {
  69355. * wasmUrl: "<url to the WebAssembly library>",
  69356. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69357. * fallbackUrl: "<url to the fallback JavaScript library>",
  69358. * }
  69359. * };
  69360. * ```
  69361. *
  69362. * 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.
  69363. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69364. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69365. *
  69366. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69367. * ```javascript
  69368. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69369. * ```
  69370. *
  69371. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69372. */
  69373. export class DracoCompression implements IDisposable {
  69374. private _workerPoolPromise?;
  69375. private _decoderModulePromise?;
  69376. /**
  69377. * The configuration. Defaults to the following urls:
  69378. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69379. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69380. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69381. */
  69382. static Configuration: IDracoCompressionConfiguration;
  69383. /**
  69384. * Returns true if the decoder configuration is available.
  69385. */
  69386. static get DecoderAvailable(): boolean;
  69387. /**
  69388. * Default number of workers to create when creating the draco compression object.
  69389. */
  69390. static DefaultNumWorkers: number;
  69391. private static GetDefaultNumWorkers;
  69392. private static _Default;
  69393. /**
  69394. * Default instance for the draco compression object.
  69395. */
  69396. static get Default(): DracoCompression;
  69397. /**
  69398. * Constructor
  69399. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69400. */
  69401. constructor(numWorkers?: number);
  69402. /**
  69403. * Stop all async operations and release resources.
  69404. */
  69405. dispose(): void;
  69406. /**
  69407. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69408. * @returns a promise that resolves when ready
  69409. */
  69410. whenReadyAsync(): Promise<void>;
  69411. /**
  69412. * Decode Draco compressed mesh data to vertex data.
  69413. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69414. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69415. * @returns A promise that resolves with the decoded vertex data
  69416. */
  69417. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69418. [kind: string]: number;
  69419. }): Promise<VertexData>;
  69420. }
  69421. }
  69422. declare module BABYLON {
  69423. /**
  69424. * Class for building Constructive Solid Geometry
  69425. */
  69426. export class CSG {
  69427. private polygons;
  69428. /**
  69429. * The world matrix
  69430. */
  69431. matrix: Matrix;
  69432. /**
  69433. * Stores the position
  69434. */
  69435. position: Vector3;
  69436. /**
  69437. * Stores the rotation
  69438. */
  69439. rotation: Vector3;
  69440. /**
  69441. * Stores the rotation quaternion
  69442. */
  69443. rotationQuaternion: Nullable<Quaternion>;
  69444. /**
  69445. * Stores the scaling vector
  69446. */
  69447. scaling: Vector3;
  69448. /**
  69449. * Convert the Mesh to CSG
  69450. * @param mesh The Mesh to convert to CSG
  69451. * @returns A new CSG from the Mesh
  69452. */
  69453. static FromMesh(mesh: Mesh): CSG;
  69454. /**
  69455. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69456. * @param polygons Polygons used to construct a CSG solid
  69457. */
  69458. private static FromPolygons;
  69459. /**
  69460. * Clones, or makes a deep copy, of the CSG
  69461. * @returns A new CSG
  69462. */
  69463. clone(): CSG;
  69464. /**
  69465. * Unions this CSG with another CSG
  69466. * @param csg The CSG to union against this CSG
  69467. * @returns The unioned CSG
  69468. */
  69469. union(csg: CSG): CSG;
  69470. /**
  69471. * Unions this CSG with another CSG in place
  69472. * @param csg The CSG to union against this CSG
  69473. */
  69474. unionInPlace(csg: CSG): void;
  69475. /**
  69476. * Subtracts this CSG with another CSG
  69477. * @param csg The CSG to subtract against this CSG
  69478. * @returns A new CSG
  69479. */
  69480. subtract(csg: CSG): CSG;
  69481. /**
  69482. * Subtracts this CSG with another CSG in place
  69483. * @param csg The CSG to subtact against this CSG
  69484. */
  69485. subtractInPlace(csg: CSG): void;
  69486. /**
  69487. * Intersect this CSG with another CSG
  69488. * @param csg The CSG to intersect against this CSG
  69489. * @returns A new CSG
  69490. */
  69491. intersect(csg: CSG): CSG;
  69492. /**
  69493. * Intersects this CSG with another CSG in place
  69494. * @param csg The CSG to intersect against this CSG
  69495. */
  69496. intersectInPlace(csg: CSG): void;
  69497. /**
  69498. * Return a new CSG solid with solid and empty space switched. This solid is
  69499. * not modified.
  69500. * @returns A new CSG solid with solid and empty space switched
  69501. */
  69502. inverse(): CSG;
  69503. /**
  69504. * Inverses the CSG in place
  69505. */
  69506. inverseInPlace(): void;
  69507. /**
  69508. * This is used to keep meshes transformations so they can be restored
  69509. * when we build back a Babylon Mesh
  69510. * NB : All CSG operations are performed in world coordinates
  69511. * @param csg The CSG to copy the transform attributes from
  69512. * @returns This CSG
  69513. */
  69514. copyTransformAttributes(csg: CSG): CSG;
  69515. /**
  69516. * Build Raw mesh from CSG
  69517. * Coordinates here are in world space
  69518. * @param name The name of the mesh geometry
  69519. * @param scene The Scene
  69520. * @param keepSubMeshes Specifies if the submeshes should be kept
  69521. * @returns A new Mesh
  69522. */
  69523. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69524. /**
  69525. * Build Mesh from CSG taking material and transforms into account
  69526. * @param name The name of the Mesh
  69527. * @param material The material of the Mesh
  69528. * @param scene The Scene
  69529. * @param keepSubMeshes Specifies if submeshes should be kept
  69530. * @returns The new Mesh
  69531. */
  69532. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69533. }
  69534. }
  69535. declare module BABYLON {
  69536. /**
  69537. * Class used to create a trail following a mesh
  69538. */
  69539. export class TrailMesh extends Mesh {
  69540. private _generator;
  69541. private _autoStart;
  69542. private _running;
  69543. private _diameter;
  69544. private _length;
  69545. private _sectionPolygonPointsCount;
  69546. private _sectionVectors;
  69547. private _sectionNormalVectors;
  69548. private _beforeRenderObserver;
  69549. /**
  69550. * @constructor
  69551. * @param name The value used by scene.getMeshByName() to do a lookup.
  69552. * @param generator The mesh or transform node to generate a trail.
  69553. * @param scene The scene to add this mesh to.
  69554. * @param diameter Diameter of trailing mesh. Default is 1.
  69555. * @param length Length of trailing mesh. Default is 60.
  69556. * @param autoStart Automatically start trailing mesh. Default true.
  69557. */
  69558. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69559. /**
  69560. * "TrailMesh"
  69561. * @returns "TrailMesh"
  69562. */
  69563. getClassName(): string;
  69564. private _createMesh;
  69565. /**
  69566. * Start trailing mesh.
  69567. */
  69568. start(): void;
  69569. /**
  69570. * Stop trailing mesh.
  69571. */
  69572. stop(): void;
  69573. /**
  69574. * Update trailing mesh geometry.
  69575. */
  69576. update(): void;
  69577. /**
  69578. * Returns a new TrailMesh object.
  69579. * @param name is a string, the name given to the new mesh
  69580. * @param newGenerator use new generator object for cloned trail mesh
  69581. * @returns a new mesh
  69582. */
  69583. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69584. /**
  69585. * Serializes this trail mesh
  69586. * @param serializationObject object to write serialization to
  69587. */
  69588. serialize(serializationObject: any): void;
  69589. /**
  69590. * Parses a serialized trail mesh
  69591. * @param parsedMesh the serialized mesh
  69592. * @param scene the scene to create the trail mesh in
  69593. * @returns the created trail mesh
  69594. */
  69595. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69596. }
  69597. }
  69598. declare module BABYLON {
  69599. /**
  69600. * Class containing static functions to help procedurally build meshes
  69601. */
  69602. export class TiledBoxBuilder {
  69603. /**
  69604. * Creates a box mesh
  69605. * 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)
  69606. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69608. * * 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
  69609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69610. * @param name defines the name of the mesh
  69611. * @param options defines the options used to create the mesh
  69612. * @param scene defines the hosting scene
  69613. * @returns the box mesh
  69614. */
  69615. static CreateTiledBox(name: string, options: {
  69616. pattern?: number;
  69617. width?: number;
  69618. height?: number;
  69619. depth?: number;
  69620. tileSize?: number;
  69621. tileWidth?: number;
  69622. tileHeight?: number;
  69623. alignHorizontal?: number;
  69624. alignVertical?: number;
  69625. faceUV?: Vector4[];
  69626. faceColors?: Color4[];
  69627. sideOrientation?: number;
  69628. updatable?: boolean;
  69629. }, scene?: Nullable<Scene>): Mesh;
  69630. }
  69631. }
  69632. declare module BABYLON {
  69633. /**
  69634. * Class containing static functions to help procedurally build meshes
  69635. */
  69636. export class TorusKnotBuilder {
  69637. /**
  69638. * Creates a torus knot mesh
  69639. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69640. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69641. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69642. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69644. * * 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
  69645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69646. * @param name defines the name of the mesh
  69647. * @param options defines the options used to create the mesh
  69648. * @param scene defines the hosting scene
  69649. * @returns the torus knot mesh
  69650. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69651. */
  69652. static CreateTorusKnot(name: string, options: {
  69653. radius?: number;
  69654. tube?: number;
  69655. radialSegments?: number;
  69656. tubularSegments?: number;
  69657. p?: number;
  69658. q?: number;
  69659. updatable?: boolean;
  69660. sideOrientation?: number;
  69661. frontUVs?: Vector4;
  69662. backUVs?: Vector4;
  69663. }, scene: any): Mesh;
  69664. }
  69665. }
  69666. declare module BABYLON {
  69667. /**
  69668. * Polygon
  69669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69670. */
  69671. export class Polygon {
  69672. /**
  69673. * Creates a rectangle
  69674. * @param xmin bottom X coord
  69675. * @param ymin bottom Y coord
  69676. * @param xmax top X coord
  69677. * @param ymax top Y coord
  69678. * @returns points that make the resulting rectation
  69679. */
  69680. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69681. /**
  69682. * Creates a circle
  69683. * @param radius radius of circle
  69684. * @param cx scale in x
  69685. * @param cy scale in y
  69686. * @param numberOfSides number of sides that make up the circle
  69687. * @returns points that make the resulting circle
  69688. */
  69689. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69690. /**
  69691. * Creates a polygon from input string
  69692. * @param input Input polygon data
  69693. * @returns the parsed points
  69694. */
  69695. static Parse(input: string): Vector2[];
  69696. /**
  69697. * Starts building a polygon from x and y coordinates
  69698. * @param x x coordinate
  69699. * @param y y coordinate
  69700. * @returns the started path2
  69701. */
  69702. static StartingAt(x: number, y: number): Path2;
  69703. }
  69704. /**
  69705. * Builds a polygon
  69706. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69707. */
  69708. export class PolygonMeshBuilder {
  69709. private _points;
  69710. private _outlinepoints;
  69711. private _holes;
  69712. private _name;
  69713. private _scene;
  69714. private _epoints;
  69715. private _eholes;
  69716. private _addToepoint;
  69717. /**
  69718. * Babylon reference to the earcut plugin.
  69719. */
  69720. bjsEarcut: any;
  69721. /**
  69722. * Creates a PolygonMeshBuilder
  69723. * @param name name of the builder
  69724. * @param contours Path of the polygon
  69725. * @param scene scene to add to when creating the mesh
  69726. * @param earcutInjection can be used to inject your own earcut reference
  69727. */
  69728. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69729. /**
  69730. * Adds a hole within the polygon
  69731. * @param hole Array of points defining the hole
  69732. * @returns this
  69733. */
  69734. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69735. /**
  69736. * Creates the polygon
  69737. * @param updatable If the mesh should be updatable
  69738. * @param depth The depth of the mesh created
  69739. * @param smoothingThreshold Dot product threshold for smoothed normals
  69740. * @returns the created mesh
  69741. */
  69742. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  69743. /**
  69744. * Creates the polygon
  69745. * @param depth The depth of the mesh created
  69746. * @param smoothingThreshold Dot product threshold for smoothed normals
  69747. * @returns the created VertexData
  69748. */
  69749. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  69750. /**
  69751. * Adds a side to the polygon
  69752. * @param positions points that make the polygon
  69753. * @param normals normals of the polygon
  69754. * @param uvs uvs of the polygon
  69755. * @param indices indices of the polygon
  69756. * @param bounds bounds of the polygon
  69757. * @param points points of the polygon
  69758. * @param depth depth of the polygon
  69759. * @param flip flip of the polygon
  69760. */
  69761. private addSide;
  69762. }
  69763. }
  69764. declare module BABYLON {
  69765. /**
  69766. * Class containing static functions to help procedurally build meshes
  69767. */
  69768. export class PolygonBuilder {
  69769. /**
  69770. * Creates a polygon mesh
  69771. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69772. * * 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
  69773. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69775. * * 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)
  69776. * * Remember you can only change the shape positions, not their number when updating a polygon
  69777. * @param name defines the name of the mesh
  69778. * @param options defines the options used to create the mesh
  69779. * @param scene defines the hosting scene
  69780. * @param earcutInjection can be used to inject your own earcut reference
  69781. * @returns the polygon mesh
  69782. */
  69783. static CreatePolygon(name: string, options: {
  69784. shape: Vector3[];
  69785. holes?: Vector3[][];
  69786. depth?: number;
  69787. smoothingThreshold?: number;
  69788. faceUV?: Vector4[];
  69789. faceColors?: Color4[];
  69790. updatable?: boolean;
  69791. sideOrientation?: number;
  69792. frontUVs?: Vector4;
  69793. backUVs?: Vector4;
  69794. wrap?: boolean;
  69795. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69796. /**
  69797. * Creates an extruded polygon mesh, with depth in the Y direction.
  69798. * * 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)
  69799. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69800. * @param name defines the name of the mesh
  69801. * @param options defines the options used to create the mesh
  69802. * @param scene defines the hosting scene
  69803. * @param earcutInjection can be used to inject your own earcut reference
  69804. * @returns the polygon mesh
  69805. */
  69806. static ExtrudePolygon(name: string, options: {
  69807. shape: Vector3[];
  69808. holes?: Vector3[][];
  69809. depth?: number;
  69810. faceUV?: Vector4[];
  69811. faceColors?: Color4[];
  69812. updatable?: boolean;
  69813. sideOrientation?: number;
  69814. frontUVs?: Vector4;
  69815. backUVs?: Vector4;
  69816. wrap?: boolean;
  69817. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69818. }
  69819. }
  69820. declare module BABYLON {
  69821. /**
  69822. * Class containing static functions to help procedurally build meshes
  69823. */
  69824. export class LatheBuilder {
  69825. /**
  69826. * Creates lathe mesh.
  69827. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69828. * * 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
  69829. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69830. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69831. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69832. * * 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
  69833. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69834. * * 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
  69835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69836. * * 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
  69837. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69839. * @param name defines the name of the mesh
  69840. * @param options defines the options used to create the mesh
  69841. * @param scene defines the hosting scene
  69842. * @returns the lathe mesh
  69843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69844. */
  69845. static CreateLathe(name: string, options: {
  69846. shape: Vector3[];
  69847. radius?: number;
  69848. tessellation?: number;
  69849. clip?: number;
  69850. arc?: number;
  69851. closed?: boolean;
  69852. updatable?: boolean;
  69853. sideOrientation?: number;
  69854. frontUVs?: Vector4;
  69855. backUVs?: Vector4;
  69856. cap?: number;
  69857. invertUV?: boolean;
  69858. }, scene?: Nullable<Scene>): Mesh;
  69859. }
  69860. }
  69861. declare module BABYLON {
  69862. /**
  69863. * Class containing static functions to help procedurally build meshes
  69864. */
  69865. export class TiledPlaneBuilder {
  69866. /**
  69867. * Creates a tiled plane mesh
  69868. * * The parameter `pattern` will, depending on value, do nothing or
  69869. * * * flip (reflect about central vertical) alternate tiles across and up
  69870. * * * flip every tile on alternate rows
  69871. * * * rotate (180 degs) alternate tiles across and up
  69872. * * * rotate every tile on alternate rows
  69873. * * * flip and rotate alternate tiles across and up
  69874. * * * flip and rotate every tile on alternate rows
  69875. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69876. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69877. * * 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
  69878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69879. * * 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)
  69880. * * 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)
  69881. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69882. * @param name defines the name of the mesh
  69883. * @param options defines the options used to create the mesh
  69884. * @param scene defines the hosting scene
  69885. * @returns the box mesh
  69886. */
  69887. static CreateTiledPlane(name: string, options: {
  69888. pattern?: number;
  69889. tileSize?: number;
  69890. tileWidth?: number;
  69891. tileHeight?: number;
  69892. size?: number;
  69893. width?: number;
  69894. height?: number;
  69895. alignHorizontal?: number;
  69896. alignVertical?: number;
  69897. sideOrientation?: number;
  69898. frontUVs?: Vector4;
  69899. backUVs?: Vector4;
  69900. updatable?: boolean;
  69901. }, scene?: Nullable<Scene>): Mesh;
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. /**
  69906. * Class containing static functions to help procedurally build meshes
  69907. */
  69908. export class TubeBuilder {
  69909. /**
  69910. * Creates a tube mesh.
  69911. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69912. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69913. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69914. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69915. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69916. * * 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)
  69917. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69918. * * 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
  69919. * * 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
  69920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69921. * * 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
  69922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69924. * @param name defines the name of the mesh
  69925. * @param options defines the options used to create the mesh
  69926. * @param scene defines the hosting scene
  69927. * @returns the tube mesh
  69928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69929. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69930. */
  69931. static CreateTube(name: string, options: {
  69932. path: Vector3[];
  69933. radius?: number;
  69934. tessellation?: number;
  69935. radiusFunction?: {
  69936. (i: number, distance: number): number;
  69937. };
  69938. cap?: number;
  69939. arc?: number;
  69940. updatable?: boolean;
  69941. sideOrientation?: number;
  69942. frontUVs?: Vector4;
  69943. backUVs?: Vector4;
  69944. instance?: Mesh;
  69945. invertUV?: boolean;
  69946. }, scene?: Nullable<Scene>): Mesh;
  69947. }
  69948. }
  69949. declare module BABYLON {
  69950. /**
  69951. * Class containing static functions to help procedurally build meshes
  69952. */
  69953. export class IcoSphereBuilder {
  69954. /**
  69955. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69956. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69957. * * 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`)
  69958. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69959. * * 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
  69960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69961. * * 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
  69962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69963. * @param name defines the name of the mesh
  69964. * @param options defines the options used to create the mesh
  69965. * @param scene defines the hosting scene
  69966. * @returns the icosahedron mesh
  69967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69968. */
  69969. static CreateIcoSphere(name: string, options: {
  69970. radius?: number;
  69971. radiusX?: number;
  69972. radiusY?: number;
  69973. radiusZ?: number;
  69974. flat?: boolean;
  69975. subdivisions?: number;
  69976. sideOrientation?: number;
  69977. frontUVs?: Vector4;
  69978. backUVs?: Vector4;
  69979. updatable?: boolean;
  69980. }, scene?: Nullable<Scene>): Mesh;
  69981. }
  69982. }
  69983. declare module BABYLON {
  69984. /**
  69985. * Class containing static functions to help procedurally build meshes
  69986. */
  69987. export class DecalBuilder {
  69988. /**
  69989. * Creates a decal mesh.
  69990. * 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
  69991. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69992. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69993. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69994. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69995. * @param name defines the name of the mesh
  69996. * @param sourceMesh defines the mesh where the decal must be applied
  69997. * @param options defines the options used to create the mesh
  69998. * @param scene defines the hosting scene
  69999. * @returns the decal mesh
  70000. * @see https://doc.babylonjs.com/how_to/decals
  70001. */
  70002. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70003. position?: Vector3;
  70004. normal?: Vector3;
  70005. size?: Vector3;
  70006. angle?: number;
  70007. }): Mesh;
  70008. }
  70009. }
  70010. declare module BABYLON {
  70011. /**
  70012. * Class containing static functions to help procedurally build meshes
  70013. */
  70014. export class MeshBuilder {
  70015. /**
  70016. * Creates a box mesh
  70017. * * The parameter `size` sets the size (float) of each box side (default 1)
  70018. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70019. * * 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)
  70020. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70022. * * 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
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70025. * @param name defines the name of the mesh
  70026. * @param options defines the options used to create the mesh
  70027. * @param scene defines the hosting scene
  70028. * @returns the box mesh
  70029. */
  70030. static CreateBox(name: string, options: {
  70031. size?: number;
  70032. width?: number;
  70033. height?: number;
  70034. depth?: number;
  70035. faceUV?: Vector4[];
  70036. faceColors?: Color4[];
  70037. sideOrientation?: number;
  70038. frontUVs?: Vector4;
  70039. backUVs?: Vector4;
  70040. wrap?: boolean;
  70041. topBaseAt?: number;
  70042. bottomBaseAt?: number;
  70043. updatable?: boolean;
  70044. }, scene?: Nullable<Scene>): Mesh;
  70045. /**
  70046. * Creates a tiled box mesh
  70047. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70049. * @param name defines the name of the mesh
  70050. * @param options defines the options used to create the mesh
  70051. * @param scene defines the hosting scene
  70052. * @returns the tiled box mesh
  70053. */
  70054. static CreateTiledBox(name: string, options: {
  70055. pattern?: number;
  70056. size?: number;
  70057. width?: number;
  70058. height?: number;
  70059. depth: number;
  70060. tileSize?: number;
  70061. tileWidth?: number;
  70062. tileHeight?: number;
  70063. faceUV?: Vector4[];
  70064. faceColors?: Color4[];
  70065. alignHorizontal?: number;
  70066. alignVertical?: number;
  70067. sideOrientation?: number;
  70068. updatable?: boolean;
  70069. }, scene?: Nullable<Scene>): Mesh;
  70070. /**
  70071. * Creates a sphere mesh
  70072. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70073. * * 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`)
  70074. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70075. * * 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
  70076. * * 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)
  70077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70078. * * 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
  70079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70080. * @param name defines the name of the mesh
  70081. * @param options defines the options used to create the mesh
  70082. * @param scene defines the hosting scene
  70083. * @returns the sphere mesh
  70084. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70085. */
  70086. static CreateSphere(name: string, options: {
  70087. segments?: number;
  70088. diameter?: number;
  70089. diameterX?: number;
  70090. diameterY?: number;
  70091. diameterZ?: number;
  70092. arc?: number;
  70093. slice?: number;
  70094. sideOrientation?: number;
  70095. frontUVs?: Vector4;
  70096. backUVs?: Vector4;
  70097. updatable?: boolean;
  70098. }, scene?: Nullable<Scene>): Mesh;
  70099. /**
  70100. * Creates a plane polygonal mesh. By default, this is a disc
  70101. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70102. * * 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
  70103. * * 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
  70104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70105. * * 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
  70106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70107. * @param name defines the name of the mesh
  70108. * @param options defines the options used to create the mesh
  70109. * @param scene defines the hosting scene
  70110. * @returns the plane polygonal mesh
  70111. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70112. */
  70113. static CreateDisc(name: string, options: {
  70114. radius?: number;
  70115. tessellation?: number;
  70116. arc?: number;
  70117. updatable?: boolean;
  70118. sideOrientation?: number;
  70119. frontUVs?: Vector4;
  70120. backUVs?: Vector4;
  70121. }, scene?: Nullable<Scene>): Mesh;
  70122. /**
  70123. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70124. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70125. * * 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`)
  70126. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70127. * * 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
  70128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70129. * * 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
  70130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70131. * @param name defines the name of the mesh
  70132. * @param options defines the options used to create the mesh
  70133. * @param scene defines the hosting scene
  70134. * @returns the icosahedron mesh
  70135. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70136. */
  70137. static CreateIcoSphere(name: string, options: {
  70138. radius?: number;
  70139. radiusX?: number;
  70140. radiusY?: number;
  70141. radiusZ?: number;
  70142. flat?: boolean;
  70143. subdivisions?: number;
  70144. sideOrientation?: number;
  70145. frontUVs?: Vector4;
  70146. backUVs?: Vector4;
  70147. updatable?: boolean;
  70148. }, scene?: Nullable<Scene>): Mesh;
  70149. /**
  70150. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70151. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70152. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70153. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70154. * * 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
  70155. * * 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
  70156. * * 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
  70157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70158. * * 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
  70159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70160. * * 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
  70161. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70162. * * 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
  70163. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70165. * @param name defines the name of the mesh
  70166. * @param options defines the options used to create the mesh
  70167. * @param scene defines the hosting scene
  70168. * @returns the ribbon mesh
  70169. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70171. */
  70172. static CreateRibbon(name: string, options: {
  70173. pathArray: Vector3[][];
  70174. closeArray?: boolean;
  70175. closePath?: boolean;
  70176. offset?: number;
  70177. updatable?: boolean;
  70178. sideOrientation?: number;
  70179. frontUVs?: Vector4;
  70180. backUVs?: Vector4;
  70181. instance?: Mesh;
  70182. invertUV?: boolean;
  70183. uvs?: Vector2[];
  70184. colors?: Color4[];
  70185. }, scene?: Nullable<Scene>): Mesh;
  70186. /**
  70187. * Creates a cylinder or a cone mesh
  70188. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70189. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70190. * * 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.
  70191. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70192. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70193. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70194. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70195. * * 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).
  70196. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70197. * * 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).
  70198. * * 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
  70199. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70200. * * 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
  70201. * * 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.
  70202. * * If `enclose` is false, a ring surface is one element.
  70203. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70204. * * 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
  70205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70206. * * 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
  70207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70208. * @param name defines the name of the mesh
  70209. * @param options defines the options used to create the mesh
  70210. * @param scene defines the hosting scene
  70211. * @returns the cylinder mesh
  70212. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70213. */
  70214. static CreateCylinder(name: string, options: {
  70215. height?: number;
  70216. diameterTop?: number;
  70217. diameterBottom?: number;
  70218. diameter?: number;
  70219. tessellation?: number;
  70220. subdivisions?: number;
  70221. arc?: number;
  70222. faceColors?: Color4[];
  70223. faceUV?: Vector4[];
  70224. updatable?: boolean;
  70225. hasRings?: boolean;
  70226. enclose?: boolean;
  70227. cap?: number;
  70228. sideOrientation?: number;
  70229. frontUVs?: Vector4;
  70230. backUVs?: Vector4;
  70231. }, scene?: Nullable<Scene>): Mesh;
  70232. /**
  70233. * Creates a torus mesh
  70234. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70235. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70236. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70238. * * 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
  70239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70240. * @param name defines the name of the mesh
  70241. * @param options defines the options used to create the mesh
  70242. * @param scene defines the hosting scene
  70243. * @returns the torus mesh
  70244. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70245. */
  70246. static CreateTorus(name: string, options: {
  70247. diameter?: number;
  70248. thickness?: number;
  70249. tessellation?: number;
  70250. updatable?: boolean;
  70251. sideOrientation?: number;
  70252. frontUVs?: Vector4;
  70253. backUVs?: Vector4;
  70254. }, scene?: Nullable<Scene>): Mesh;
  70255. /**
  70256. * Creates a torus knot mesh
  70257. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70258. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70259. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70260. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70262. * * 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
  70263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70264. * @param name defines the name of the mesh
  70265. * @param options defines the options used to create the mesh
  70266. * @param scene defines the hosting scene
  70267. * @returns the torus knot mesh
  70268. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70269. */
  70270. static CreateTorusKnot(name: string, options: {
  70271. radius?: number;
  70272. tube?: number;
  70273. radialSegments?: number;
  70274. tubularSegments?: number;
  70275. p?: number;
  70276. q?: number;
  70277. updatable?: boolean;
  70278. sideOrientation?: number;
  70279. frontUVs?: Vector4;
  70280. backUVs?: Vector4;
  70281. }, scene?: Nullable<Scene>): Mesh;
  70282. /**
  70283. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70284. * * 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
  70285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70286. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70287. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70288. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70290. * * 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
  70291. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70294. * @param name defines the name of the new line system
  70295. * @param options defines the options used to create the line system
  70296. * @param scene defines the hosting scene
  70297. * @returns a new line system mesh
  70298. */
  70299. static CreateLineSystem(name: string, options: {
  70300. lines: Vector3[][];
  70301. updatable?: boolean;
  70302. instance?: Nullable<LinesMesh>;
  70303. colors?: Nullable<Color4[][]>;
  70304. useVertexAlpha?: boolean;
  70305. }, scene: Nullable<Scene>): LinesMesh;
  70306. /**
  70307. * Creates a line mesh
  70308. * 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
  70309. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70310. * * The parameter `points` is an array successive Vector3
  70311. * * 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
  70312. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70313. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70314. * * When updating an instance, remember that only point positions can change, not the number of points
  70315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70317. * @param name defines the name of the new line system
  70318. * @param options defines the options used to create the line system
  70319. * @param scene defines the hosting scene
  70320. * @returns a new line mesh
  70321. */
  70322. static CreateLines(name: string, options: {
  70323. points: Vector3[];
  70324. updatable?: boolean;
  70325. instance?: Nullable<LinesMesh>;
  70326. colors?: Color4[];
  70327. useVertexAlpha?: boolean;
  70328. }, scene?: Nullable<Scene>): LinesMesh;
  70329. /**
  70330. * Creates a dashed line mesh
  70331. * * 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
  70332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70333. * * The parameter `points` is an array successive Vector3
  70334. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70335. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70336. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70337. * * 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
  70338. * * When updating an instance, remember that only point positions can change, not the number of points
  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 dashed line mesh
  70344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70345. */
  70346. static CreateDashedLines(name: string, options: {
  70347. points: Vector3[];
  70348. dashSize?: number;
  70349. gapSize?: number;
  70350. dashNb?: number;
  70351. updatable?: boolean;
  70352. instance?: LinesMesh;
  70353. }, scene?: Nullable<Scene>): LinesMesh;
  70354. /**
  70355. * 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.
  70356. * * 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.
  70357. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70358. * * 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.
  70359. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70360. * * 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
  70361. * * 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
  70362. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70364. * * 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
  70365. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70367. * @param name defines the name of the mesh
  70368. * @param options defines the options used to create the mesh
  70369. * @param scene defines the hosting scene
  70370. * @returns the extruded shape mesh
  70371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70373. */
  70374. static ExtrudeShape(name: string, options: {
  70375. shape: Vector3[];
  70376. path: Vector3[];
  70377. scale?: number;
  70378. rotation?: number;
  70379. cap?: number;
  70380. updatable?: boolean;
  70381. sideOrientation?: number;
  70382. frontUVs?: Vector4;
  70383. backUVs?: Vector4;
  70384. instance?: Mesh;
  70385. invertUV?: boolean;
  70386. }, scene?: Nullable<Scene>): Mesh;
  70387. /**
  70388. * Creates an custom extruded shape mesh.
  70389. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70390. * * 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.
  70391. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70392. * * 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
  70393. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70394. * * 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
  70395. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70396. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70397. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70398. * * 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
  70399. * * 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
  70400. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70402. * * 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
  70403. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70405. * @param name defines the name of the mesh
  70406. * @param options defines the options used to create the mesh
  70407. * @param scene defines the hosting scene
  70408. * @returns the custom extruded shape mesh
  70409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70410. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70412. */
  70413. static ExtrudeShapeCustom(name: string, options: {
  70414. shape: Vector3[];
  70415. path: Vector3[];
  70416. scaleFunction?: any;
  70417. rotationFunction?: any;
  70418. ribbonCloseArray?: boolean;
  70419. ribbonClosePath?: boolean;
  70420. cap?: number;
  70421. updatable?: boolean;
  70422. sideOrientation?: number;
  70423. frontUVs?: Vector4;
  70424. backUVs?: Vector4;
  70425. instance?: Mesh;
  70426. invertUV?: boolean;
  70427. }, scene?: Nullable<Scene>): Mesh;
  70428. /**
  70429. * Creates lathe mesh.
  70430. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70431. * * 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
  70432. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70433. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70434. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70435. * * 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
  70436. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70437. * * 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
  70438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70439. * * 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
  70440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70442. * @param name defines the name of the mesh
  70443. * @param options defines the options used to create the mesh
  70444. * @param scene defines the hosting scene
  70445. * @returns the lathe mesh
  70446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70447. */
  70448. static CreateLathe(name: string, options: {
  70449. shape: Vector3[];
  70450. radius?: number;
  70451. tessellation?: number;
  70452. clip?: number;
  70453. arc?: number;
  70454. closed?: boolean;
  70455. updatable?: boolean;
  70456. sideOrientation?: number;
  70457. frontUVs?: Vector4;
  70458. backUVs?: Vector4;
  70459. cap?: number;
  70460. invertUV?: boolean;
  70461. }, scene?: Nullable<Scene>): Mesh;
  70462. /**
  70463. * Creates a tiled plane mesh
  70464. * * You can set a limited pattern arrangement with the tiles
  70465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70466. * * 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
  70467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70468. * @param name defines the name of the mesh
  70469. * @param options defines the options used to create the mesh
  70470. * @param scene defines the hosting scene
  70471. * @returns the plane mesh
  70472. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70473. */
  70474. static CreateTiledPlane(name: string, options: {
  70475. pattern?: number;
  70476. tileSize?: number;
  70477. tileWidth?: number;
  70478. tileHeight?: number;
  70479. size?: number;
  70480. width?: number;
  70481. height?: number;
  70482. alignHorizontal?: number;
  70483. alignVertical?: number;
  70484. sideOrientation?: number;
  70485. frontUVs?: Vector4;
  70486. backUVs?: Vector4;
  70487. updatable?: boolean;
  70488. }, scene?: Nullable<Scene>): Mesh;
  70489. /**
  70490. * Creates a plane mesh
  70491. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70492. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70493. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70495. * * 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
  70496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70497. * @param name defines the name of the mesh
  70498. * @param options defines the options used to create the mesh
  70499. * @param scene defines the hosting scene
  70500. * @returns the plane mesh
  70501. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70502. */
  70503. static CreatePlane(name: string, options: {
  70504. size?: number;
  70505. width?: number;
  70506. height?: number;
  70507. sideOrientation?: number;
  70508. frontUVs?: Vector4;
  70509. backUVs?: Vector4;
  70510. updatable?: boolean;
  70511. sourcePlane?: Plane;
  70512. }, scene?: Nullable<Scene>): Mesh;
  70513. /**
  70514. * Creates a ground mesh
  70515. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70516. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70518. * @param name defines the name of the mesh
  70519. * @param options defines the options used to create the mesh
  70520. * @param scene defines the hosting scene
  70521. * @returns the ground mesh
  70522. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70523. */
  70524. static CreateGround(name: string, options: {
  70525. width?: number;
  70526. height?: number;
  70527. subdivisions?: number;
  70528. subdivisionsX?: number;
  70529. subdivisionsY?: number;
  70530. updatable?: boolean;
  70531. }, scene?: Nullable<Scene>): Mesh;
  70532. /**
  70533. * Creates a tiled ground mesh
  70534. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70535. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70536. * * 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
  70537. * * 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
  70538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70539. * @param name defines the name of the mesh
  70540. * @param options defines the options used to create the mesh
  70541. * @param scene defines the hosting scene
  70542. * @returns the tiled ground mesh
  70543. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70544. */
  70545. static CreateTiledGround(name: string, options: {
  70546. xmin: number;
  70547. zmin: number;
  70548. xmax: number;
  70549. zmax: number;
  70550. subdivisions?: {
  70551. w: number;
  70552. h: number;
  70553. };
  70554. precision?: {
  70555. w: number;
  70556. h: number;
  70557. };
  70558. updatable?: boolean;
  70559. }, scene?: Nullable<Scene>): Mesh;
  70560. /**
  70561. * Creates a ground mesh from a height map
  70562. * * The parameter `url` sets the URL of the height map image resource.
  70563. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70564. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70565. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70566. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70567. * * 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.
  70568. * * 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).
  70569. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70571. * @param name defines the name of the mesh
  70572. * @param url defines the url to the height map
  70573. * @param options defines the options used to create the mesh
  70574. * @param scene defines the hosting scene
  70575. * @returns the ground mesh
  70576. * @see https://doc.babylonjs.com/babylon101/height_map
  70577. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70578. */
  70579. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70580. width?: number;
  70581. height?: number;
  70582. subdivisions?: number;
  70583. minHeight?: number;
  70584. maxHeight?: number;
  70585. colorFilter?: Color3;
  70586. alphaFilter?: number;
  70587. updatable?: boolean;
  70588. onReady?: (mesh: GroundMesh) => void;
  70589. }, scene?: Nullable<Scene>): GroundMesh;
  70590. /**
  70591. * Creates a polygon mesh
  70592. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70593. * * 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
  70594. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70596. * * 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)
  70597. * * Remember you can only change the shape positions, not their number when updating a polygon
  70598. * @param name defines the name of the mesh
  70599. * @param options defines the options used to create the mesh
  70600. * @param scene defines the hosting scene
  70601. * @param earcutInjection can be used to inject your own earcut reference
  70602. * @returns the polygon mesh
  70603. */
  70604. static CreatePolygon(name: string, options: {
  70605. shape: Vector3[];
  70606. holes?: Vector3[][];
  70607. depth?: number;
  70608. faceUV?: Vector4[];
  70609. faceColors?: Color4[];
  70610. updatable?: boolean;
  70611. sideOrientation?: number;
  70612. frontUVs?: Vector4;
  70613. backUVs?: Vector4;
  70614. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70615. /**
  70616. * Creates an extruded polygon mesh, with depth in the Y direction.
  70617. * * 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)
  70618. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70619. * @param name defines the name of the mesh
  70620. * @param options defines the options used to create the mesh
  70621. * @param scene defines the hosting scene
  70622. * @param earcutInjection can be used to inject your own earcut reference
  70623. * @returns the polygon mesh
  70624. */
  70625. static ExtrudePolygon(name: string, options: {
  70626. shape: Vector3[];
  70627. holes?: Vector3[][];
  70628. depth?: number;
  70629. faceUV?: Vector4[];
  70630. faceColors?: Color4[];
  70631. updatable?: boolean;
  70632. sideOrientation?: number;
  70633. frontUVs?: Vector4;
  70634. backUVs?: Vector4;
  70635. wrap?: boolean;
  70636. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70637. /**
  70638. * Creates a tube mesh.
  70639. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70640. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70641. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70642. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70643. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70644. * * 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)
  70645. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70646. * * 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
  70647. * * 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
  70648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70649. * * 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
  70650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70652. * @param name defines the name of the mesh
  70653. * @param options defines the options used to create the mesh
  70654. * @param scene defines the hosting scene
  70655. * @returns the tube mesh
  70656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70657. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70658. */
  70659. static CreateTube(name: string, options: {
  70660. path: Vector3[];
  70661. radius?: number;
  70662. tessellation?: number;
  70663. radiusFunction?: {
  70664. (i: number, distance: number): number;
  70665. };
  70666. cap?: number;
  70667. arc?: number;
  70668. updatable?: boolean;
  70669. sideOrientation?: number;
  70670. frontUVs?: Vector4;
  70671. backUVs?: Vector4;
  70672. instance?: Mesh;
  70673. invertUV?: boolean;
  70674. }, scene?: Nullable<Scene>): Mesh;
  70675. /**
  70676. * Creates a polyhedron mesh
  70677. * * 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
  70678. * * The parameter `size` (positive float, default 1) sets the polygon size
  70679. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70680. * * 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`
  70681. * * 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
  70682. * * 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)`)
  70683. * * 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
  70684. * * 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
  70685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70686. * * 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
  70687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70688. * @param name defines the name of the mesh
  70689. * @param options defines the options used to create the mesh
  70690. * @param scene defines the hosting scene
  70691. * @returns the polyhedron mesh
  70692. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70693. */
  70694. static CreatePolyhedron(name: string, options: {
  70695. type?: number;
  70696. size?: number;
  70697. sizeX?: number;
  70698. sizeY?: number;
  70699. sizeZ?: number;
  70700. custom?: any;
  70701. faceUV?: Vector4[];
  70702. faceColors?: Color4[];
  70703. flat?: boolean;
  70704. updatable?: boolean;
  70705. sideOrientation?: number;
  70706. frontUVs?: Vector4;
  70707. backUVs?: Vector4;
  70708. }, scene?: Nullable<Scene>): Mesh;
  70709. /**
  70710. * Creates a decal mesh.
  70711. * 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
  70712. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70713. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70714. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70715. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70716. * @param name defines the name of the mesh
  70717. * @param sourceMesh defines the mesh where the decal must be applied
  70718. * @param options defines the options used to create the mesh
  70719. * @param scene defines the hosting scene
  70720. * @returns the decal mesh
  70721. * @see https://doc.babylonjs.com/how_to/decals
  70722. */
  70723. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70724. position?: Vector3;
  70725. normal?: Vector3;
  70726. size?: Vector3;
  70727. angle?: number;
  70728. }): Mesh;
  70729. /**
  70730. * Creates a Capsule Mesh
  70731. * @param name defines the name of the mesh.
  70732. * @param options the constructors options used to shape the mesh.
  70733. * @param scene defines the scene the mesh is scoped to.
  70734. * @returns the capsule mesh
  70735. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70736. */
  70737. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70738. }
  70739. }
  70740. declare module BABYLON {
  70741. /**
  70742. * A simplifier interface for future simplification implementations
  70743. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70744. */
  70745. export interface ISimplifier {
  70746. /**
  70747. * Simplification of a given mesh according to the given settings.
  70748. * Since this requires computation, it is assumed that the function runs async.
  70749. * @param settings The settings of the simplification, including quality and distance
  70750. * @param successCallback A callback that will be called after the mesh was simplified.
  70751. * @param errorCallback in case of an error, this callback will be called. optional.
  70752. */
  70753. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70754. }
  70755. /**
  70756. * Expected simplification settings.
  70757. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70758. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70759. */
  70760. export interface ISimplificationSettings {
  70761. /**
  70762. * Gets or sets the expected quality
  70763. */
  70764. quality: number;
  70765. /**
  70766. * Gets or sets the distance when this optimized version should be used
  70767. */
  70768. distance: number;
  70769. /**
  70770. * Gets an already optimized mesh
  70771. */
  70772. optimizeMesh?: boolean;
  70773. }
  70774. /**
  70775. * Class used to specify simplification options
  70776. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70777. */
  70778. export class SimplificationSettings implements ISimplificationSettings {
  70779. /** expected quality */
  70780. quality: number;
  70781. /** distance when this optimized version should be used */
  70782. distance: number;
  70783. /** already optimized mesh */
  70784. optimizeMesh?: boolean | undefined;
  70785. /**
  70786. * Creates a SimplificationSettings
  70787. * @param quality expected quality
  70788. * @param distance distance when this optimized version should be used
  70789. * @param optimizeMesh already optimized mesh
  70790. */
  70791. constructor(
  70792. /** expected quality */
  70793. quality: number,
  70794. /** distance when this optimized version should be used */
  70795. distance: number,
  70796. /** already optimized mesh */
  70797. optimizeMesh?: boolean | undefined);
  70798. }
  70799. /**
  70800. * Interface used to define a simplification task
  70801. */
  70802. export interface ISimplificationTask {
  70803. /**
  70804. * Array of settings
  70805. */
  70806. settings: Array<ISimplificationSettings>;
  70807. /**
  70808. * Simplification type
  70809. */
  70810. simplificationType: SimplificationType;
  70811. /**
  70812. * Mesh to simplify
  70813. */
  70814. mesh: Mesh;
  70815. /**
  70816. * Callback called on success
  70817. */
  70818. successCallback?: () => void;
  70819. /**
  70820. * Defines if parallel processing can be used
  70821. */
  70822. parallelProcessing: boolean;
  70823. }
  70824. /**
  70825. * Queue used to order the simplification tasks
  70826. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70827. */
  70828. export class SimplificationQueue {
  70829. private _simplificationArray;
  70830. /**
  70831. * Gets a boolean indicating that the process is still running
  70832. */
  70833. running: boolean;
  70834. /**
  70835. * Creates a new queue
  70836. */
  70837. constructor();
  70838. /**
  70839. * Adds a new simplification task
  70840. * @param task defines a task to add
  70841. */
  70842. addTask(task: ISimplificationTask): void;
  70843. /**
  70844. * Execute next task
  70845. */
  70846. executeNext(): void;
  70847. /**
  70848. * Execute a simplification task
  70849. * @param task defines the task to run
  70850. */
  70851. runSimplification(task: ISimplificationTask): void;
  70852. private getSimplifier;
  70853. }
  70854. /**
  70855. * The implemented types of simplification
  70856. * At the moment only Quadratic Error Decimation is implemented
  70857. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70858. */
  70859. export enum SimplificationType {
  70860. /** Quadratic error decimation */
  70861. QUADRATIC = 0
  70862. }
  70863. /**
  70864. * An implementation of the Quadratic Error simplification algorithm.
  70865. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70866. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70867. * @author RaananW
  70868. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70869. */
  70870. export class QuadraticErrorSimplification implements ISimplifier {
  70871. private _mesh;
  70872. private triangles;
  70873. private vertices;
  70874. private references;
  70875. private _reconstructedMesh;
  70876. /** Gets or sets the number pf sync interations */
  70877. syncIterations: number;
  70878. /** Gets or sets the aggressiveness of the simplifier */
  70879. aggressiveness: number;
  70880. /** Gets or sets the number of allowed iterations for decimation */
  70881. decimationIterations: number;
  70882. /** Gets or sets the espilon to use for bounding box computation */
  70883. boundingBoxEpsilon: number;
  70884. /**
  70885. * Creates a new QuadraticErrorSimplification
  70886. * @param _mesh defines the target mesh
  70887. */
  70888. constructor(_mesh: Mesh);
  70889. /**
  70890. * Simplification of a given mesh according to the given settings.
  70891. * Since this requires computation, it is assumed that the function runs async.
  70892. * @param settings The settings of the simplification, including quality and distance
  70893. * @param successCallback A callback that will be called after the mesh was simplified.
  70894. */
  70895. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70896. private runDecimation;
  70897. private initWithMesh;
  70898. private init;
  70899. private reconstructMesh;
  70900. private initDecimatedMesh;
  70901. private isFlipped;
  70902. private updateTriangles;
  70903. private identifyBorder;
  70904. private updateMesh;
  70905. private vertexError;
  70906. private calculateError;
  70907. }
  70908. }
  70909. declare module BABYLON {
  70910. interface Scene {
  70911. /** @hidden (Backing field) */
  70912. _simplificationQueue: SimplificationQueue;
  70913. /**
  70914. * Gets or sets the simplification queue attached to the scene
  70915. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70916. */
  70917. simplificationQueue: SimplificationQueue;
  70918. }
  70919. interface Mesh {
  70920. /**
  70921. * Simplify the mesh according to the given array of settings.
  70922. * Function will return immediately and will simplify async
  70923. * @param settings a collection of simplification settings
  70924. * @param parallelProcessing should all levels calculate parallel or one after the other
  70925. * @param simplificationType the type of simplification to run
  70926. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70927. * @returns the current mesh
  70928. */
  70929. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70930. }
  70931. /**
  70932. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70933. * created in a scene
  70934. */
  70935. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70936. /**
  70937. * The component name helpfull to identify the component in the list of scene components.
  70938. */
  70939. readonly name: string;
  70940. /**
  70941. * The scene the component belongs to.
  70942. */
  70943. scene: Scene;
  70944. /**
  70945. * Creates a new instance of the component for the given scene
  70946. * @param scene Defines the scene to register the component in
  70947. */
  70948. constructor(scene: Scene);
  70949. /**
  70950. * Registers the component in a given scene
  70951. */
  70952. register(): void;
  70953. /**
  70954. * Rebuilds the elements related to this component in case of
  70955. * context lost for instance.
  70956. */
  70957. rebuild(): void;
  70958. /**
  70959. * Disposes the component and the associated ressources
  70960. */
  70961. dispose(): void;
  70962. private _beforeCameraUpdate;
  70963. }
  70964. }
  70965. declare module BABYLON {
  70966. interface Mesh {
  70967. /**
  70968. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70969. */
  70970. thinInstanceEnablePicking: boolean;
  70971. /**
  70972. * Creates a new thin instance
  70973. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70974. * @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
  70975. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70976. */
  70977. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70978. /**
  70979. * Adds the transformation (matrix) of the current mesh as a thin instance
  70980. * @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
  70981. * @returns the thin instance index number
  70982. */
  70983. thinInstanceAddSelf(refresh: boolean): number;
  70984. /**
  70985. * Registers a custom attribute to be used with thin instances
  70986. * @param kind name of the attribute
  70987. * @param stride size in floats of the attribute
  70988. */
  70989. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70990. /**
  70991. * Sets the matrix of a thin instance
  70992. * @param index index of the thin instance
  70993. * @param matrix matrix to set
  70994. * @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
  70995. */
  70996. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70997. /**
  70998. * Sets the value of a custom attribute for a thin instance
  70999. * @param kind name of the attribute
  71000. * @param index index of the thin instance
  71001. * @param value value to set
  71002. * @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
  71003. */
  71004. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71005. /**
  71006. * 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.
  71007. */
  71008. thinInstanceCount: number;
  71009. /**
  71010. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71011. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71012. * @param buffer buffer to set
  71013. * @param stride size in floats of each value of the buffer
  71014. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71015. */
  71016. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71017. /**
  71018. * Gets the list of world matrices
  71019. * @return an array containing all the world matrices from the thin instances
  71020. */
  71021. thinInstanceGetWorldMatrices(): Matrix[];
  71022. /**
  71023. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71024. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71025. */
  71026. thinInstanceBufferUpdated(kind: string): void;
  71027. /**
  71028. * Applies a partial update to a buffer directly on the GPU
  71029. * 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
  71030. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71031. * @param data the data to set in the GPU buffer
  71032. * @param offset the offset in the GPU buffer where to update the data
  71033. */
  71034. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71035. /**
  71036. * Refreshes the bounding info, taking into account all the thin instances defined
  71037. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71038. */
  71039. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71040. /** @hidden */
  71041. _thinInstanceInitializeUserStorage(): void;
  71042. /** @hidden */
  71043. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71044. /** @hidden */
  71045. _userThinInstanceBuffersStorage: {
  71046. data: {
  71047. [key: string]: Float32Array;
  71048. };
  71049. sizes: {
  71050. [key: string]: number;
  71051. };
  71052. vertexBuffers: {
  71053. [key: string]: Nullable<VertexBuffer>;
  71054. };
  71055. strides: {
  71056. [key: string]: number;
  71057. };
  71058. };
  71059. }
  71060. }
  71061. declare module BABYLON {
  71062. /**
  71063. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71064. */
  71065. export interface INavigationEnginePlugin {
  71066. /**
  71067. * plugin name
  71068. */
  71069. name: string;
  71070. /**
  71071. * Creates a navigation mesh
  71072. * @param meshes array of all the geometry used to compute the navigatio mesh
  71073. * @param parameters bunch of parameters used to filter geometry
  71074. */
  71075. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71076. /**
  71077. * Create a navigation mesh debug mesh
  71078. * @param scene is where the mesh will be added
  71079. * @returns debug display mesh
  71080. */
  71081. createDebugNavMesh(scene: Scene): Mesh;
  71082. /**
  71083. * Get a navigation mesh constrained position, closest to the parameter position
  71084. * @param position world position
  71085. * @returns the closest point to position constrained by the navigation mesh
  71086. */
  71087. getClosestPoint(position: Vector3): Vector3;
  71088. /**
  71089. * Get a navigation mesh constrained position, closest to the parameter position
  71090. * @param position world position
  71091. * @param result output the closest point to position constrained by the navigation mesh
  71092. */
  71093. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71094. /**
  71095. * Get a navigation mesh constrained position, within a particular radius
  71096. * @param position world position
  71097. * @param maxRadius the maximum distance to the constrained world position
  71098. * @returns the closest point to position constrained by the navigation mesh
  71099. */
  71100. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71101. /**
  71102. * Get a navigation mesh constrained position, within a particular radius
  71103. * @param position world position
  71104. * @param maxRadius the maximum distance to the constrained world position
  71105. * @param result output the closest point to position constrained by the navigation mesh
  71106. */
  71107. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71108. /**
  71109. * Compute the final position from a segment made of destination-position
  71110. * @param position world position
  71111. * @param destination world position
  71112. * @returns the resulting point along the navmesh
  71113. */
  71114. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71115. /**
  71116. * Compute the final position from a segment made of destination-position
  71117. * @param position world position
  71118. * @param destination world position
  71119. * @param result output the resulting point along the navmesh
  71120. */
  71121. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71122. /**
  71123. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71124. * @param start world position
  71125. * @param end world position
  71126. * @returns array containing world position composing the path
  71127. */
  71128. computePath(start: Vector3, end: Vector3): Vector3[];
  71129. /**
  71130. * If this plugin is supported
  71131. * @returns true if plugin is supported
  71132. */
  71133. isSupported(): boolean;
  71134. /**
  71135. * Create a new Crowd so you can add agents
  71136. * @param maxAgents the maximum agent count in the crowd
  71137. * @param maxAgentRadius the maximum radius an agent can have
  71138. * @param scene to attach the crowd to
  71139. * @returns the crowd you can add agents to
  71140. */
  71141. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71142. /**
  71143. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71144. * The queries will try to find a solution within those bounds
  71145. * default is (1,1,1)
  71146. * @param extent x,y,z value that define the extent around the queries point of reference
  71147. */
  71148. setDefaultQueryExtent(extent: Vector3): void;
  71149. /**
  71150. * Get the Bounding box extent specified by setDefaultQueryExtent
  71151. * @returns the box extent values
  71152. */
  71153. getDefaultQueryExtent(): Vector3;
  71154. /**
  71155. * build the navmesh from a previously saved state using getNavmeshData
  71156. * @param data the Uint8Array returned by getNavmeshData
  71157. */
  71158. buildFromNavmeshData(data: Uint8Array): void;
  71159. /**
  71160. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71161. * @returns data the Uint8Array that can be saved and reused
  71162. */
  71163. getNavmeshData(): Uint8Array;
  71164. /**
  71165. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71166. * @param result output the box extent values
  71167. */
  71168. getDefaultQueryExtentToRef(result: Vector3): void;
  71169. /**
  71170. * Set the time step of the navigation tick update.
  71171. * Default is 1/60.
  71172. * A value of 0 will disable fixed time update
  71173. * @param newTimeStep the new timestep to apply to this world.
  71174. */
  71175. setTimeStep(newTimeStep: number): void;
  71176. /**
  71177. * Get the time step of the navigation tick update.
  71178. * @returns the current time step
  71179. */
  71180. getTimeStep(): number;
  71181. /**
  71182. * If delta time in navigation tick update is greater than the time step
  71183. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71184. * they will be discarded.
  71185. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71186. * @param newStepCount the maximum number of iterations
  71187. */
  71188. setMaximumSubStepCount(newStepCount: number): void;
  71189. /**
  71190. * Get the maximum number of iterations per navigation tick update
  71191. * @returns the maximum number of iterations
  71192. */
  71193. getMaximumSubStepCount(): number;
  71194. /**
  71195. * Release all resources
  71196. */
  71197. dispose(): void;
  71198. }
  71199. /**
  71200. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71201. */
  71202. export interface ICrowd {
  71203. /**
  71204. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71205. * You can attach anything to that node. The node position is updated in the scene update tick.
  71206. * @param pos world position that will be constrained by the navigation mesh
  71207. * @param parameters agent parameters
  71208. * @param transform hooked to the agent that will be update by the scene
  71209. * @returns agent index
  71210. */
  71211. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71212. /**
  71213. * Returns the agent position in world space
  71214. * @param index agent index returned by addAgent
  71215. * @returns world space position
  71216. */
  71217. getAgentPosition(index: number): Vector3;
  71218. /**
  71219. * Gets the agent position result in world space
  71220. * @param index agent index returned by addAgent
  71221. * @param result output world space position
  71222. */
  71223. getAgentPositionToRef(index: number, result: Vector3): void;
  71224. /**
  71225. * Gets the agent velocity in world space
  71226. * @param index agent index returned by addAgent
  71227. * @returns world space velocity
  71228. */
  71229. getAgentVelocity(index: number): Vector3;
  71230. /**
  71231. * Gets the agent velocity result in world space
  71232. * @param index agent index returned by addAgent
  71233. * @param result output world space velocity
  71234. */
  71235. getAgentVelocityToRef(index: number, result: Vector3): void;
  71236. /**
  71237. * Gets the agent next target point on the path
  71238. * @param index agent index returned by addAgent
  71239. * @returns world space position
  71240. */
  71241. getAgentNextTargetPath(index: number): Vector3;
  71242. /**
  71243. * Gets the agent state
  71244. * @param index agent index returned by addAgent
  71245. * @returns agent state
  71246. */
  71247. getAgentState(index: number): number;
  71248. /**
  71249. * returns true if the agent in over an off mesh link connection
  71250. * @param index agent index returned by addAgent
  71251. * @returns true if over an off mesh link connection
  71252. */
  71253. overOffmeshConnection(index: number): boolean;
  71254. /**
  71255. * Gets the agent next target point on the path
  71256. * @param index agent index returned by addAgent
  71257. * @param result output world space position
  71258. */
  71259. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71260. /**
  71261. * remove a particular agent previously created
  71262. * @param index agent index returned by addAgent
  71263. */
  71264. removeAgent(index: number): void;
  71265. /**
  71266. * get the list of all agents attached to this crowd
  71267. * @returns list of agent indices
  71268. */
  71269. getAgents(): number[];
  71270. /**
  71271. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71272. * @param deltaTime in seconds
  71273. */
  71274. update(deltaTime: number): void;
  71275. /**
  71276. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71277. * @param index agent index returned by addAgent
  71278. * @param destination targeted world position
  71279. */
  71280. agentGoto(index: number, destination: Vector3): void;
  71281. /**
  71282. * Teleport the agent to a new position
  71283. * @param index agent index returned by addAgent
  71284. * @param destination targeted world position
  71285. */
  71286. agentTeleport(index: number, destination: Vector3): void;
  71287. /**
  71288. * Update agent parameters
  71289. * @param index agent index returned by addAgent
  71290. * @param parameters agent parameters
  71291. */
  71292. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71293. /**
  71294. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71295. * The queries will try to find a solution within those bounds
  71296. * default is (1,1,1)
  71297. * @param extent x,y,z value that define the extent around the queries point of reference
  71298. */
  71299. setDefaultQueryExtent(extent: Vector3): void;
  71300. /**
  71301. * Get the Bounding box extent specified by setDefaultQueryExtent
  71302. * @returns the box extent values
  71303. */
  71304. getDefaultQueryExtent(): Vector3;
  71305. /**
  71306. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71307. * @param result output the box extent values
  71308. */
  71309. getDefaultQueryExtentToRef(result: Vector3): void;
  71310. /**
  71311. * Release all resources
  71312. */
  71313. dispose(): void;
  71314. }
  71315. /**
  71316. * Configures an agent
  71317. */
  71318. export interface IAgentParameters {
  71319. /**
  71320. * Agent radius. [Limit: >= 0]
  71321. */
  71322. radius: number;
  71323. /**
  71324. * Agent height. [Limit: > 0]
  71325. */
  71326. height: number;
  71327. /**
  71328. * Maximum allowed acceleration. [Limit: >= 0]
  71329. */
  71330. maxAcceleration: number;
  71331. /**
  71332. * Maximum allowed speed. [Limit: >= 0]
  71333. */
  71334. maxSpeed: number;
  71335. /**
  71336. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71337. */
  71338. collisionQueryRange: number;
  71339. /**
  71340. * The path visibility optimization range. [Limit: > 0]
  71341. */
  71342. pathOptimizationRange: number;
  71343. /**
  71344. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71345. */
  71346. separationWeight: number;
  71347. }
  71348. /**
  71349. * Configures the navigation mesh creation
  71350. */
  71351. export interface INavMeshParameters {
  71352. /**
  71353. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71354. */
  71355. cs: number;
  71356. /**
  71357. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71358. */
  71359. ch: number;
  71360. /**
  71361. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71362. */
  71363. walkableSlopeAngle: number;
  71364. /**
  71365. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71366. * be considered walkable. [Limit: >= 3] [Units: vx]
  71367. */
  71368. walkableHeight: number;
  71369. /**
  71370. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71371. */
  71372. walkableClimb: number;
  71373. /**
  71374. * The distance to erode/shrink the walkable area of the heightfield away from
  71375. * obstructions. [Limit: >=0] [Units: vx]
  71376. */
  71377. walkableRadius: number;
  71378. /**
  71379. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71380. */
  71381. maxEdgeLen: number;
  71382. /**
  71383. * The maximum distance a simplfied contour's border edges should deviate
  71384. * the original raw contour. [Limit: >=0] [Units: vx]
  71385. */
  71386. maxSimplificationError: number;
  71387. /**
  71388. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71389. */
  71390. minRegionArea: number;
  71391. /**
  71392. * Any regions with a span count smaller than this value will, if possible,
  71393. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71394. */
  71395. mergeRegionArea: number;
  71396. /**
  71397. * The maximum number of vertices allowed for polygons generated during the
  71398. * contour to polygon conversion process. [Limit: >= 3]
  71399. */
  71400. maxVertsPerPoly: number;
  71401. /**
  71402. * Sets the sampling distance to use when generating the detail mesh.
  71403. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71404. */
  71405. detailSampleDist: number;
  71406. /**
  71407. * The maximum distance the detail mesh surface should deviate from heightfield
  71408. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71409. */
  71410. detailSampleMaxError: number;
  71411. }
  71412. }
  71413. declare module BABYLON {
  71414. /**
  71415. * RecastJS navigation plugin
  71416. */
  71417. export class RecastJSPlugin implements INavigationEnginePlugin {
  71418. /**
  71419. * Reference to the Recast library
  71420. */
  71421. bjsRECAST: any;
  71422. /**
  71423. * plugin name
  71424. */
  71425. name: string;
  71426. /**
  71427. * the first navmesh created. We might extend this to support multiple navmeshes
  71428. */
  71429. navMesh: any;
  71430. private _maximumSubStepCount;
  71431. private _timeStep;
  71432. /**
  71433. * Initializes the recastJS plugin
  71434. * @param recastInjection can be used to inject your own recast reference
  71435. */
  71436. constructor(recastInjection?: any);
  71437. /**
  71438. * Set the time step of the navigation tick update.
  71439. * Default is 1/60.
  71440. * A value of 0 will disable fixed time update
  71441. * @param newTimeStep the new timestep to apply to this world.
  71442. */
  71443. setTimeStep(newTimeStep?: number): void;
  71444. /**
  71445. * Get the time step of the navigation tick update.
  71446. * @returns the current time step
  71447. */
  71448. getTimeStep(): number;
  71449. /**
  71450. * If delta time in navigation tick update is greater than the time step
  71451. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71452. * they will be discarded.
  71453. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71454. * @param newStepCount the maximum number of iterations
  71455. */
  71456. setMaximumSubStepCount(newStepCount?: number): void;
  71457. /**
  71458. * Get the maximum number of iterations per navigation tick update
  71459. * @returns the maximum number of iterations
  71460. */
  71461. getMaximumSubStepCount(): number;
  71462. /**
  71463. * Creates a navigation mesh
  71464. * @param meshes array of all the geometry used to compute the navigatio mesh
  71465. * @param parameters bunch of parameters used to filter geometry
  71466. */
  71467. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71468. /**
  71469. * Create a navigation mesh debug mesh
  71470. * @param scene is where the mesh will be added
  71471. * @returns debug display mesh
  71472. */
  71473. createDebugNavMesh(scene: Scene): Mesh;
  71474. /**
  71475. * Get a navigation mesh constrained position, closest to the parameter position
  71476. * @param position world position
  71477. * @returns the closest point to position constrained by the navigation mesh
  71478. */
  71479. getClosestPoint(position: Vector3): Vector3;
  71480. /**
  71481. * Get a navigation mesh constrained position, closest to the parameter position
  71482. * @param position world position
  71483. * @param result output the closest point to position constrained by the navigation mesh
  71484. */
  71485. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71486. /**
  71487. * Get a navigation mesh constrained position, within a particular radius
  71488. * @param position world position
  71489. * @param maxRadius the maximum distance to the constrained world position
  71490. * @returns the closest point to position constrained by the navigation mesh
  71491. */
  71492. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71493. /**
  71494. * Get a navigation mesh constrained position, within a particular radius
  71495. * @param position world position
  71496. * @param maxRadius the maximum distance to the constrained world position
  71497. * @param result output the closest point to position constrained by the navigation mesh
  71498. */
  71499. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71500. /**
  71501. * Compute the final position from a segment made of destination-position
  71502. * @param position world position
  71503. * @param destination world position
  71504. * @returns the resulting point along the navmesh
  71505. */
  71506. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71507. /**
  71508. * Compute the final position from a segment made of destination-position
  71509. * @param position world position
  71510. * @param destination world position
  71511. * @param result output the resulting point along the navmesh
  71512. */
  71513. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71514. /**
  71515. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71516. * @param start world position
  71517. * @param end world position
  71518. * @returns array containing world position composing the path
  71519. */
  71520. computePath(start: Vector3, end: Vector3): Vector3[];
  71521. /**
  71522. * Create a new Crowd so you can add agents
  71523. * @param maxAgents the maximum agent count in the crowd
  71524. * @param maxAgentRadius the maximum radius an agent can have
  71525. * @param scene to attach the crowd to
  71526. * @returns the crowd you can add agents to
  71527. */
  71528. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71529. /**
  71530. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71531. * The queries will try to find a solution within those bounds
  71532. * default is (1,1,1)
  71533. * @param extent x,y,z value that define the extent around the queries point of reference
  71534. */
  71535. setDefaultQueryExtent(extent: Vector3): void;
  71536. /**
  71537. * Get the Bounding box extent specified by setDefaultQueryExtent
  71538. * @returns the box extent values
  71539. */
  71540. getDefaultQueryExtent(): Vector3;
  71541. /**
  71542. * build the navmesh from a previously saved state using getNavmeshData
  71543. * @param data the Uint8Array returned by getNavmeshData
  71544. */
  71545. buildFromNavmeshData(data: Uint8Array): void;
  71546. /**
  71547. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71548. * @returns data the Uint8Array that can be saved and reused
  71549. */
  71550. getNavmeshData(): Uint8Array;
  71551. /**
  71552. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71553. * @param result output the box extent values
  71554. */
  71555. getDefaultQueryExtentToRef(result: Vector3): void;
  71556. /**
  71557. * Disposes
  71558. */
  71559. dispose(): void;
  71560. /**
  71561. * If this plugin is supported
  71562. * @returns true if plugin is supported
  71563. */
  71564. isSupported(): boolean;
  71565. }
  71566. /**
  71567. * Recast detour crowd implementation
  71568. */
  71569. export class RecastJSCrowd implements ICrowd {
  71570. /**
  71571. * Recast/detour plugin
  71572. */
  71573. bjsRECASTPlugin: RecastJSPlugin;
  71574. /**
  71575. * Link to the detour crowd
  71576. */
  71577. recastCrowd: any;
  71578. /**
  71579. * One transform per agent
  71580. */
  71581. transforms: TransformNode[];
  71582. /**
  71583. * All agents created
  71584. */
  71585. agents: number[];
  71586. /**
  71587. * Link to the scene is kept to unregister the crowd from the scene
  71588. */
  71589. private _scene;
  71590. /**
  71591. * Observer for crowd updates
  71592. */
  71593. private _onBeforeAnimationsObserver;
  71594. /**
  71595. * Constructor
  71596. * @param plugin recastJS plugin
  71597. * @param maxAgents the maximum agent count in the crowd
  71598. * @param maxAgentRadius the maximum radius an agent can have
  71599. * @param scene to attach the crowd to
  71600. * @returns the crowd you can add agents to
  71601. */
  71602. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71603. /**
  71604. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71605. * You can attach anything to that node. The node position is updated in the scene update tick.
  71606. * @param pos world position that will be constrained by the navigation mesh
  71607. * @param parameters agent parameters
  71608. * @param transform hooked to the agent that will be update by the scene
  71609. * @returns agent index
  71610. */
  71611. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71612. /**
  71613. * Returns the agent position in world space
  71614. * @param index agent index returned by addAgent
  71615. * @returns world space position
  71616. */
  71617. getAgentPosition(index: number): Vector3;
  71618. /**
  71619. * Returns the agent position result in world space
  71620. * @param index agent index returned by addAgent
  71621. * @param result output world space position
  71622. */
  71623. getAgentPositionToRef(index: number, result: Vector3): void;
  71624. /**
  71625. * Returns the agent velocity in world space
  71626. * @param index agent index returned by addAgent
  71627. * @returns world space velocity
  71628. */
  71629. getAgentVelocity(index: number): Vector3;
  71630. /**
  71631. * Returns the agent velocity result in world space
  71632. * @param index agent index returned by addAgent
  71633. * @param result output world space velocity
  71634. */
  71635. getAgentVelocityToRef(index: number, result: Vector3): void;
  71636. /**
  71637. * Returns the agent next target point on the path
  71638. * @param index agent index returned by addAgent
  71639. * @returns world space position
  71640. */
  71641. getAgentNextTargetPath(index: number): Vector3;
  71642. /**
  71643. * Returns the agent next target point on the path
  71644. * @param index agent index returned by addAgent
  71645. * @param result output world space position
  71646. */
  71647. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71648. /**
  71649. * Gets the agent state
  71650. * @param index agent index returned by addAgent
  71651. * @returns agent state
  71652. */
  71653. getAgentState(index: number): number;
  71654. /**
  71655. * returns true if the agent in over an off mesh link connection
  71656. * @param index agent index returned by addAgent
  71657. * @returns true if over an off mesh link connection
  71658. */
  71659. overOffmeshConnection(index: number): boolean;
  71660. /**
  71661. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71662. * @param index agent index returned by addAgent
  71663. * @param destination targeted world position
  71664. */
  71665. agentGoto(index: number, destination: Vector3): void;
  71666. /**
  71667. * Teleport the agent to a new position
  71668. * @param index agent index returned by addAgent
  71669. * @param destination targeted world position
  71670. */
  71671. agentTeleport(index: number, destination: Vector3): void;
  71672. /**
  71673. * Update agent parameters
  71674. * @param index agent index returned by addAgent
  71675. * @param parameters agent parameters
  71676. */
  71677. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71678. /**
  71679. * remove a particular agent previously created
  71680. * @param index agent index returned by addAgent
  71681. */
  71682. removeAgent(index: number): void;
  71683. /**
  71684. * get the list of all agents attached to this crowd
  71685. * @returns list of agent indices
  71686. */
  71687. getAgents(): number[];
  71688. /**
  71689. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71690. * @param deltaTime in seconds
  71691. */
  71692. update(deltaTime: number): void;
  71693. /**
  71694. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71695. * The queries will try to find a solution within those bounds
  71696. * default is (1,1,1)
  71697. * @param extent x,y,z value that define the extent around the queries point of reference
  71698. */
  71699. setDefaultQueryExtent(extent: Vector3): void;
  71700. /**
  71701. * Get the Bounding box extent specified by setDefaultQueryExtent
  71702. * @returns the box extent values
  71703. */
  71704. getDefaultQueryExtent(): Vector3;
  71705. /**
  71706. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71707. * @param result output the box extent values
  71708. */
  71709. getDefaultQueryExtentToRef(result: Vector3): void;
  71710. /**
  71711. * Release all resources
  71712. */
  71713. dispose(): void;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /**
  71718. * Class used to enable access to IndexedDB
  71719. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71720. */
  71721. export class Database implements IOfflineProvider {
  71722. private _callbackManifestChecked;
  71723. private _currentSceneUrl;
  71724. private _db;
  71725. private _enableSceneOffline;
  71726. private _enableTexturesOffline;
  71727. private _manifestVersionFound;
  71728. private _mustUpdateRessources;
  71729. private _hasReachedQuota;
  71730. private _isSupported;
  71731. private _idbFactory;
  71732. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71733. private static IsUASupportingBlobStorage;
  71734. /**
  71735. * Gets a boolean indicating if Database storate is enabled (off by default)
  71736. */
  71737. static IDBStorageEnabled: boolean;
  71738. /**
  71739. * Gets a boolean indicating if scene must be saved in the database
  71740. */
  71741. get enableSceneOffline(): boolean;
  71742. /**
  71743. * Gets a boolean indicating if textures must be saved in the database
  71744. */
  71745. get enableTexturesOffline(): boolean;
  71746. /**
  71747. * Creates a new Database
  71748. * @param urlToScene defines the url to load the scene
  71749. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71750. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71751. */
  71752. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71753. private static _ParseURL;
  71754. private static _ReturnFullUrlLocation;
  71755. private _checkManifestFile;
  71756. /**
  71757. * Open the database and make it available
  71758. * @param successCallback defines the callback to call on success
  71759. * @param errorCallback defines the callback to call on error
  71760. */
  71761. open(successCallback: () => void, errorCallback: () => void): void;
  71762. /**
  71763. * Loads an image from the database
  71764. * @param url defines the url to load from
  71765. * @param image defines the target DOM image
  71766. */
  71767. loadImage(url: string, image: HTMLImageElement): void;
  71768. private _loadImageFromDBAsync;
  71769. private _saveImageIntoDBAsync;
  71770. private _checkVersionFromDB;
  71771. private _loadVersionFromDBAsync;
  71772. private _saveVersionIntoDBAsync;
  71773. /**
  71774. * Loads a file from database
  71775. * @param url defines the URL to load from
  71776. * @param sceneLoaded defines a callback to call on success
  71777. * @param progressCallBack defines a callback to call when progress changed
  71778. * @param errorCallback defines a callback to call on error
  71779. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71780. */
  71781. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71782. private _loadFileAsync;
  71783. private _saveFileAsync;
  71784. /**
  71785. * Validates if xhr data is correct
  71786. * @param xhr defines the request to validate
  71787. * @param dataType defines the expected data type
  71788. * @returns true if data is correct
  71789. */
  71790. private static _ValidateXHRData;
  71791. }
  71792. }
  71793. declare module BABYLON {
  71794. /** @hidden */
  71795. export var gpuUpdateParticlesPixelShader: {
  71796. name: string;
  71797. shader: string;
  71798. };
  71799. }
  71800. declare module BABYLON {
  71801. /** @hidden */
  71802. export var gpuUpdateParticlesVertexShader: {
  71803. name: string;
  71804. shader: string;
  71805. };
  71806. }
  71807. declare module BABYLON {
  71808. /** @hidden */
  71809. export var clipPlaneFragmentDeclaration2: {
  71810. name: string;
  71811. shader: string;
  71812. };
  71813. }
  71814. declare module BABYLON {
  71815. /** @hidden */
  71816. export var gpuRenderParticlesPixelShader: {
  71817. name: string;
  71818. shader: string;
  71819. };
  71820. }
  71821. declare module BABYLON {
  71822. /** @hidden */
  71823. export var clipPlaneVertexDeclaration2: {
  71824. name: string;
  71825. shader: string;
  71826. };
  71827. }
  71828. declare module BABYLON {
  71829. /** @hidden */
  71830. export var gpuRenderParticlesVertexShader: {
  71831. name: string;
  71832. shader: string;
  71833. };
  71834. }
  71835. declare module BABYLON {
  71836. /**
  71837. * This represents a GPU particle system in Babylon
  71838. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71839. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71840. */
  71841. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71842. /**
  71843. * The layer mask we are rendering the particles through.
  71844. */
  71845. layerMask: number;
  71846. private _capacity;
  71847. private _activeCount;
  71848. private _currentActiveCount;
  71849. private _accumulatedCount;
  71850. private _renderEffect;
  71851. private _updateEffect;
  71852. private _buffer0;
  71853. private _buffer1;
  71854. private _spriteBuffer;
  71855. private _updateVAO;
  71856. private _renderVAO;
  71857. private _targetIndex;
  71858. private _sourceBuffer;
  71859. private _targetBuffer;
  71860. private _currentRenderId;
  71861. private _started;
  71862. private _stopped;
  71863. private _timeDelta;
  71864. private _randomTexture;
  71865. private _randomTexture2;
  71866. private _attributesStrideSize;
  71867. private _updateEffectOptions;
  71868. private _randomTextureSize;
  71869. private _actualFrame;
  71870. private _customEffect;
  71871. private readonly _rawTextureWidth;
  71872. /**
  71873. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71874. */
  71875. static get IsSupported(): boolean;
  71876. /**
  71877. * An event triggered when the system is disposed.
  71878. */
  71879. onDisposeObservable: Observable<IParticleSystem>;
  71880. /**
  71881. * An event triggered when the system is stopped
  71882. */
  71883. onStoppedObservable: Observable<IParticleSystem>;
  71884. /**
  71885. * Gets the maximum number of particles active at the same time.
  71886. * @returns The max number of active particles.
  71887. */
  71888. getCapacity(): number;
  71889. /**
  71890. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71891. * to override the particles.
  71892. */
  71893. forceDepthWrite: boolean;
  71894. /**
  71895. * Gets or set the number of active particles
  71896. */
  71897. get activeParticleCount(): number;
  71898. set activeParticleCount(value: number);
  71899. private _preWarmDone;
  71900. /**
  71901. * Specifies if the particles are updated in emitter local space or world space.
  71902. */
  71903. isLocal: boolean;
  71904. /** Gets or sets a matrix to use to compute projection */
  71905. defaultProjectionMatrix: Matrix;
  71906. /**
  71907. * Is this system ready to be used/rendered
  71908. * @return true if the system is ready
  71909. */
  71910. isReady(): boolean;
  71911. /**
  71912. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71913. * @returns True if it has been started, otherwise false.
  71914. */
  71915. isStarted(): boolean;
  71916. /**
  71917. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71918. * @returns True if it has been stopped, otherwise false.
  71919. */
  71920. isStopped(): boolean;
  71921. /**
  71922. * Gets a boolean indicating that the system is stopping
  71923. * @returns true if the system is currently stopping
  71924. */
  71925. isStopping(): boolean;
  71926. /**
  71927. * Gets the number of particles active at the same time.
  71928. * @returns The number of active particles.
  71929. */
  71930. getActiveCount(): number;
  71931. /**
  71932. * Starts the particle system and begins to emit
  71933. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71934. */
  71935. start(delay?: number): void;
  71936. /**
  71937. * Stops the particle system.
  71938. */
  71939. stop(): void;
  71940. /**
  71941. * Remove all active particles
  71942. */
  71943. reset(): void;
  71944. /**
  71945. * Returns the string "GPUParticleSystem"
  71946. * @returns a string containing the class name
  71947. */
  71948. getClassName(): string;
  71949. /**
  71950. * Gets the custom effect used to render the particles
  71951. * @param blendMode Blend mode for which the effect should be retrieved
  71952. * @returns The effect
  71953. */
  71954. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71955. /**
  71956. * Sets the custom effect used to render the particles
  71957. * @param effect The effect to set
  71958. * @param blendMode Blend mode for which the effect should be set
  71959. */
  71960. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71961. /** @hidden */
  71962. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71963. /**
  71964. * Observable that will be called just before the particles are drawn
  71965. */
  71966. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71967. /**
  71968. * Gets the name of the particle vertex shader
  71969. */
  71970. get vertexShaderName(): string;
  71971. private _colorGradientsTexture;
  71972. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71973. /**
  71974. * Adds a new color gradient
  71975. * @param gradient defines the gradient to use (between 0 and 1)
  71976. * @param color1 defines the color to affect to the specified gradient
  71977. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71978. * @returns the current particle system
  71979. */
  71980. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71981. private _refreshColorGradient;
  71982. /** Force the system to rebuild all gradients that need to be resync */
  71983. forceRefreshGradients(): void;
  71984. /**
  71985. * Remove a specific color gradient
  71986. * @param gradient defines the gradient to remove
  71987. * @returns the current particle system
  71988. */
  71989. removeColorGradient(gradient: number): GPUParticleSystem;
  71990. private _angularSpeedGradientsTexture;
  71991. private _sizeGradientsTexture;
  71992. private _velocityGradientsTexture;
  71993. private _limitVelocityGradientsTexture;
  71994. private _dragGradientsTexture;
  71995. private _addFactorGradient;
  71996. /**
  71997. * Adds a new size gradient
  71998. * @param gradient defines the gradient to use (between 0 and 1)
  71999. * @param factor defines the size factor to affect to the specified gradient
  72000. * @returns the current particle system
  72001. */
  72002. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72003. /**
  72004. * Remove a specific size gradient
  72005. * @param gradient defines the gradient to remove
  72006. * @returns the current particle system
  72007. */
  72008. removeSizeGradient(gradient: number): GPUParticleSystem;
  72009. private _refreshFactorGradient;
  72010. /**
  72011. * Adds a new angular speed gradient
  72012. * @param gradient defines the gradient to use (between 0 and 1)
  72013. * @param factor defines the angular speed to affect to the specified gradient
  72014. * @returns the current particle system
  72015. */
  72016. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72017. /**
  72018. * Remove a specific angular speed gradient
  72019. * @param gradient defines the gradient to remove
  72020. * @returns the current particle system
  72021. */
  72022. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72023. /**
  72024. * Adds a new velocity gradient
  72025. * @param gradient defines the gradient to use (between 0 and 1)
  72026. * @param factor defines the velocity to affect to the specified gradient
  72027. * @returns the current particle system
  72028. */
  72029. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72030. /**
  72031. * Remove a specific velocity gradient
  72032. * @param gradient defines the gradient to remove
  72033. * @returns the current particle system
  72034. */
  72035. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72036. /**
  72037. * Adds a new limit velocity gradient
  72038. * @param gradient defines the gradient to use (between 0 and 1)
  72039. * @param factor defines the limit velocity value to affect to the specified gradient
  72040. * @returns the current particle system
  72041. */
  72042. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72043. /**
  72044. * Remove a specific limit velocity gradient
  72045. * @param gradient defines the gradient to remove
  72046. * @returns the current particle system
  72047. */
  72048. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72049. /**
  72050. * Adds a new drag gradient
  72051. * @param gradient defines the gradient to use (between 0 and 1)
  72052. * @param factor defines the drag value to affect to the specified gradient
  72053. * @returns the current particle system
  72054. */
  72055. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72056. /**
  72057. * Remove a specific drag gradient
  72058. * @param gradient defines the gradient to remove
  72059. * @returns the current particle system
  72060. */
  72061. removeDragGradient(gradient: number): GPUParticleSystem;
  72062. /**
  72063. * Not supported by GPUParticleSystem
  72064. * @param gradient defines the gradient to use (between 0 and 1)
  72065. * @param factor defines the emit rate value to affect to the specified gradient
  72066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72067. * @returns the current particle system
  72068. */
  72069. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72070. /**
  72071. * Not supported by GPUParticleSystem
  72072. * @param gradient defines the gradient to remove
  72073. * @returns the current particle system
  72074. */
  72075. removeEmitRateGradient(gradient: number): IParticleSystem;
  72076. /**
  72077. * Not supported by GPUParticleSystem
  72078. * @param gradient defines the gradient to use (between 0 and 1)
  72079. * @param factor defines the start size value to affect to the specified gradient
  72080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72081. * @returns the current particle system
  72082. */
  72083. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72084. /**
  72085. * Not supported by GPUParticleSystem
  72086. * @param gradient defines the gradient to remove
  72087. * @returns the current particle system
  72088. */
  72089. removeStartSizeGradient(gradient: number): IParticleSystem;
  72090. /**
  72091. * Not supported by GPUParticleSystem
  72092. * @param gradient defines the gradient to use (between 0 and 1)
  72093. * @param min defines the color remap minimal range
  72094. * @param max defines the color remap maximal range
  72095. * @returns the current particle system
  72096. */
  72097. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72098. /**
  72099. * Not supported by GPUParticleSystem
  72100. * @param gradient defines the gradient to remove
  72101. * @returns the current particle system
  72102. */
  72103. removeColorRemapGradient(): IParticleSystem;
  72104. /**
  72105. * Not supported by GPUParticleSystem
  72106. * @param gradient defines the gradient to use (between 0 and 1)
  72107. * @param min defines the alpha remap minimal range
  72108. * @param max defines the alpha remap maximal range
  72109. * @returns the current particle system
  72110. */
  72111. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72112. /**
  72113. * Not supported by GPUParticleSystem
  72114. * @param gradient defines the gradient to remove
  72115. * @returns the current particle system
  72116. */
  72117. removeAlphaRemapGradient(): IParticleSystem;
  72118. /**
  72119. * Not supported by GPUParticleSystem
  72120. * @param gradient defines the gradient to use (between 0 and 1)
  72121. * @param color defines the color to affect to the specified gradient
  72122. * @returns the current particle system
  72123. */
  72124. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72125. /**
  72126. * Not supported by GPUParticleSystem
  72127. * @param gradient defines the gradient to remove
  72128. * @returns the current particle system
  72129. */
  72130. removeRampGradient(): IParticleSystem;
  72131. /**
  72132. * Not supported by GPUParticleSystem
  72133. * @returns the list of ramp gradients
  72134. */
  72135. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72136. /**
  72137. * Not supported by GPUParticleSystem
  72138. * Gets or sets a boolean indicating that ramp gradients must be used
  72139. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72140. */
  72141. get useRampGradients(): boolean;
  72142. set useRampGradients(value: boolean);
  72143. /**
  72144. * Not supported by GPUParticleSystem
  72145. * @param gradient defines the gradient to use (between 0 and 1)
  72146. * @param factor defines the life time factor to affect to the specified gradient
  72147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72148. * @returns the current particle system
  72149. */
  72150. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72151. /**
  72152. * Not supported by GPUParticleSystem
  72153. * @param gradient defines the gradient to remove
  72154. * @returns the current particle system
  72155. */
  72156. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72157. /**
  72158. * Instantiates a GPU particle system.
  72159. * 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.
  72160. * @param name The name of the particle system
  72161. * @param options The options used to create the system
  72162. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72163. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72164. * @param customEffect a custom effect used to change the way particles are rendered by default
  72165. */
  72166. constructor(name: string, options: Partial<{
  72167. capacity: number;
  72168. randomTextureSize: number;
  72169. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72170. protected _reset(): void;
  72171. private _createUpdateVAO;
  72172. private _createRenderVAO;
  72173. private _initialize;
  72174. /** @hidden */
  72175. _recreateUpdateEffect(): void;
  72176. private _getEffect;
  72177. /**
  72178. * Fill the defines array according to the current settings of the particle system
  72179. * @param defines Array to be updated
  72180. * @param blendMode blend mode to take into account when updating the array
  72181. */
  72182. fillDefines(defines: Array<string>, blendMode?: number): void;
  72183. /**
  72184. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72185. * @param uniforms Uniforms array to fill
  72186. * @param attributes Attributes array to fill
  72187. * @param samplers Samplers array to fill
  72188. */
  72189. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72190. /** @hidden */
  72191. _recreateRenderEffect(): Effect;
  72192. /**
  72193. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72194. * @param preWarm defines if we are in the pre-warmimg phase
  72195. */
  72196. animate(preWarm?: boolean): void;
  72197. private _createFactorGradientTexture;
  72198. private _createSizeGradientTexture;
  72199. private _createAngularSpeedGradientTexture;
  72200. private _createVelocityGradientTexture;
  72201. private _createLimitVelocityGradientTexture;
  72202. private _createDragGradientTexture;
  72203. private _createColorGradientTexture;
  72204. /**
  72205. * Renders the particle system in its current state
  72206. * @param preWarm defines if the system should only update the particles but not render them
  72207. * @returns the current number of particles
  72208. */
  72209. render(preWarm?: boolean): number;
  72210. /**
  72211. * Rebuilds the particle system
  72212. */
  72213. rebuild(): void;
  72214. private _releaseBuffers;
  72215. private _releaseVAOs;
  72216. /**
  72217. * Disposes the particle system and free the associated resources
  72218. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72219. */
  72220. dispose(disposeTexture?: boolean): void;
  72221. /**
  72222. * Clones the particle system.
  72223. * @param name The name of the cloned object
  72224. * @param newEmitter The new emitter to use
  72225. * @returns the cloned particle system
  72226. */
  72227. clone(name: string, newEmitter: any): GPUParticleSystem;
  72228. /**
  72229. * Serializes the particle system to a JSON object
  72230. * @param serializeTexture defines if the texture must be serialized as well
  72231. * @returns the JSON object
  72232. */
  72233. serialize(serializeTexture?: boolean): any;
  72234. /**
  72235. * Parses a JSON object to create a GPU particle system.
  72236. * @param parsedParticleSystem The JSON object to parse
  72237. * @param sceneOrEngine The scene or the engine to create the particle system in
  72238. * @param rootUrl The root url to use to load external dependencies like texture
  72239. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72240. * @returns the parsed GPU particle system
  72241. */
  72242. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72243. }
  72244. }
  72245. declare module BABYLON {
  72246. /**
  72247. * Represents a set of particle systems working together to create a specific effect
  72248. */
  72249. export class ParticleSystemSet implements IDisposable {
  72250. /**
  72251. * Gets or sets base Assets URL
  72252. */
  72253. static BaseAssetsUrl: string;
  72254. private _emitterCreationOptions;
  72255. private _emitterNode;
  72256. /**
  72257. * Gets the particle system list
  72258. */
  72259. systems: IParticleSystem[];
  72260. /**
  72261. * Gets the emitter node used with this set
  72262. */
  72263. get emitterNode(): Nullable<TransformNode>;
  72264. /**
  72265. * Creates a new emitter mesh as a sphere
  72266. * @param options defines the options used to create the sphere
  72267. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72268. * @param scene defines the hosting scene
  72269. */
  72270. setEmitterAsSphere(options: {
  72271. diameter: number;
  72272. segments: number;
  72273. color: Color3;
  72274. }, renderingGroupId: number, scene: Scene): void;
  72275. /**
  72276. * Starts all particle systems of the set
  72277. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72278. */
  72279. start(emitter?: AbstractMesh): void;
  72280. /**
  72281. * Release all associated resources
  72282. */
  72283. dispose(): void;
  72284. /**
  72285. * Serialize the set into a JSON compatible object
  72286. * @param serializeTexture defines if the texture must be serialized as well
  72287. * @returns a JSON compatible representation of the set
  72288. */
  72289. serialize(serializeTexture?: boolean): any;
  72290. /**
  72291. * Parse a new ParticleSystemSet from a serialized source
  72292. * @param data defines a JSON compatible representation of the set
  72293. * @param scene defines the hosting scene
  72294. * @param gpu defines if we want GPU particles or CPU particles
  72295. * @returns a new ParticleSystemSet
  72296. */
  72297. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72298. }
  72299. }
  72300. declare module BABYLON {
  72301. /**
  72302. * This class is made for on one-liner static method to help creating particle system set.
  72303. */
  72304. export class ParticleHelper {
  72305. /**
  72306. * Gets or sets base Assets URL
  72307. */
  72308. static BaseAssetsUrl: string;
  72309. /** Define the Url to load snippets */
  72310. static SnippetUrl: string;
  72311. /**
  72312. * Create a default particle system that you can tweak
  72313. * @param emitter defines the emitter to use
  72314. * @param capacity defines the system capacity (default is 500 particles)
  72315. * @param scene defines the hosting scene
  72316. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72317. * @returns the new Particle system
  72318. */
  72319. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72320. /**
  72321. * This is the main static method (one-liner) of this helper to create different particle systems
  72322. * @param type This string represents the type to the particle system to create
  72323. * @param scene The scene where the particle system should live
  72324. * @param gpu If the system will use gpu
  72325. * @returns the ParticleSystemSet created
  72326. */
  72327. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72328. /**
  72329. * Static function used to export a particle system to a ParticleSystemSet variable.
  72330. * Please note that the emitter shape is not exported
  72331. * @param systems defines the particle systems to export
  72332. * @returns the created particle system set
  72333. */
  72334. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72335. /**
  72336. * Creates a particle system from a snippet saved in a remote file
  72337. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72338. * @param url defines the url to load from
  72339. * @param scene defines the hosting scene
  72340. * @param gpu If the system will use gpu
  72341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72342. * @returns a promise that will resolve to the new particle system
  72343. */
  72344. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72345. /**
  72346. * Creates a particle system from a snippet saved by the particle system editor
  72347. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72348. * @param scene defines the hosting scene
  72349. * @param gpu If the system will use gpu
  72350. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72351. * @returns a promise that will resolve to the new particle system
  72352. */
  72353. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72354. }
  72355. }
  72356. declare module BABYLON {
  72357. interface Engine {
  72358. /**
  72359. * Create an effect to use with particle systems.
  72360. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72361. * the particle system for which you want to create a custom effect in the last parameter
  72362. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72363. * @param uniformsNames defines a list of attribute names
  72364. * @param samplers defines an array of string used to represent textures
  72365. * @param defines defines the string containing the defines to use to compile the shaders
  72366. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72367. * @param onCompiled defines a function to call when the effect creation is successful
  72368. * @param onError defines a function to call when the effect creation has failed
  72369. * @param particleSystem the particle system you want to create the effect for
  72370. * @returns the new Effect
  72371. */
  72372. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72373. }
  72374. interface Mesh {
  72375. /**
  72376. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72377. * @returns an array of IParticleSystem
  72378. */
  72379. getEmittedParticleSystems(): IParticleSystem[];
  72380. /**
  72381. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72382. * @returns an array of IParticleSystem
  72383. */
  72384. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72385. }
  72386. }
  72387. declare module BABYLON {
  72388. /** Defines the 4 color options */
  72389. export enum PointColor {
  72390. /** color value */
  72391. Color = 2,
  72392. /** uv value */
  72393. UV = 1,
  72394. /** random value */
  72395. Random = 0,
  72396. /** stated value */
  72397. Stated = 3
  72398. }
  72399. /**
  72400. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72401. * 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.
  72402. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72403. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72404. *
  72405. * Full documentation here : TO BE ENTERED
  72406. */
  72407. export class PointsCloudSystem implements IDisposable {
  72408. /**
  72409. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72410. * Example : var p = SPS.particles[i];
  72411. */
  72412. particles: CloudPoint[];
  72413. /**
  72414. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72415. */
  72416. nbParticles: number;
  72417. /**
  72418. * This a counter for your own usage. It's not set by any SPS functions.
  72419. */
  72420. counter: number;
  72421. /**
  72422. * The PCS name. This name is also given to the underlying mesh.
  72423. */
  72424. name: string;
  72425. /**
  72426. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72427. */
  72428. mesh: Mesh;
  72429. /**
  72430. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72431. * Please read :
  72432. */
  72433. vars: any;
  72434. /**
  72435. * @hidden
  72436. */
  72437. _size: number;
  72438. private _scene;
  72439. private _promises;
  72440. private _positions;
  72441. private _indices;
  72442. private _normals;
  72443. private _colors;
  72444. private _uvs;
  72445. private _indices32;
  72446. private _positions32;
  72447. private _colors32;
  72448. private _uvs32;
  72449. private _updatable;
  72450. private _isVisibilityBoxLocked;
  72451. private _alwaysVisible;
  72452. private _groups;
  72453. private _groupCounter;
  72454. private _computeParticleColor;
  72455. private _computeParticleTexture;
  72456. private _computeParticleRotation;
  72457. private _computeBoundingBox;
  72458. private _isReady;
  72459. /**
  72460. * Creates a PCS (Points Cloud System) object
  72461. * @param name (String) is the PCS name, this will be the underlying mesh name
  72462. * @param pointSize (number) is the size for each point
  72463. * @param scene (Scene) is the scene in which the PCS is added
  72464. * @param options defines the options of the PCS e.g.
  72465. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72466. */
  72467. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72468. updatable?: boolean;
  72469. });
  72470. /**
  72471. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72472. * If no points were added to the PCS, the returned mesh is just a single point.
  72473. * @returns a promise for the created mesh
  72474. */
  72475. buildMeshAsync(): Promise<Mesh>;
  72476. /**
  72477. * @hidden
  72478. */
  72479. private _buildMesh;
  72480. private _addParticle;
  72481. private _randomUnitVector;
  72482. private _getColorIndicesForCoord;
  72483. private _setPointsColorOrUV;
  72484. private _colorFromTexture;
  72485. private _calculateDensity;
  72486. /**
  72487. * Adds points to the PCS in random positions within a unit sphere
  72488. * @param nb (positive integer) the number of particles to be created from this model
  72489. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72490. * @returns the number of groups in the system
  72491. */
  72492. addPoints(nb: number, pointFunction?: any): number;
  72493. /**
  72494. * Adds points to the PCS from the surface of the model shape
  72495. * @param mesh is any Mesh object that will be used as a surface model for the points
  72496. * @param nb (positive integer) the number of particles to be created from this model
  72497. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72498. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72499. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72500. * @returns the number of groups in the system
  72501. */
  72502. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72503. /**
  72504. * Adds points to the PCS inside the model shape
  72505. * @param mesh is any Mesh object that will be used as a surface model for the points
  72506. * @param nb (positive integer) the number of particles to be created from this model
  72507. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72508. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72509. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72510. * @returns the number of groups in the system
  72511. */
  72512. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72513. /**
  72514. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72515. * This method calls `updateParticle()` for each particle of the SPS.
  72516. * For an animated SPS, it is usually called within the render loop.
  72517. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72518. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72519. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72520. * @returns the PCS.
  72521. */
  72522. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72523. /**
  72524. * Disposes the PCS.
  72525. */
  72526. dispose(): void;
  72527. /**
  72528. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72529. * doc :
  72530. * @returns the PCS.
  72531. */
  72532. refreshVisibleSize(): PointsCloudSystem;
  72533. /**
  72534. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72535. * @param size the size (float) of the visibility box
  72536. * note : this doesn't lock the PCS mesh bounding box.
  72537. * doc :
  72538. */
  72539. setVisibilityBox(size: number): void;
  72540. /**
  72541. * Gets whether the PCS is always visible or not
  72542. * doc :
  72543. */
  72544. get isAlwaysVisible(): boolean;
  72545. /**
  72546. * Sets the PCS as always visible or not
  72547. * doc :
  72548. */
  72549. set isAlwaysVisible(val: boolean);
  72550. /**
  72551. * Tells to `setParticles()` to compute the particle rotations or not
  72552. * Default value : false. The PCS is faster when it's set to false
  72553. * Note : particle rotations are only applied to parent particles
  72554. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72555. */
  72556. set computeParticleRotation(val: boolean);
  72557. /**
  72558. * Tells to `setParticles()` to compute the particle colors or not.
  72559. * Default value : true. The PCS is faster when it's set to false.
  72560. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72561. */
  72562. set computeParticleColor(val: boolean);
  72563. set computeParticleTexture(val: boolean);
  72564. /**
  72565. * Gets if `setParticles()` computes the particle colors or not.
  72566. * Default value : false. The PCS is faster when it's set to false.
  72567. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72568. */
  72569. get computeParticleColor(): boolean;
  72570. /**
  72571. * Gets if `setParticles()` computes the particle textures or not.
  72572. * Default value : false. The PCS is faster when it's set to false.
  72573. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72574. */
  72575. get computeParticleTexture(): boolean;
  72576. /**
  72577. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72578. */
  72579. set computeBoundingBox(val: boolean);
  72580. /**
  72581. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72582. */
  72583. get computeBoundingBox(): boolean;
  72584. /**
  72585. * This function does nothing. It may be overwritten to set all the particle first values.
  72586. * The PCS doesn't call this function, you may have to call it by your own.
  72587. * doc :
  72588. */
  72589. initParticles(): void;
  72590. /**
  72591. * This function does nothing. It may be overwritten to recycle a particle
  72592. * The PCS doesn't call this function, you can to call it
  72593. * doc :
  72594. * @param particle The particle to recycle
  72595. * @returns the recycled particle
  72596. */
  72597. recycleParticle(particle: CloudPoint): CloudPoint;
  72598. /**
  72599. * Updates a particle : this function should be overwritten by the user.
  72600. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72601. * doc :
  72602. * @example : just set a particle position or velocity and recycle conditions
  72603. * @param particle The particle to update
  72604. * @returns the updated particle
  72605. */
  72606. updateParticle(particle: CloudPoint): CloudPoint;
  72607. /**
  72608. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72609. * This does nothing and may be overwritten by the user.
  72610. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72611. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72612. * @param update the boolean update value actually passed to setParticles()
  72613. */
  72614. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72615. /**
  72616. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72617. * This will be passed three parameters.
  72618. * This does nothing and may be overwritten by the user.
  72619. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72620. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72621. * @param update the boolean update value actually passed to setParticles()
  72622. */
  72623. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72624. }
  72625. }
  72626. declare module BABYLON {
  72627. /**
  72628. * Represents one particle of a points cloud system.
  72629. */
  72630. export class CloudPoint {
  72631. /**
  72632. * particle global index
  72633. */
  72634. idx: number;
  72635. /**
  72636. * The color of the particle
  72637. */
  72638. color: Nullable<Color4>;
  72639. /**
  72640. * The world space position of the particle.
  72641. */
  72642. position: Vector3;
  72643. /**
  72644. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72645. */
  72646. rotation: Vector3;
  72647. /**
  72648. * The world space rotation quaternion of the particle.
  72649. */
  72650. rotationQuaternion: Nullable<Quaternion>;
  72651. /**
  72652. * The uv of the particle.
  72653. */
  72654. uv: Nullable<Vector2>;
  72655. /**
  72656. * The current speed of the particle.
  72657. */
  72658. velocity: Vector3;
  72659. /**
  72660. * The pivot point in the particle local space.
  72661. */
  72662. pivot: Vector3;
  72663. /**
  72664. * Must the particle be translated from its pivot point in its local space ?
  72665. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72666. * Default : false
  72667. */
  72668. translateFromPivot: boolean;
  72669. /**
  72670. * Index of this particle in the global "positions" array (Internal use)
  72671. * @hidden
  72672. */
  72673. _pos: number;
  72674. /**
  72675. * @hidden Index of this particle in the global "indices" array (Internal use)
  72676. */
  72677. _ind: number;
  72678. /**
  72679. * Group this particle belongs to
  72680. */
  72681. _group: PointsGroup;
  72682. /**
  72683. * Group id of this particle
  72684. */
  72685. groupId: number;
  72686. /**
  72687. * Index of the particle in its group id (Internal use)
  72688. */
  72689. idxInGroup: number;
  72690. /**
  72691. * @hidden Particle BoundingInfo object (Internal use)
  72692. */
  72693. _boundingInfo: BoundingInfo;
  72694. /**
  72695. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72696. */
  72697. _pcs: PointsCloudSystem;
  72698. /**
  72699. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72700. */
  72701. _stillInvisible: boolean;
  72702. /**
  72703. * @hidden Last computed particle rotation matrix
  72704. */
  72705. _rotationMatrix: number[];
  72706. /**
  72707. * Parent particle Id, if any.
  72708. * Default null.
  72709. */
  72710. parentId: Nullable<number>;
  72711. /**
  72712. * @hidden Internal global position in the PCS.
  72713. */
  72714. _globalPosition: Vector3;
  72715. /**
  72716. * Creates a Point Cloud object.
  72717. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72718. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72719. * @param group (PointsGroup) is the group the particle belongs to
  72720. * @param groupId (integer) is the group identifier in the PCS.
  72721. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72722. * @param pcs defines the PCS it is associated to
  72723. */
  72724. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72725. /**
  72726. * get point size
  72727. */
  72728. get size(): Vector3;
  72729. /**
  72730. * Set point size
  72731. */
  72732. set size(scale: Vector3);
  72733. /**
  72734. * Legacy support, changed quaternion to rotationQuaternion
  72735. */
  72736. get quaternion(): Nullable<Quaternion>;
  72737. /**
  72738. * Legacy support, changed quaternion to rotationQuaternion
  72739. */
  72740. set quaternion(q: Nullable<Quaternion>);
  72741. /**
  72742. * Returns a boolean. True if the particle intersects a mesh, else false
  72743. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72744. * @param target is the object (point or mesh) what the intersection is computed against
  72745. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72746. * @returns true if it intersects
  72747. */
  72748. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72749. /**
  72750. * get the rotation matrix of the particle
  72751. * @hidden
  72752. */
  72753. getRotationMatrix(m: Matrix): void;
  72754. }
  72755. /**
  72756. * Represents a group of points in a points cloud system
  72757. * * PCS internal tool, don't use it manually.
  72758. */
  72759. export class PointsGroup {
  72760. /**
  72761. * The group id
  72762. * @hidden
  72763. */
  72764. groupID: number;
  72765. /**
  72766. * image data for group (internal use)
  72767. * @hidden
  72768. */
  72769. _groupImageData: Nullable<ArrayBufferView>;
  72770. /**
  72771. * Image Width (internal use)
  72772. * @hidden
  72773. */
  72774. _groupImgWidth: number;
  72775. /**
  72776. * Image Height (internal use)
  72777. * @hidden
  72778. */
  72779. _groupImgHeight: number;
  72780. /**
  72781. * Custom position function (internal use)
  72782. * @hidden
  72783. */
  72784. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72785. /**
  72786. * density per facet for surface points
  72787. * @hidden
  72788. */
  72789. _groupDensity: number[];
  72790. /**
  72791. * Only when points are colored by texture carries pointer to texture list array
  72792. * @hidden
  72793. */
  72794. _textureNb: number;
  72795. /**
  72796. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72797. * PCS internal tool, don't use it manually.
  72798. * @hidden
  72799. */
  72800. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72801. }
  72802. }
  72803. declare module BABYLON {
  72804. interface Scene {
  72805. /** @hidden (Backing field) */
  72806. _physicsEngine: Nullable<IPhysicsEngine>;
  72807. /** @hidden */
  72808. _physicsTimeAccumulator: number;
  72809. /**
  72810. * Gets the current physics engine
  72811. * @returns a IPhysicsEngine or null if none attached
  72812. */
  72813. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72814. /**
  72815. * Enables physics to the current scene
  72816. * @param gravity defines the scene's gravity for the physics engine
  72817. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72818. * @return a boolean indicating if the physics engine was initialized
  72819. */
  72820. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72821. /**
  72822. * Disables and disposes the physics engine associated with the scene
  72823. */
  72824. disablePhysicsEngine(): void;
  72825. /**
  72826. * Gets a boolean indicating if there is an active physics engine
  72827. * @returns a boolean indicating if there is an active physics engine
  72828. */
  72829. isPhysicsEnabled(): boolean;
  72830. /**
  72831. * Deletes a physics compound impostor
  72832. * @param compound defines the compound to delete
  72833. */
  72834. deleteCompoundImpostor(compound: any): void;
  72835. /**
  72836. * An event triggered when physic simulation is about to be run
  72837. */
  72838. onBeforePhysicsObservable: Observable<Scene>;
  72839. /**
  72840. * An event triggered when physic simulation has been done
  72841. */
  72842. onAfterPhysicsObservable: Observable<Scene>;
  72843. }
  72844. interface AbstractMesh {
  72845. /** @hidden */
  72846. _physicsImpostor: Nullable<PhysicsImpostor>;
  72847. /**
  72848. * Gets or sets impostor used for physic simulation
  72849. * @see https://doc.babylonjs.com/features/physics_engine
  72850. */
  72851. physicsImpostor: Nullable<PhysicsImpostor>;
  72852. /**
  72853. * Gets the current physics impostor
  72854. * @see https://doc.babylonjs.com/features/physics_engine
  72855. * @returns a physics impostor or null
  72856. */
  72857. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72858. /** Apply a physic impulse to the mesh
  72859. * @param force defines the force to apply
  72860. * @param contactPoint defines where to apply the force
  72861. * @returns the current mesh
  72862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72863. */
  72864. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72865. /**
  72866. * Creates a physic joint between two meshes
  72867. * @param otherMesh defines the other mesh to use
  72868. * @param pivot1 defines the pivot to use on this mesh
  72869. * @param pivot2 defines the pivot to use on the other mesh
  72870. * @param options defines additional options (can be plugin dependent)
  72871. * @returns the current mesh
  72872. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72873. */
  72874. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72875. /** @hidden */
  72876. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72877. }
  72878. /**
  72879. * Defines the physics engine scene component responsible to manage a physics engine
  72880. */
  72881. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72882. /**
  72883. * The component name helpful to identify the component in the list of scene components.
  72884. */
  72885. readonly name: string;
  72886. /**
  72887. * The scene the component belongs to.
  72888. */
  72889. scene: Scene;
  72890. /**
  72891. * Creates a new instance of the component for the given scene
  72892. * @param scene Defines the scene to register the component in
  72893. */
  72894. constructor(scene: Scene);
  72895. /**
  72896. * Registers the component in a given scene
  72897. */
  72898. register(): void;
  72899. /**
  72900. * Rebuilds the elements related to this component in case of
  72901. * context lost for instance.
  72902. */
  72903. rebuild(): void;
  72904. /**
  72905. * Disposes the component and the associated ressources
  72906. */
  72907. dispose(): void;
  72908. }
  72909. }
  72910. declare module BABYLON {
  72911. /**
  72912. * A helper for physics simulations
  72913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72914. */
  72915. export class PhysicsHelper {
  72916. private _scene;
  72917. private _physicsEngine;
  72918. /**
  72919. * Initializes the Physics helper
  72920. * @param scene Babylon.js scene
  72921. */
  72922. constructor(scene: Scene);
  72923. /**
  72924. * Applies a radial explosion impulse
  72925. * @param origin the origin of the explosion
  72926. * @param radiusOrEventOptions the radius or the options of radial explosion
  72927. * @param strength the explosion strength
  72928. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72929. * @returns A physics radial explosion event, or null
  72930. */
  72931. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72932. /**
  72933. * Applies a radial explosion force
  72934. * @param origin the origin of the explosion
  72935. * @param radiusOrEventOptions the radius or the options of radial explosion
  72936. * @param strength the explosion strength
  72937. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72938. * @returns A physics radial explosion event, or null
  72939. */
  72940. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72941. /**
  72942. * Creates a gravitational field
  72943. * @param origin the origin of the explosion
  72944. * @param radiusOrEventOptions the radius or the options of radial explosion
  72945. * @param strength the explosion strength
  72946. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72947. * @returns A physics gravitational field event, or null
  72948. */
  72949. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72950. /**
  72951. * Creates a physics updraft event
  72952. * @param origin the origin of the updraft
  72953. * @param radiusOrEventOptions the radius or the options of the updraft
  72954. * @param strength the strength of the updraft
  72955. * @param height the height of the updraft
  72956. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72957. * @returns A physics updraft event, or null
  72958. */
  72959. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72960. /**
  72961. * Creates a physics vortex event
  72962. * @param origin the of the vortex
  72963. * @param radiusOrEventOptions the radius or the options of the vortex
  72964. * @param strength the strength of the vortex
  72965. * @param height the height of the vortex
  72966. * @returns a Physics vortex event, or null
  72967. * A physics vortex event or null
  72968. */
  72969. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72970. }
  72971. /**
  72972. * Represents a physics radial explosion event
  72973. */
  72974. class PhysicsRadialExplosionEvent {
  72975. private _scene;
  72976. private _options;
  72977. private _sphere;
  72978. private _dataFetched;
  72979. /**
  72980. * Initializes a radial explosioin event
  72981. * @param _scene BabylonJS scene
  72982. * @param _options The options for the vortex event
  72983. */
  72984. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72985. /**
  72986. * Returns the data related to the radial explosion event (sphere).
  72987. * @returns The radial explosion event data
  72988. */
  72989. getData(): PhysicsRadialExplosionEventData;
  72990. /**
  72991. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72992. * @param impostor A physics imposter
  72993. * @param origin the origin of the explosion
  72994. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72995. */
  72996. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72997. /**
  72998. * Triggers affecterd impostors callbacks
  72999. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73000. */
  73001. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73002. /**
  73003. * Disposes the sphere.
  73004. * @param force Specifies if the sphere should be disposed by force
  73005. */
  73006. dispose(force?: boolean): void;
  73007. /*** Helpers ***/
  73008. private _prepareSphere;
  73009. private _intersectsWithSphere;
  73010. }
  73011. /**
  73012. * Represents a gravitational field event
  73013. */
  73014. class PhysicsGravitationalFieldEvent {
  73015. private _physicsHelper;
  73016. private _scene;
  73017. private _origin;
  73018. private _options;
  73019. private _tickCallback;
  73020. private _sphere;
  73021. private _dataFetched;
  73022. /**
  73023. * Initializes the physics gravitational field event
  73024. * @param _physicsHelper A physics helper
  73025. * @param _scene BabylonJS scene
  73026. * @param _origin The origin position of the gravitational field event
  73027. * @param _options The options for the vortex event
  73028. */
  73029. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73030. /**
  73031. * Returns the data related to the gravitational field event (sphere).
  73032. * @returns A gravitational field event
  73033. */
  73034. getData(): PhysicsGravitationalFieldEventData;
  73035. /**
  73036. * Enables the gravitational field.
  73037. */
  73038. enable(): void;
  73039. /**
  73040. * Disables the gravitational field.
  73041. */
  73042. disable(): void;
  73043. /**
  73044. * Disposes the sphere.
  73045. * @param force The force to dispose from the gravitational field event
  73046. */
  73047. dispose(force?: boolean): void;
  73048. private _tick;
  73049. }
  73050. /**
  73051. * Represents a physics updraft event
  73052. */
  73053. class PhysicsUpdraftEvent {
  73054. private _scene;
  73055. private _origin;
  73056. private _options;
  73057. private _physicsEngine;
  73058. private _originTop;
  73059. private _originDirection;
  73060. private _tickCallback;
  73061. private _cylinder;
  73062. private _cylinderPosition;
  73063. private _dataFetched;
  73064. /**
  73065. * Initializes the physics updraft event
  73066. * @param _scene BabylonJS scene
  73067. * @param _origin The origin position of the updraft
  73068. * @param _options The options for the updraft event
  73069. */
  73070. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73071. /**
  73072. * Returns the data related to the updraft event (cylinder).
  73073. * @returns A physics updraft event
  73074. */
  73075. getData(): PhysicsUpdraftEventData;
  73076. /**
  73077. * Enables the updraft.
  73078. */
  73079. enable(): void;
  73080. /**
  73081. * Disables the updraft.
  73082. */
  73083. disable(): void;
  73084. /**
  73085. * Disposes the cylinder.
  73086. * @param force Specifies if the updraft should be disposed by force
  73087. */
  73088. dispose(force?: boolean): void;
  73089. private getImpostorHitData;
  73090. private _tick;
  73091. /*** Helpers ***/
  73092. private _prepareCylinder;
  73093. private _intersectsWithCylinder;
  73094. }
  73095. /**
  73096. * Represents a physics vortex event
  73097. */
  73098. class PhysicsVortexEvent {
  73099. private _scene;
  73100. private _origin;
  73101. private _options;
  73102. private _physicsEngine;
  73103. private _originTop;
  73104. private _tickCallback;
  73105. private _cylinder;
  73106. private _cylinderPosition;
  73107. private _dataFetched;
  73108. /**
  73109. * Initializes the physics vortex event
  73110. * @param _scene The BabylonJS scene
  73111. * @param _origin The origin position of the vortex
  73112. * @param _options The options for the vortex event
  73113. */
  73114. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73115. /**
  73116. * Returns the data related to the vortex event (cylinder).
  73117. * @returns The physics vortex event data
  73118. */
  73119. getData(): PhysicsVortexEventData;
  73120. /**
  73121. * Enables the vortex.
  73122. */
  73123. enable(): void;
  73124. /**
  73125. * Disables the cortex.
  73126. */
  73127. disable(): void;
  73128. /**
  73129. * Disposes the sphere.
  73130. * @param force
  73131. */
  73132. dispose(force?: boolean): void;
  73133. private getImpostorHitData;
  73134. private _tick;
  73135. /*** Helpers ***/
  73136. private _prepareCylinder;
  73137. private _intersectsWithCylinder;
  73138. }
  73139. /**
  73140. * Options fot the radial explosion event
  73141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73142. */
  73143. export class PhysicsRadialExplosionEventOptions {
  73144. /**
  73145. * The radius of the sphere for the radial explosion.
  73146. */
  73147. radius: number;
  73148. /**
  73149. * The strenth of the explosion.
  73150. */
  73151. strength: number;
  73152. /**
  73153. * The strenght of the force in correspondence to the distance of the affected object
  73154. */
  73155. falloff: PhysicsRadialImpulseFalloff;
  73156. /**
  73157. * Sphere options for the radial explosion.
  73158. */
  73159. sphere: {
  73160. segments: number;
  73161. diameter: number;
  73162. };
  73163. /**
  73164. * Sphere options for the radial explosion.
  73165. */
  73166. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73167. }
  73168. /**
  73169. * Options fot the updraft event
  73170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73171. */
  73172. export class PhysicsUpdraftEventOptions {
  73173. /**
  73174. * The radius of the cylinder for the vortex
  73175. */
  73176. radius: number;
  73177. /**
  73178. * The strenth of the updraft.
  73179. */
  73180. strength: number;
  73181. /**
  73182. * The height of the cylinder for the updraft.
  73183. */
  73184. height: number;
  73185. /**
  73186. * The mode for the the updraft.
  73187. */
  73188. updraftMode: PhysicsUpdraftMode;
  73189. }
  73190. /**
  73191. * Options fot the vortex event
  73192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73193. */
  73194. export class PhysicsVortexEventOptions {
  73195. /**
  73196. * The radius of the cylinder for the vortex
  73197. */
  73198. radius: number;
  73199. /**
  73200. * The strenth of the vortex.
  73201. */
  73202. strength: number;
  73203. /**
  73204. * The height of the cylinder for the vortex.
  73205. */
  73206. height: number;
  73207. /**
  73208. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73209. */
  73210. centripetalForceThreshold: number;
  73211. /**
  73212. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73213. */
  73214. centripetalForceMultiplier: number;
  73215. /**
  73216. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73217. */
  73218. centrifugalForceMultiplier: number;
  73219. /**
  73220. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73221. */
  73222. updraftForceMultiplier: number;
  73223. }
  73224. /**
  73225. * The strenght of the force in correspondence to the distance of the affected object
  73226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73227. */
  73228. export enum PhysicsRadialImpulseFalloff {
  73229. /** Defines that impulse is constant in strength across it's whole radius */
  73230. Constant = 0,
  73231. /** Defines that impulse gets weaker if it's further from the origin */
  73232. Linear = 1
  73233. }
  73234. /**
  73235. * The strength of the force in correspondence to the distance of the affected object
  73236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73237. */
  73238. export enum PhysicsUpdraftMode {
  73239. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73240. Center = 0,
  73241. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73242. Perpendicular = 1
  73243. }
  73244. /**
  73245. * Interface for a physics hit data
  73246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73247. */
  73248. export interface PhysicsHitData {
  73249. /**
  73250. * The force applied at the contact point
  73251. */
  73252. force: Vector3;
  73253. /**
  73254. * The contact point
  73255. */
  73256. contactPoint: Vector3;
  73257. /**
  73258. * The distance from the origin to the contact point
  73259. */
  73260. distanceFromOrigin: number;
  73261. }
  73262. /**
  73263. * Interface for radial explosion event data
  73264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73265. */
  73266. export interface PhysicsRadialExplosionEventData {
  73267. /**
  73268. * A sphere used for the radial explosion event
  73269. */
  73270. sphere: Mesh;
  73271. }
  73272. /**
  73273. * Interface for gravitational field event data
  73274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73275. */
  73276. export interface PhysicsGravitationalFieldEventData {
  73277. /**
  73278. * A sphere mesh used for the gravitational field event
  73279. */
  73280. sphere: Mesh;
  73281. }
  73282. /**
  73283. * Interface for updraft event data
  73284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73285. */
  73286. export interface PhysicsUpdraftEventData {
  73287. /**
  73288. * A cylinder used for the updraft event
  73289. */
  73290. cylinder: Mesh;
  73291. }
  73292. /**
  73293. * Interface for vortex event data
  73294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73295. */
  73296. export interface PhysicsVortexEventData {
  73297. /**
  73298. * A cylinder used for the vortex event
  73299. */
  73300. cylinder: Mesh;
  73301. }
  73302. /**
  73303. * Interface for an affected physics impostor
  73304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73305. */
  73306. export interface PhysicsAffectedImpostorWithData {
  73307. /**
  73308. * The impostor affected by the effect
  73309. */
  73310. impostor: PhysicsImpostor;
  73311. /**
  73312. * The data about the hit/horce from the explosion
  73313. */
  73314. hitData: PhysicsHitData;
  73315. }
  73316. }
  73317. declare module BABYLON {
  73318. /** @hidden */
  73319. export var blackAndWhitePixelShader: {
  73320. name: string;
  73321. shader: string;
  73322. };
  73323. }
  73324. declare module BABYLON {
  73325. /**
  73326. * Post process used to render in black and white
  73327. */
  73328. export class BlackAndWhitePostProcess extends PostProcess {
  73329. /**
  73330. * Linear about to convert he result to black and white (default: 1)
  73331. */
  73332. degree: number;
  73333. /**
  73334. * Gets a string identifying the name of the class
  73335. * @returns "BlackAndWhitePostProcess" string
  73336. */
  73337. getClassName(): string;
  73338. /**
  73339. * Creates a black and white post process
  73340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73341. * @param name The name of the effect.
  73342. * @param options The required width/height ratio to downsize to before computing the render pass.
  73343. * @param camera The camera to apply the render pass to.
  73344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73345. * @param engine The engine which the post process will be applied. (default: current engine)
  73346. * @param reusable If the post process can be reused on the same frame. (default: false)
  73347. */
  73348. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73349. /** @hidden */
  73350. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73351. }
  73352. }
  73353. declare module BABYLON {
  73354. /**
  73355. * This represents a set of one or more post processes in Babylon.
  73356. * A post process can be used to apply a shader to a texture after it is rendered.
  73357. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73358. */
  73359. export class PostProcessRenderEffect {
  73360. private _postProcesses;
  73361. private _getPostProcesses;
  73362. private _singleInstance;
  73363. private _cameras;
  73364. private _indicesForCamera;
  73365. /**
  73366. * Name of the effect
  73367. * @hidden
  73368. */
  73369. _name: string;
  73370. /**
  73371. * Instantiates a post process render effect.
  73372. * A post process can be used to apply a shader to a texture after it is rendered.
  73373. * @param engine The engine the effect is tied to
  73374. * @param name The name of the effect
  73375. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73376. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73377. */
  73378. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73379. /**
  73380. * Checks if all the post processes in the effect are supported.
  73381. */
  73382. get isSupported(): boolean;
  73383. /**
  73384. * Updates the current state of the effect
  73385. * @hidden
  73386. */
  73387. _update(): void;
  73388. /**
  73389. * Attaches the effect on cameras
  73390. * @param cameras The camera to attach to.
  73391. * @hidden
  73392. */
  73393. _attachCameras(cameras: Camera): void;
  73394. /**
  73395. * Attaches the effect on cameras
  73396. * @param cameras The camera to attach to.
  73397. * @hidden
  73398. */
  73399. _attachCameras(cameras: Camera[]): void;
  73400. /**
  73401. * Detaches the effect on cameras
  73402. * @param cameras The camera to detatch from.
  73403. * @hidden
  73404. */
  73405. _detachCameras(cameras: Camera): void;
  73406. /**
  73407. * Detatches the effect on cameras
  73408. * @param cameras The camera to detatch from.
  73409. * @hidden
  73410. */
  73411. _detachCameras(cameras: Camera[]): void;
  73412. /**
  73413. * Enables the effect on given cameras
  73414. * @param cameras The camera to enable.
  73415. * @hidden
  73416. */
  73417. _enable(cameras: Camera): void;
  73418. /**
  73419. * Enables the effect on given cameras
  73420. * @param cameras The camera to enable.
  73421. * @hidden
  73422. */
  73423. _enable(cameras: Nullable<Camera[]>): void;
  73424. /**
  73425. * Disables the effect on the given cameras
  73426. * @param cameras The camera to disable.
  73427. * @hidden
  73428. */
  73429. _disable(cameras: Camera): void;
  73430. /**
  73431. * Disables the effect on the given cameras
  73432. * @param cameras The camera to disable.
  73433. * @hidden
  73434. */
  73435. _disable(cameras: Nullable<Camera[]>): void;
  73436. /**
  73437. * Gets a list of the post processes contained in the effect.
  73438. * @param camera The camera to get the post processes on.
  73439. * @returns The list of the post processes in the effect.
  73440. */
  73441. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /** @hidden */
  73446. export var extractHighlightsPixelShader: {
  73447. name: string;
  73448. shader: string;
  73449. };
  73450. }
  73451. declare module BABYLON {
  73452. /**
  73453. * 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.
  73454. */
  73455. export class ExtractHighlightsPostProcess extends PostProcess {
  73456. /**
  73457. * The luminance threshold, pixels below this value will be set to black.
  73458. */
  73459. threshold: number;
  73460. /** @hidden */
  73461. _exposure: number;
  73462. /**
  73463. * Post process which has the input texture to be used when performing highlight extraction
  73464. * @hidden
  73465. */
  73466. _inputPostProcess: Nullable<PostProcess>;
  73467. /**
  73468. * Gets a string identifying the name of the class
  73469. * @returns "ExtractHighlightsPostProcess" string
  73470. */
  73471. getClassName(): string;
  73472. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73473. }
  73474. }
  73475. declare module BABYLON {
  73476. /** @hidden */
  73477. export var bloomMergePixelShader: {
  73478. name: string;
  73479. shader: string;
  73480. };
  73481. }
  73482. declare module BABYLON {
  73483. /**
  73484. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73485. */
  73486. export class BloomMergePostProcess extends PostProcess {
  73487. /** Weight of the bloom to be added to the original input. */
  73488. weight: number;
  73489. /**
  73490. * Gets a string identifying the name of the class
  73491. * @returns "BloomMergePostProcess" string
  73492. */
  73493. getClassName(): string;
  73494. /**
  73495. * Creates a new instance of @see BloomMergePostProcess
  73496. * @param name The name of the effect.
  73497. * @param originalFromInput Post process which's input will be used for the merge.
  73498. * @param blurred Blurred highlights post process which's output will be used.
  73499. * @param weight Weight of the bloom to be added to the original input.
  73500. * @param options The required width/height ratio to downsize to before computing the render pass.
  73501. * @param camera The camera to apply the render pass to.
  73502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73503. * @param engine The engine which the post process will be applied. (default: current engine)
  73504. * @param reusable If the post process can be reused on the same frame. (default: false)
  73505. * @param textureType Type of textures used when performing the post process. (default: 0)
  73506. * @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)
  73507. */
  73508. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73509. /** Weight of the bloom to be added to the original input. */
  73510. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73511. }
  73512. }
  73513. declare module BABYLON {
  73514. /**
  73515. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73516. */
  73517. export class BloomEffect extends PostProcessRenderEffect {
  73518. private bloomScale;
  73519. /**
  73520. * @hidden Internal
  73521. */
  73522. _effects: Array<PostProcess>;
  73523. /**
  73524. * @hidden Internal
  73525. */
  73526. _downscale: ExtractHighlightsPostProcess;
  73527. private _blurX;
  73528. private _blurY;
  73529. private _merge;
  73530. /**
  73531. * The luminance threshold to find bright areas of the image to bloom.
  73532. */
  73533. get threshold(): number;
  73534. set threshold(value: number);
  73535. /**
  73536. * The strength of the bloom.
  73537. */
  73538. get weight(): number;
  73539. set weight(value: number);
  73540. /**
  73541. * Specifies the size of the bloom blur kernel, relative to the final output size
  73542. */
  73543. get kernel(): number;
  73544. set kernel(value: number);
  73545. /**
  73546. * Creates a new instance of @see BloomEffect
  73547. * @param scene The scene the effect belongs to.
  73548. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73549. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73550. * @param bloomWeight The the strength of bloom.
  73551. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73552. * @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)
  73553. */
  73554. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73555. /**
  73556. * Disposes each of the internal effects for a given camera.
  73557. * @param camera The camera to dispose the effect on.
  73558. */
  73559. disposeEffects(camera: Camera): void;
  73560. /**
  73561. * @hidden Internal
  73562. */
  73563. _updateEffects(): void;
  73564. /**
  73565. * Internal
  73566. * @returns if all the contained post processes are ready.
  73567. * @hidden
  73568. */
  73569. _isReady(): boolean;
  73570. }
  73571. }
  73572. declare module BABYLON {
  73573. /** @hidden */
  73574. export var chromaticAberrationPixelShader: {
  73575. name: string;
  73576. shader: string;
  73577. };
  73578. }
  73579. declare module BABYLON {
  73580. /**
  73581. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73582. */
  73583. export class ChromaticAberrationPostProcess extends PostProcess {
  73584. /**
  73585. * The amount of seperation of rgb channels (default: 30)
  73586. */
  73587. aberrationAmount: number;
  73588. /**
  73589. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73590. */
  73591. radialIntensity: number;
  73592. /**
  73593. * 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))
  73594. */
  73595. direction: Vector2;
  73596. /**
  73597. * 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))
  73598. */
  73599. centerPosition: Vector2;
  73600. /** The width of the screen to apply the effect on */
  73601. screenWidth: number;
  73602. /** The height of the screen to apply the effect on */
  73603. screenHeight: number;
  73604. /**
  73605. * Gets a string identifying the name of the class
  73606. * @returns "ChromaticAberrationPostProcess" string
  73607. */
  73608. getClassName(): string;
  73609. /**
  73610. * Creates a new instance ChromaticAberrationPostProcess
  73611. * @param name The name of the effect.
  73612. * @param screenWidth The width of the screen to apply the effect on.
  73613. * @param screenHeight The height of the screen to apply the effect on.
  73614. * @param options The required width/height ratio to downsize to before computing the render pass.
  73615. * @param camera The camera to apply the render pass to.
  73616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73617. * @param engine The engine which the post process will be applied. (default: current engine)
  73618. * @param reusable If the post process can be reused on the same frame. (default: false)
  73619. * @param textureType Type of textures used when performing the post process. (default: 0)
  73620. * @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)
  73621. */
  73622. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73623. /** @hidden */
  73624. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73625. }
  73626. }
  73627. declare module BABYLON {
  73628. /** @hidden */
  73629. export var circleOfConfusionPixelShader: {
  73630. name: string;
  73631. shader: string;
  73632. };
  73633. }
  73634. declare module BABYLON {
  73635. /**
  73636. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73637. */
  73638. export class CircleOfConfusionPostProcess extends PostProcess {
  73639. /**
  73640. * 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.
  73641. */
  73642. lensSize: number;
  73643. /**
  73644. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73645. */
  73646. fStop: number;
  73647. /**
  73648. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73649. */
  73650. focusDistance: number;
  73651. /**
  73652. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73653. */
  73654. focalLength: number;
  73655. /**
  73656. * Gets a string identifying the name of the class
  73657. * @returns "CircleOfConfusionPostProcess" string
  73658. */
  73659. getClassName(): string;
  73660. private _depthTexture;
  73661. /**
  73662. * Creates a new instance CircleOfConfusionPostProcess
  73663. * @param name The name of the effect.
  73664. * @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.
  73665. * @param options The required width/height ratio to downsize to before computing the render pass.
  73666. * @param camera The camera to apply the render pass to.
  73667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73668. * @param engine The engine which the post process will be applied. (default: current engine)
  73669. * @param reusable If the post process can be reused on the same frame. (default: false)
  73670. * @param textureType Type of textures used when performing the post process. (default: 0)
  73671. * @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)
  73672. */
  73673. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73674. /**
  73675. * 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.
  73676. */
  73677. set depthTexture(value: RenderTargetTexture);
  73678. }
  73679. }
  73680. declare module BABYLON {
  73681. /** @hidden */
  73682. export var colorCorrectionPixelShader: {
  73683. name: string;
  73684. shader: string;
  73685. };
  73686. }
  73687. declare module BABYLON {
  73688. /**
  73689. *
  73690. * This post-process allows the modification of rendered colors by using
  73691. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73692. *
  73693. * The object needs to be provided an url to a texture containing the color
  73694. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73695. * Use an image editing software to tweak the LUT to match your needs.
  73696. *
  73697. * For an example of a color LUT, see here:
  73698. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73699. * For explanations on color grading, see here:
  73700. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73701. *
  73702. */
  73703. export class ColorCorrectionPostProcess extends PostProcess {
  73704. private _colorTableTexture;
  73705. /**
  73706. * Gets the color table url used to create the LUT texture
  73707. */
  73708. colorTableUrl: string;
  73709. /**
  73710. * Gets a string identifying the name of the class
  73711. * @returns "ColorCorrectionPostProcess" string
  73712. */
  73713. getClassName(): string;
  73714. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73715. /** @hidden */
  73716. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73717. }
  73718. }
  73719. declare module BABYLON {
  73720. /** @hidden */
  73721. export var convolutionPixelShader: {
  73722. name: string;
  73723. shader: string;
  73724. };
  73725. }
  73726. declare module BABYLON {
  73727. /**
  73728. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73729. * input texture to perform effects such as edge detection or sharpening
  73730. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73731. */
  73732. export class ConvolutionPostProcess extends PostProcess {
  73733. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73734. kernel: number[];
  73735. /**
  73736. * Gets a string identifying the name of the class
  73737. * @returns "ConvolutionPostProcess" string
  73738. */
  73739. getClassName(): string;
  73740. /**
  73741. * Creates a new instance ConvolutionPostProcess
  73742. * @param name The name of the effect.
  73743. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73744. * @param options The required width/height ratio to downsize to before computing the render pass.
  73745. * @param camera The camera to apply the render pass to.
  73746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73747. * @param engine The engine which the post process will be applied. (default: current engine)
  73748. * @param reusable If the post process can be reused on the same frame. (default: false)
  73749. * @param textureType Type of textures used when performing the post process. (default: 0)
  73750. */
  73751. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73752. /** @hidden */
  73753. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73754. /**
  73755. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73756. */
  73757. static EdgeDetect0Kernel: number[];
  73758. /**
  73759. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73760. */
  73761. static EdgeDetect1Kernel: number[];
  73762. /**
  73763. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73764. */
  73765. static EdgeDetect2Kernel: number[];
  73766. /**
  73767. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73768. */
  73769. static SharpenKernel: number[];
  73770. /**
  73771. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73772. */
  73773. static EmbossKernel: number[];
  73774. /**
  73775. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73776. */
  73777. static GaussianKernel: number[];
  73778. }
  73779. }
  73780. declare module BABYLON {
  73781. /**
  73782. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73783. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73784. * based on samples that have a large difference in distance than the center pixel.
  73785. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73786. */
  73787. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73788. /**
  73789. * The direction the blur should be applied
  73790. */
  73791. direction: Vector2;
  73792. /**
  73793. * Gets a string identifying the name of the class
  73794. * @returns "DepthOfFieldBlurPostProcess" string
  73795. */
  73796. getClassName(): string;
  73797. /**
  73798. * Creates a new instance CircleOfConfusionPostProcess
  73799. * @param name The name of the effect.
  73800. * @param scene The scene the effect belongs to.
  73801. * @param direction The direction the blur should be applied.
  73802. * @param kernel The size of the kernel used to blur.
  73803. * @param options The required width/height ratio to downsize to before computing the render pass.
  73804. * @param camera The camera to apply the render pass to.
  73805. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73806. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73808. * @param engine The engine which the post process will be applied. (default: current engine)
  73809. * @param reusable If the post process can be reused on the same frame. (default: false)
  73810. * @param textureType Type of textures used when performing the post process. (default: 0)
  73811. * @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)
  73812. */
  73813. 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);
  73814. }
  73815. }
  73816. declare module BABYLON {
  73817. /** @hidden */
  73818. export var depthOfFieldMergePixelShader: {
  73819. name: string;
  73820. shader: string;
  73821. };
  73822. }
  73823. declare module BABYLON {
  73824. /**
  73825. * Options to be set when merging outputs from the default pipeline.
  73826. */
  73827. export class DepthOfFieldMergePostProcessOptions {
  73828. /**
  73829. * The original image to merge on top of
  73830. */
  73831. originalFromInput: PostProcess;
  73832. /**
  73833. * Parameters to perform the merge of the depth of field effect
  73834. */
  73835. depthOfField?: {
  73836. circleOfConfusion: PostProcess;
  73837. blurSteps: Array<PostProcess>;
  73838. };
  73839. /**
  73840. * Parameters to perform the merge of bloom effect
  73841. */
  73842. bloom?: {
  73843. blurred: PostProcess;
  73844. weight: number;
  73845. };
  73846. }
  73847. /**
  73848. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73849. */
  73850. export class DepthOfFieldMergePostProcess extends PostProcess {
  73851. private blurSteps;
  73852. /**
  73853. * Gets a string identifying the name of the class
  73854. * @returns "DepthOfFieldMergePostProcess" string
  73855. */
  73856. getClassName(): string;
  73857. /**
  73858. * Creates a new instance of DepthOfFieldMergePostProcess
  73859. * @param name The name of the effect.
  73860. * @param originalFromInput Post process which's input will be used for the merge.
  73861. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73862. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73863. * @param options The required width/height ratio to downsize to before computing the render pass.
  73864. * @param camera The camera to apply the render pass to.
  73865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73866. * @param engine The engine which the post process will be applied. (default: current engine)
  73867. * @param reusable If the post process can be reused on the same frame. (default: false)
  73868. * @param textureType Type of textures used when performing the post process. (default: 0)
  73869. * @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)
  73870. */
  73871. 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);
  73872. /**
  73873. * Updates the effect with the current post process compile time values and recompiles the shader.
  73874. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73875. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73876. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73877. * @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
  73878. * @param onCompiled Called when the shader has been compiled.
  73879. * @param onError Called if there is an error when compiling a shader.
  73880. */
  73881. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73882. }
  73883. }
  73884. declare module BABYLON {
  73885. /**
  73886. * Specifies the level of max blur that should be applied when using the depth of field effect
  73887. */
  73888. export enum DepthOfFieldEffectBlurLevel {
  73889. /**
  73890. * Subtle blur
  73891. */
  73892. Low = 0,
  73893. /**
  73894. * Medium blur
  73895. */
  73896. Medium = 1,
  73897. /**
  73898. * Large blur
  73899. */
  73900. High = 2
  73901. }
  73902. /**
  73903. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73904. */
  73905. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73906. private _circleOfConfusion;
  73907. /**
  73908. * @hidden Internal, blurs from high to low
  73909. */
  73910. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73911. private _depthOfFieldBlurY;
  73912. private _dofMerge;
  73913. /**
  73914. * @hidden Internal post processes in depth of field effect
  73915. */
  73916. _effects: Array<PostProcess>;
  73917. /**
  73918. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73919. */
  73920. set focalLength(value: number);
  73921. get focalLength(): number;
  73922. /**
  73923. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73924. */
  73925. set fStop(value: number);
  73926. get fStop(): number;
  73927. /**
  73928. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73929. */
  73930. set focusDistance(value: number);
  73931. get focusDistance(): number;
  73932. /**
  73933. * 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.
  73934. */
  73935. set lensSize(value: number);
  73936. get lensSize(): number;
  73937. /**
  73938. * Creates a new instance DepthOfFieldEffect
  73939. * @param scene The scene the effect belongs to.
  73940. * @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.
  73941. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73942. * @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)
  73943. */
  73944. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73945. /**
  73946. * Get the current class name of the current effet
  73947. * @returns "DepthOfFieldEffect"
  73948. */
  73949. getClassName(): string;
  73950. /**
  73951. * 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.
  73952. */
  73953. set depthTexture(value: RenderTargetTexture);
  73954. /**
  73955. * Disposes each of the internal effects for a given camera.
  73956. * @param camera The camera to dispose the effect on.
  73957. */
  73958. disposeEffects(camera: Camera): void;
  73959. /**
  73960. * @hidden Internal
  73961. */
  73962. _updateEffects(): void;
  73963. /**
  73964. * Internal
  73965. * @returns if all the contained post processes are ready.
  73966. * @hidden
  73967. */
  73968. _isReady(): boolean;
  73969. }
  73970. }
  73971. declare module BABYLON {
  73972. /** @hidden */
  73973. export var displayPassPixelShader: {
  73974. name: string;
  73975. shader: string;
  73976. };
  73977. }
  73978. declare module BABYLON {
  73979. /**
  73980. * DisplayPassPostProcess which produces an output the same as it's input
  73981. */
  73982. export class DisplayPassPostProcess extends PostProcess {
  73983. /**
  73984. * Gets a string identifying the name of the class
  73985. * @returns "DisplayPassPostProcess" string
  73986. */
  73987. getClassName(): string;
  73988. /**
  73989. * Creates the DisplayPassPostProcess
  73990. * @param name The name of the effect.
  73991. * @param options The required width/height ratio to downsize to before computing the render pass.
  73992. * @param camera The camera to apply the render pass to.
  73993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73994. * @param engine The engine which the post process will be applied. (default: current engine)
  73995. * @param reusable If the post process can be reused on the same frame. (default: false)
  73996. */
  73997. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73998. /** @hidden */
  73999. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74000. }
  74001. }
  74002. declare module BABYLON {
  74003. /** @hidden */
  74004. export var filterPixelShader: {
  74005. name: string;
  74006. shader: string;
  74007. };
  74008. }
  74009. declare module BABYLON {
  74010. /**
  74011. * Applies a kernel filter to the image
  74012. */
  74013. export class FilterPostProcess extends PostProcess {
  74014. /** The matrix to be applied to the image */
  74015. kernelMatrix: Matrix;
  74016. /**
  74017. * Gets a string identifying the name of the class
  74018. * @returns "FilterPostProcess" string
  74019. */
  74020. getClassName(): string;
  74021. /**
  74022. *
  74023. * @param name The name of the effect.
  74024. * @param kernelMatrix The matrix to be applied to the image
  74025. * @param options The required width/height ratio to downsize to before computing the render pass.
  74026. * @param camera The camera to apply the render pass to.
  74027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74028. * @param engine The engine which the post process will be applied. (default: current engine)
  74029. * @param reusable If the post process can be reused on the same frame. (default: false)
  74030. */
  74031. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74032. /** @hidden */
  74033. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74034. }
  74035. }
  74036. declare module BABYLON {
  74037. /** @hidden */
  74038. export var fxaaPixelShader: {
  74039. name: string;
  74040. shader: string;
  74041. };
  74042. }
  74043. declare module BABYLON {
  74044. /** @hidden */
  74045. export var fxaaVertexShader: {
  74046. name: string;
  74047. shader: string;
  74048. };
  74049. }
  74050. declare module BABYLON {
  74051. /**
  74052. * Fxaa post process
  74053. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74054. */
  74055. export class FxaaPostProcess extends PostProcess {
  74056. /**
  74057. * Gets a string identifying the name of the class
  74058. * @returns "FxaaPostProcess" string
  74059. */
  74060. getClassName(): string;
  74061. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74062. private _getDefines;
  74063. /** @hidden */
  74064. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74065. }
  74066. }
  74067. declare module BABYLON {
  74068. /** @hidden */
  74069. export var grainPixelShader: {
  74070. name: string;
  74071. shader: string;
  74072. };
  74073. }
  74074. declare module BABYLON {
  74075. /**
  74076. * The GrainPostProcess adds noise to the image at mid luminance levels
  74077. */
  74078. export class GrainPostProcess extends PostProcess {
  74079. /**
  74080. * The intensity of the grain added (default: 30)
  74081. */
  74082. intensity: number;
  74083. /**
  74084. * If the grain should be randomized on every frame
  74085. */
  74086. animated: boolean;
  74087. /**
  74088. * Gets a string identifying the name of the class
  74089. * @returns "GrainPostProcess" string
  74090. */
  74091. getClassName(): string;
  74092. /**
  74093. * Creates a new instance of @see GrainPostProcess
  74094. * @param name The name of the effect.
  74095. * @param options The required width/height ratio to downsize to before computing the render pass.
  74096. * @param camera The camera to apply the render pass to.
  74097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74098. * @param engine The engine which the post process will be applied. (default: current engine)
  74099. * @param reusable If the post process can be reused on the same frame. (default: false)
  74100. * @param textureType Type of textures used when performing the post process. (default: 0)
  74101. * @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)
  74102. */
  74103. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74104. /** @hidden */
  74105. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74106. }
  74107. }
  74108. declare module BABYLON {
  74109. /** @hidden */
  74110. export var highlightsPixelShader: {
  74111. name: string;
  74112. shader: string;
  74113. };
  74114. }
  74115. declare module BABYLON {
  74116. /**
  74117. * Extracts highlights from the image
  74118. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74119. */
  74120. export class HighlightsPostProcess extends PostProcess {
  74121. /**
  74122. * Gets a string identifying the name of the class
  74123. * @returns "HighlightsPostProcess" string
  74124. */
  74125. getClassName(): string;
  74126. /**
  74127. * Extracts highlights from the image
  74128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74129. * @param name The name of the effect.
  74130. * @param options The required width/height ratio to downsize to before computing the render pass.
  74131. * @param camera The camera to apply the render pass to.
  74132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74133. * @param engine The engine which the post process will be applied. (default: current engine)
  74134. * @param reusable If the post process can be reused on the same frame. (default: false)
  74135. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74136. */
  74137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74138. }
  74139. }
  74140. declare module BABYLON {
  74141. /**
  74142. * Contains all parameters needed for the prepass to perform
  74143. * motion blur
  74144. */
  74145. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74146. /**
  74147. * Is motion blur enabled
  74148. */
  74149. enabled: boolean;
  74150. /**
  74151. * Name of the configuration
  74152. */
  74153. name: string;
  74154. /**
  74155. * Textures that should be present in the MRT for this effect to work
  74156. */
  74157. readonly texturesRequired: number[];
  74158. }
  74159. }
  74160. declare module BABYLON {
  74161. interface Scene {
  74162. /** @hidden (Backing field) */
  74163. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74164. /**
  74165. * Gets or Sets the current geometry buffer associated to the scene.
  74166. */
  74167. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74168. /**
  74169. * Enables a GeometryBufferRender and associates it with the scene
  74170. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74171. * @returns the GeometryBufferRenderer
  74172. */
  74173. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74174. /**
  74175. * Disables the GeometryBufferRender associated with the scene
  74176. */
  74177. disableGeometryBufferRenderer(): void;
  74178. }
  74179. /**
  74180. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74181. * in several rendering techniques.
  74182. */
  74183. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74184. /**
  74185. * The component name helpful to identify the component in the list of scene components.
  74186. */
  74187. readonly name: string;
  74188. /**
  74189. * The scene the component belongs to.
  74190. */
  74191. scene: Scene;
  74192. /**
  74193. * Creates a new instance of the component for the given scene
  74194. * @param scene Defines the scene to register the component in
  74195. */
  74196. constructor(scene: Scene);
  74197. /**
  74198. * Registers the component in a given scene
  74199. */
  74200. register(): void;
  74201. /**
  74202. * Rebuilds the elements related to this component in case of
  74203. * context lost for instance.
  74204. */
  74205. rebuild(): void;
  74206. /**
  74207. * Disposes the component and the associated ressources
  74208. */
  74209. dispose(): void;
  74210. private _gatherRenderTargets;
  74211. }
  74212. }
  74213. declare module BABYLON {
  74214. /** @hidden */
  74215. export var motionBlurPixelShader: {
  74216. name: string;
  74217. shader: string;
  74218. };
  74219. }
  74220. declare module BABYLON {
  74221. /**
  74222. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74223. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74224. * As an example, all you have to do is to create the post-process:
  74225. * var mb = new BABYLON.MotionBlurPostProcess(
  74226. * 'mb', // The name of the effect.
  74227. * scene, // The scene containing the objects to blur according to their velocity.
  74228. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74229. * camera // The camera to apply the render pass to.
  74230. * );
  74231. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74232. */
  74233. export class MotionBlurPostProcess extends PostProcess {
  74234. /**
  74235. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74236. */
  74237. motionStrength: number;
  74238. /**
  74239. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74240. */
  74241. get motionBlurSamples(): number;
  74242. /**
  74243. * Sets the number of iterations to be used for motion blur quality
  74244. */
  74245. set motionBlurSamples(samples: number);
  74246. private _motionBlurSamples;
  74247. /**
  74248. * Gets wether or not the motion blur post-process is in object based mode.
  74249. */
  74250. get isObjectBased(): boolean;
  74251. /**
  74252. * Sets wether or not the motion blur post-process is in object based mode.
  74253. */
  74254. set isObjectBased(value: boolean);
  74255. private _isObjectBased;
  74256. private _forceGeometryBuffer;
  74257. private _geometryBufferRenderer;
  74258. private _prePassRenderer;
  74259. private _invViewProjection;
  74260. private _previousViewProjection;
  74261. /**
  74262. * Gets a string identifying the name of the class
  74263. * @returns "MotionBlurPostProcess" string
  74264. */
  74265. getClassName(): string;
  74266. /**
  74267. * Creates a new instance MotionBlurPostProcess
  74268. * @param name The name of the effect.
  74269. * @param scene The scene containing the objects to blur according to their velocity.
  74270. * @param options The required width/height ratio to downsize to before computing the render pass.
  74271. * @param camera The camera to apply the render pass to.
  74272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74273. * @param engine The engine which the post process will be applied. (default: current engine)
  74274. * @param reusable If the post process can be reused on the same frame. (default: false)
  74275. * @param textureType Type of textures used when performing the post process. (default: 0)
  74276. * @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)
  74277. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74278. */
  74279. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74280. /**
  74281. * Excludes the given skinned mesh from computing bones velocities.
  74282. * 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.
  74283. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74284. */
  74285. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74286. /**
  74287. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74288. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74289. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74290. */
  74291. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74292. /**
  74293. * Disposes the post process.
  74294. * @param camera The camera to dispose the post process on.
  74295. */
  74296. dispose(camera?: Camera): void;
  74297. /**
  74298. * Called on the mode changed (object based or screen based).
  74299. */
  74300. private _applyMode;
  74301. /**
  74302. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74303. */
  74304. private _onApplyObjectBased;
  74305. /**
  74306. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74307. */
  74308. private _onApplyScreenBased;
  74309. /**
  74310. * Called on the effect must be updated (changed mode, samples count, etc.).
  74311. */
  74312. private _updateEffect;
  74313. /** @hidden */
  74314. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74315. }
  74316. }
  74317. declare module BABYLON {
  74318. /** @hidden */
  74319. export var refractionPixelShader: {
  74320. name: string;
  74321. shader: string;
  74322. };
  74323. }
  74324. declare module BABYLON {
  74325. /**
  74326. * Post process which applies a refractin texture
  74327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74328. */
  74329. export class RefractionPostProcess extends PostProcess {
  74330. private _refTexture;
  74331. private _ownRefractionTexture;
  74332. /** the base color of the refraction (used to taint the rendering) */
  74333. color: Color3;
  74334. /** simulated refraction depth */
  74335. depth: number;
  74336. /** the coefficient of the base color (0 to remove base color tainting) */
  74337. colorLevel: number;
  74338. /** Gets the url used to load the refraction texture */
  74339. refractionTextureUrl: string;
  74340. /**
  74341. * Gets or sets the refraction texture
  74342. * Please note that you are responsible for disposing the texture if you set it manually
  74343. */
  74344. get refractionTexture(): Texture;
  74345. set refractionTexture(value: Texture);
  74346. /**
  74347. * Gets a string identifying the name of the class
  74348. * @returns "RefractionPostProcess" string
  74349. */
  74350. getClassName(): string;
  74351. /**
  74352. * Initializes the RefractionPostProcess
  74353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74354. * @param name The name of the effect.
  74355. * @param refractionTextureUrl Url of the refraction texture to use
  74356. * @param color the base color of the refraction (used to taint the rendering)
  74357. * @param depth simulated refraction depth
  74358. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74359. * @param camera The camera to apply the render pass to.
  74360. * @param options The required width/height ratio to downsize to before computing the render pass.
  74361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74362. * @param engine The engine which the post process will be applied. (default: current engine)
  74363. * @param reusable If the post process can be reused on the same frame. (default: false)
  74364. */
  74365. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74366. /**
  74367. * Disposes of the post process
  74368. * @param camera Camera to dispose post process on
  74369. */
  74370. dispose(camera: Camera): void;
  74371. /** @hidden */
  74372. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74373. }
  74374. }
  74375. declare module BABYLON {
  74376. /** @hidden */
  74377. export var sharpenPixelShader: {
  74378. name: string;
  74379. shader: string;
  74380. };
  74381. }
  74382. declare module BABYLON {
  74383. /**
  74384. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74385. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74386. */
  74387. export class SharpenPostProcess extends PostProcess {
  74388. /**
  74389. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74390. */
  74391. colorAmount: number;
  74392. /**
  74393. * How much sharpness should be applied (default: 0.3)
  74394. */
  74395. edgeAmount: number;
  74396. /**
  74397. * Gets a string identifying the name of the class
  74398. * @returns "SharpenPostProcess" string
  74399. */
  74400. getClassName(): string;
  74401. /**
  74402. * Creates a new instance ConvolutionPostProcess
  74403. * @param name The name of the effect.
  74404. * @param options The required width/height ratio to downsize to before computing the render pass.
  74405. * @param camera The camera to apply the render pass to.
  74406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74407. * @param engine The engine which the post process will be applied. (default: current engine)
  74408. * @param reusable If the post process can be reused on the same frame. (default: false)
  74409. * @param textureType Type of textures used when performing the post process. (default: 0)
  74410. * @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)
  74411. */
  74412. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74413. /** @hidden */
  74414. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74415. }
  74416. }
  74417. declare module BABYLON {
  74418. /**
  74419. * PostProcessRenderPipeline
  74420. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74421. */
  74422. export class PostProcessRenderPipeline {
  74423. private engine;
  74424. private _renderEffects;
  74425. private _renderEffectsForIsolatedPass;
  74426. /**
  74427. * List of inspectable custom properties (used by the Inspector)
  74428. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74429. */
  74430. inspectableCustomProperties: IInspectable[];
  74431. /**
  74432. * @hidden
  74433. */
  74434. protected _cameras: Camera[];
  74435. /** @hidden */
  74436. _name: string;
  74437. /**
  74438. * Gets pipeline name
  74439. */
  74440. get name(): string;
  74441. /** Gets the list of attached cameras */
  74442. get cameras(): Camera[];
  74443. /**
  74444. * Initializes a PostProcessRenderPipeline
  74445. * @param engine engine to add the pipeline to
  74446. * @param name name of the pipeline
  74447. */
  74448. constructor(engine: Engine, name: string);
  74449. /**
  74450. * Gets the class name
  74451. * @returns "PostProcessRenderPipeline"
  74452. */
  74453. getClassName(): string;
  74454. /**
  74455. * If all the render effects in the pipeline are supported
  74456. */
  74457. get isSupported(): boolean;
  74458. /**
  74459. * Adds an effect to the pipeline
  74460. * @param renderEffect the effect to add
  74461. */
  74462. addEffect(renderEffect: PostProcessRenderEffect): void;
  74463. /** @hidden */
  74464. _rebuild(): void;
  74465. /** @hidden */
  74466. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74467. /** @hidden */
  74468. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74469. /** @hidden */
  74470. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74471. /** @hidden */
  74472. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74473. /** @hidden */
  74474. _attachCameras(cameras: Camera, unique: boolean): void;
  74475. /** @hidden */
  74476. _attachCameras(cameras: Camera[], unique: boolean): void;
  74477. /** @hidden */
  74478. _detachCameras(cameras: Camera): void;
  74479. /** @hidden */
  74480. _detachCameras(cameras: Nullable<Camera[]>): void;
  74481. /** @hidden */
  74482. _update(): void;
  74483. /** @hidden */
  74484. _reset(): void;
  74485. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74486. /**
  74487. * Sets the required values to the prepass renderer.
  74488. * @param prePassRenderer defines the prepass renderer to setup.
  74489. * @returns true if the pre pass is needed.
  74490. */
  74491. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74492. /**
  74493. * Disposes of the pipeline
  74494. */
  74495. dispose(): void;
  74496. }
  74497. }
  74498. declare module BABYLON {
  74499. /**
  74500. * PostProcessRenderPipelineManager class
  74501. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74502. */
  74503. export class PostProcessRenderPipelineManager {
  74504. private _renderPipelines;
  74505. /**
  74506. * Initializes a PostProcessRenderPipelineManager
  74507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74508. */
  74509. constructor();
  74510. /**
  74511. * Gets the list of supported render pipelines
  74512. */
  74513. get supportedPipelines(): PostProcessRenderPipeline[];
  74514. /**
  74515. * Adds a pipeline to the manager
  74516. * @param renderPipeline The pipeline to add
  74517. */
  74518. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74519. /**
  74520. * Attaches a camera to the pipeline
  74521. * @param renderPipelineName The name of the pipeline to attach to
  74522. * @param cameras the camera to attach
  74523. * @param unique if the camera can be attached multiple times to the pipeline
  74524. */
  74525. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74526. /**
  74527. * Detaches a camera from the pipeline
  74528. * @param renderPipelineName The name of the pipeline to detach from
  74529. * @param cameras the camera to detach
  74530. */
  74531. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74532. /**
  74533. * Enables an effect by name on a pipeline
  74534. * @param renderPipelineName the name of the pipeline to enable the effect in
  74535. * @param renderEffectName the name of the effect to enable
  74536. * @param cameras the cameras that the effect should be enabled on
  74537. */
  74538. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74539. /**
  74540. * Disables an effect by name on a pipeline
  74541. * @param renderPipelineName the name of the pipeline to disable the effect in
  74542. * @param renderEffectName the name of the effect to disable
  74543. * @param cameras the cameras that the effect should be disabled on
  74544. */
  74545. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74546. /**
  74547. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74548. */
  74549. update(): void;
  74550. /** @hidden */
  74551. _rebuild(): void;
  74552. /**
  74553. * Disposes of the manager and pipelines
  74554. */
  74555. dispose(): void;
  74556. }
  74557. }
  74558. declare module BABYLON {
  74559. interface Scene {
  74560. /** @hidden (Backing field) */
  74561. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74562. /**
  74563. * Gets the postprocess render pipeline manager
  74564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74565. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74566. */
  74567. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74568. }
  74569. /**
  74570. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74571. */
  74572. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74573. /**
  74574. * The component name helpfull to identify the component in the list of scene components.
  74575. */
  74576. readonly name: string;
  74577. /**
  74578. * The scene the component belongs to.
  74579. */
  74580. scene: Scene;
  74581. /**
  74582. * Creates a new instance of the component for the given scene
  74583. * @param scene Defines the scene to register the component in
  74584. */
  74585. constructor(scene: Scene);
  74586. /**
  74587. * Registers the component in a given scene
  74588. */
  74589. register(): void;
  74590. /**
  74591. * Rebuilds the elements related to this component in case of
  74592. * context lost for instance.
  74593. */
  74594. rebuild(): void;
  74595. /**
  74596. * Disposes the component and the associated ressources
  74597. */
  74598. dispose(): void;
  74599. private _gatherRenderTargets;
  74600. }
  74601. }
  74602. declare module BABYLON {
  74603. /**
  74604. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74605. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74606. */
  74607. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74608. private _scene;
  74609. private _camerasToBeAttached;
  74610. /**
  74611. * ID of the sharpen post process,
  74612. */
  74613. private readonly SharpenPostProcessId;
  74614. /**
  74615. * @ignore
  74616. * ID of the image processing post process;
  74617. */
  74618. readonly ImageProcessingPostProcessId: string;
  74619. /**
  74620. * @ignore
  74621. * ID of the Fast Approximate Anti-Aliasing post process;
  74622. */
  74623. readonly FxaaPostProcessId: string;
  74624. /**
  74625. * ID of the chromatic aberration post process,
  74626. */
  74627. private readonly ChromaticAberrationPostProcessId;
  74628. /**
  74629. * ID of the grain post process
  74630. */
  74631. private readonly GrainPostProcessId;
  74632. /**
  74633. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74634. */
  74635. sharpen: SharpenPostProcess;
  74636. private _sharpenEffect;
  74637. private bloom;
  74638. /**
  74639. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74640. */
  74641. depthOfField: DepthOfFieldEffect;
  74642. /**
  74643. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74644. */
  74645. fxaa: FxaaPostProcess;
  74646. /**
  74647. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74648. */
  74649. imageProcessing: ImageProcessingPostProcess;
  74650. /**
  74651. * Chromatic aberration post process which will shift rgb colors in the image
  74652. */
  74653. chromaticAberration: ChromaticAberrationPostProcess;
  74654. private _chromaticAberrationEffect;
  74655. /**
  74656. * Grain post process which add noise to the image
  74657. */
  74658. grain: GrainPostProcess;
  74659. private _grainEffect;
  74660. /**
  74661. * Glow post process which adds a glow to emissive areas of the image
  74662. */
  74663. private _glowLayer;
  74664. /**
  74665. * Animations which can be used to tweak settings over a period of time
  74666. */
  74667. animations: Animation[];
  74668. private _imageProcessingConfigurationObserver;
  74669. private _sharpenEnabled;
  74670. private _bloomEnabled;
  74671. private _depthOfFieldEnabled;
  74672. private _depthOfFieldBlurLevel;
  74673. private _fxaaEnabled;
  74674. private _imageProcessingEnabled;
  74675. private _defaultPipelineTextureType;
  74676. private _bloomScale;
  74677. private _chromaticAberrationEnabled;
  74678. private _grainEnabled;
  74679. private _buildAllowed;
  74680. /**
  74681. * This is triggered each time the pipeline has been built.
  74682. */
  74683. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74684. /**
  74685. * Gets active scene
  74686. */
  74687. get scene(): Scene;
  74688. /**
  74689. * Enable or disable the sharpen process from the pipeline
  74690. */
  74691. set sharpenEnabled(enabled: boolean);
  74692. get sharpenEnabled(): boolean;
  74693. private _resizeObserver;
  74694. private _hardwareScaleLevel;
  74695. private _bloomKernel;
  74696. /**
  74697. * Specifies the size of the bloom blur kernel, relative to the final output size
  74698. */
  74699. get bloomKernel(): number;
  74700. set bloomKernel(value: number);
  74701. /**
  74702. * Specifies the weight of the bloom in the final rendering
  74703. */
  74704. private _bloomWeight;
  74705. /**
  74706. * Specifies the luma threshold for the area that will be blurred by the bloom
  74707. */
  74708. private _bloomThreshold;
  74709. private _hdr;
  74710. /**
  74711. * The strength of the bloom.
  74712. */
  74713. set bloomWeight(value: number);
  74714. get bloomWeight(): number;
  74715. /**
  74716. * The strength of the bloom.
  74717. */
  74718. set bloomThreshold(value: number);
  74719. get bloomThreshold(): number;
  74720. /**
  74721. * The scale of the bloom, lower value will provide better performance.
  74722. */
  74723. set bloomScale(value: number);
  74724. get bloomScale(): number;
  74725. /**
  74726. * Enable or disable the bloom from the pipeline
  74727. */
  74728. set bloomEnabled(enabled: boolean);
  74729. get bloomEnabled(): boolean;
  74730. private _rebuildBloom;
  74731. /**
  74732. * If the depth of field is enabled.
  74733. */
  74734. get depthOfFieldEnabled(): boolean;
  74735. set depthOfFieldEnabled(enabled: boolean);
  74736. /**
  74737. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74738. */
  74739. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74740. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74741. /**
  74742. * If the anti aliasing is enabled.
  74743. */
  74744. set fxaaEnabled(enabled: boolean);
  74745. get fxaaEnabled(): boolean;
  74746. private _samples;
  74747. /**
  74748. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74749. */
  74750. set samples(sampleCount: number);
  74751. get samples(): number;
  74752. /**
  74753. * If image processing is enabled.
  74754. */
  74755. set imageProcessingEnabled(enabled: boolean);
  74756. get imageProcessingEnabled(): boolean;
  74757. /**
  74758. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74759. */
  74760. set glowLayerEnabled(enabled: boolean);
  74761. get glowLayerEnabled(): boolean;
  74762. /**
  74763. * Gets the glow layer (or null if not defined)
  74764. */
  74765. get glowLayer(): Nullable<GlowLayer>;
  74766. /**
  74767. * Enable or disable the chromaticAberration process from the pipeline
  74768. */
  74769. set chromaticAberrationEnabled(enabled: boolean);
  74770. get chromaticAberrationEnabled(): boolean;
  74771. /**
  74772. * Enable or disable the grain process from the pipeline
  74773. */
  74774. set grainEnabled(enabled: boolean);
  74775. get grainEnabled(): boolean;
  74776. /**
  74777. * @constructor
  74778. * @param name - The rendering pipeline name (default: "")
  74779. * @param hdr - If high dynamic range textures should be used (default: true)
  74780. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74781. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74782. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74783. */
  74784. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74785. /**
  74786. * Get the class name
  74787. * @returns "DefaultRenderingPipeline"
  74788. */
  74789. getClassName(): string;
  74790. /**
  74791. * Force the compilation of the entire pipeline.
  74792. */
  74793. prepare(): void;
  74794. private _hasCleared;
  74795. private _prevPostProcess;
  74796. private _prevPrevPostProcess;
  74797. private _setAutoClearAndTextureSharing;
  74798. private _depthOfFieldSceneObserver;
  74799. private _buildPipeline;
  74800. private _disposePostProcesses;
  74801. /**
  74802. * Adds a camera to the pipeline
  74803. * @param camera the camera to be added
  74804. */
  74805. addCamera(camera: Camera): void;
  74806. /**
  74807. * Removes a camera from the pipeline
  74808. * @param camera the camera to remove
  74809. */
  74810. removeCamera(camera: Camera): void;
  74811. /**
  74812. * Dispose of the pipeline and stop all post processes
  74813. */
  74814. dispose(): void;
  74815. /**
  74816. * Serialize the rendering pipeline (Used when exporting)
  74817. * @returns the serialized object
  74818. */
  74819. serialize(): any;
  74820. /**
  74821. * Parse the serialized pipeline
  74822. * @param source Source pipeline.
  74823. * @param scene The scene to load the pipeline to.
  74824. * @param rootUrl The URL of the serialized pipeline.
  74825. * @returns An instantiated pipeline from the serialized object.
  74826. */
  74827. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74828. }
  74829. }
  74830. declare module BABYLON {
  74831. /** @hidden */
  74832. export var lensHighlightsPixelShader: {
  74833. name: string;
  74834. shader: string;
  74835. };
  74836. }
  74837. declare module BABYLON {
  74838. /** @hidden */
  74839. export var depthOfFieldPixelShader: {
  74840. name: string;
  74841. shader: string;
  74842. };
  74843. }
  74844. declare module BABYLON {
  74845. /**
  74846. * BABYLON.JS Chromatic Aberration GLSL Shader
  74847. * Author: Olivier Guyot
  74848. * Separates very slightly R, G and B colors on the edges of the screen
  74849. * Inspired by Francois Tarlier & Martins Upitis
  74850. */
  74851. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74852. /**
  74853. * @ignore
  74854. * The chromatic aberration PostProcess id in the pipeline
  74855. */
  74856. LensChromaticAberrationEffect: string;
  74857. /**
  74858. * @ignore
  74859. * The highlights enhancing PostProcess id in the pipeline
  74860. */
  74861. HighlightsEnhancingEffect: string;
  74862. /**
  74863. * @ignore
  74864. * The depth-of-field PostProcess id in the pipeline
  74865. */
  74866. LensDepthOfFieldEffect: string;
  74867. private _scene;
  74868. private _depthTexture;
  74869. private _grainTexture;
  74870. private _chromaticAberrationPostProcess;
  74871. private _highlightsPostProcess;
  74872. private _depthOfFieldPostProcess;
  74873. private _edgeBlur;
  74874. private _grainAmount;
  74875. private _chromaticAberration;
  74876. private _distortion;
  74877. private _highlightsGain;
  74878. private _highlightsThreshold;
  74879. private _dofDistance;
  74880. private _dofAperture;
  74881. private _dofDarken;
  74882. private _dofPentagon;
  74883. private _blurNoise;
  74884. /**
  74885. * @constructor
  74886. *
  74887. * Effect parameters are as follow:
  74888. * {
  74889. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74890. * edge_blur: number; // from 0 to x (1 for realism)
  74891. * distortion: number; // from 0 to x (1 for realism)
  74892. * grain_amount: number; // from 0 to 1
  74893. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74894. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74895. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74896. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74897. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74898. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74899. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74900. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74901. * }
  74902. * Note: if an effect parameter is unset, effect is disabled
  74903. *
  74904. * @param name The rendering pipeline name
  74905. * @param parameters - An object containing all parameters (see above)
  74906. * @param scene The scene linked to this pipeline
  74907. * @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)
  74908. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74909. */
  74910. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74911. /**
  74912. * Get the class name
  74913. * @returns "LensRenderingPipeline"
  74914. */
  74915. getClassName(): string;
  74916. /**
  74917. * Gets associated scene
  74918. */
  74919. get scene(): Scene;
  74920. /**
  74921. * Gets or sets the edge blur
  74922. */
  74923. get edgeBlur(): number;
  74924. set edgeBlur(value: number);
  74925. /**
  74926. * Gets or sets the grain amount
  74927. */
  74928. get grainAmount(): number;
  74929. set grainAmount(value: number);
  74930. /**
  74931. * Gets or sets the chromatic aberration amount
  74932. */
  74933. get chromaticAberration(): number;
  74934. set chromaticAberration(value: number);
  74935. /**
  74936. * Gets or sets the depth of field aperture
  74937. */
  74938. get dofAperture(): number;
  74939. set dofAperture(value: number);
  74940. /**
  74941. * Gets or sets the edge distortion
  74942. */
  74943. get edgeDistortion(): number;
  74944. set edgeDistortion(value: number);
  74945. /**
  74946. * Gets or sets the depth of field distortion
  74947. */
  74948. get dofDistortion(): number;
  74949. set dofDistortion(value: number);
  74950. /**
  74951. * Gets or sets the darken out of focus amount
  74952. */
  74953. get darkenOutOfFocus(): number;
  74954. set darkenOutOfFocus(value: number);
  74955. /**
  74956. * Gets or sets a boolean indicating if blur noise is enabled
  74957. */
  74958. get blurNoise(): boolean;
  74959. set blurNoise(value: boolean);
  74960. /**
  74961. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74962. */
  74963. get pentagonBokeh(): boolean;
  74964. set pentagonBokeh(value: boolean);
  74965. /**
  74966. * Gets or sets the highlight grain amount
  74967. */
  74968. get highlightsGain(): number;
  74969. set highlightsGain(value: number);
  74970. /**
  74971. * Gets or sets the highlight threshold
  74972. */
  74973. get highlightsThreshold(): number;
  74974. set highlightsThreshold(value: number);
  74975. /**
  74976. * Sets the amount of blur at the edges
  74977. * @param amount blur amount
  74978. */
  74979. setEdgeBlur(amount: number): void;
  74980. /**
  74981. * Sets edge blur to 0
  74982. */
  74983. disableEdgeBlur(): void;
  74984. /**
  74985. * Sets the amout of grain
  74986. * @param amount Amount of grain
  74987. */
  74988. setGrainAmount(amount: number): void;
  74989. /**
  74990. * Set grain amount to 0
  74991. */
  74992. disableGrain(): void;
  74993. /**
  74994. * Sets the chromatic aberration amount
  74995. * @param amount amount of chromatic aberration
  74996. */
  74997. setChromaticAberration(amount: number): void;
  74998. /**
  74999. * Sets chromatic aberration amount to 0
  75000. */
  75001. disableChromaticAberration(): void;
  75002. /**
  75003. * Sets the EdgeDistortion amount
  75004. * @param amount amount of EdgeDistortion
  75005. */
  75006. setEdgeDistortion(amount: number): void;
  75007. /**
  75008. * Sets edge distortion to 0
  75009. */
  75010. disableEdgeDistortion(): void;
  75011. /**
  75012. * Sets the FocusDistance amount
  75013. * @param amount amount of FocusDistance
  75014. */
  75015. setFocusDistance(amount: number): void;
  75016. /**
  75017. * Disables depth of field
  75018. */
  75019. disableDepthOfField(): void;
  75020. /**
  75021. * Sets the Aperture amount
  75022. * @param amount amount of Aperture
  75023. */
  75024. setAperture(amount: number): void;
  75025. /**
  75026. * Sets the DarkenOutOfFocus amount
  75027. * @param amount amount of DarkenOutOfFocus
  75028. */
  75029. setDarkenOutOfFocus(amount: number): void;
  75030. private _pentagonBokehIsEnabled;
  75031. /**
  75032. * Creates a pentagon bokeh effect
  75033. */
  75034. enablePentagonBokeh(): void;
  75035. /**
  75036. * Disables the pentagon bokeh effect
  75037. */
  75038. disablePentagonBokeh(): void;
  75039. /**
  75040. * Enables noise blur
  75041. */
  75042. enableNoiseBlur(): void;
  75043. /**
  75044. * Disables noise blur
  75045. */
  75046. disableNoiseBlur(): void;
  75047. /**
  75048. * Sets the HighlightsGain amount
  75049. * @param amount amount of HighlightsGain
  75050. */
  75051. setHighlightsGain(amount: number): void;
  75052. /**
  75053. * Sets the HighlightsThreshold amount
  75054. * @param amount amount of HighlightsThreshold
  75055. */
  75056. setHighlightsThreshold(amount: number): void;
  75057. /**
  75058. * Disables highlights
  75059. */
  75060. disableHighlights(): void;
  75061. /**
  75062. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75063. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75064. */
  75065. dispose(disableDepthRender?: boolean): void;
  75066. private _createChromaticAberrationPostProcess;
  75067. private _createHighlightsPostProcess;
  75068. private _createDepthOfFieldPostProcess;
  75069. private _createGrainTexture;
  75070. }
  75071. }
  75072. declare module BABYLON {
  75073. /**
  75074. * Contains all parameters needed for the prepass to perform
  75075. * screen space subsurface scattering
  75076. */
  75077. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75078. /**
  75079. * Is subsurface enabled
  75080. */
  75081. enabled: boolean;
  75082. /**
  75083. * Name of the configuration
  75084. */
  75085. name: string;
  75086. /**
  75087. * Textures that should be present in the MRT for this effect to work
  75088. */
  75089. readonly texturesRequired: number[];
  75090. }
  75091. }
  75092. declare module BABYLON {
  75093. /** @hidden */
  75094. export var ssao2PixelShader: {
  75095. name: string;
  75096. shader: string;
  75097. };
  75098. }
  75099. declare module BABYLON {
  75100. /** @hidden */
  75101. export var ssaoCombinePixelShader: {
  75102. name: string;
  75103. shader: string;
  75104. };
  75105. }
  75106. declare module BABYLON {
  75107. /**
  75108. * Render pipeline to produce ssao effect
  75109. */
  75110. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75111. /**
  75112. * @ignore
  75113. * The PassPostProcess id in the pipeline that contains the original scene color
  75114. */
  75115. SSAOOriginalSceneColorEffect: string;
  75116. /**
  75117. * @ignore
  75118. * The SSAO PostProcess id in the pipeline
  75119. */
  75120. SSAORenderEffect: string;
  75121. /**
  75122. * @ignore
  75123. * The horizontal blur PostProcess id in the pipeline
  75124. */
  75125. SSAOBlurHRenderEffect: string;
  75126. /**
  75127. * @ignore
  75128. * The vertical blur PostProcess id in the pipeline
  75129. */
  75130. SSAOBlurVRenderEffect: string;
  75131. /**
  75132. * @ignore
  75133. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75134. */
  75135. SSAOCombineRenderEffect: string;
  75136. /**
  75137. * The output strength of the SSAO post-process. Default value is 1.0.
  75138. */
  75139. totalStrength: number;
  75140. /**
  75141. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75142. */
  75143. maxZ: number;
  75144. /**
  75145. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75146. */
  75147. minZAspect: number;
  75148. private _samples;
  75149. /**
  75150. * Number of samples used for the SSAO calculations. Default value is 8
  75151. */
  75152. set samples(n: number);
  75153. get samples(): number;
  75154. private _textureSamples;
  75155. /**
  75156. * Number of samples to use for antialiasing
  75157. */
  75158. set textureSamples(n: number);
  75159. get textureSamples(): number;
  75160. /**
  75161. * Force rendering the geometry through geometry buffer
  75162. */
  75163. private _forceGeometryBuffer;
  75164. /**
  75165. * Ratio object used for SSAO ratio and blur ratio
  75166. */
  75167. private _ratio;
  75168. /**
  75169. * Dynamically generated sphere sampler.
  75170. */
  75171. private _sampleSphere;
  75172. /**
  75173. * Blur filter offsets
  75174. */
  75175. private _samplerOffsets;
  75176. private _expensiveBlur;
  75177. /**
  75178. * If bilateral blur should be used
  75179. */
  75180. set expensiveBlur(b: boolean);
  75181. get expensiveBlur(): boolean;
  75182. /**
  75183. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75184. */
  75185. radius: number;
  75186. /**
  75187. * The base color of the SSAO post-process
  75188. * The final result is "base + ssao" between [0, 1]
  75189. */
  75190. base: number;
  75191. /**
  75192. * Support test.
  75193. */
  75194. static get IsSupported(): boolean;
  75195. private _scene;
  75196. private _randomTexture;
  75197. private _originalColorPostProcess;
  75198. private _ssaoPostProcess;
  75199. private _blurHPostProcess;
  75200. private _blurVPostProcess;
  75201. private _ssaoCombinePostProcess;
  75202. private _prePassRenderer;
  75203. /**
  75204. * Gets active scene
  75205. */
  75206. get scene(): Scene;
  75207. /**
  75208. * @constructor
  75209. * @param name The rendering pipeline name
  75210. * @param scene The scene linked to this pipeline
  75211. * @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 }
  75212. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75213. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75214. */
  75215. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75216. /**
  75217. * Get the class name
  75218. * @returns "SSAO2RenderingPipeline"
  75219. */
  75220. getClassName(): string;
  75221. /**
  75222. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75223. */
  75224. dispose(disableGeometryBufferRenderer?: boolean): void;
  75225. private _createBlurPostProcess;
  75226. /** @hidden */
  75227. _rebuild(): void;
  75228. private _bits;
  75229. private _radicalInverse_VdC;
  75230. private _hammersley;
  75231. private _hemisphereSample_uniform;
  75232. private _generateHemisphere;
  75233. private _getDefinesForSSAO;
  75234. private static readonly ORTHO_DEPTH_PROJECTION;
  75235. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75236. private _createSSAOPostProcess;
  75237. private _createSSAOCombinePostProcess;
  75238. private _createRandomTexture;
  75239. /**
  75240. * Serialize the rendering pipeline (Used when exporting)
  75241. * @returns the serialized object
  75242. */
  75243. serialize(): any;
  75244. /**
  75245. * Parse the serialized pipeline
  75246. * @param source Source pipeline.
  75247. * @param scene The scene to load the pipeline to.
  75248. * @param rootUrl The URL of the serialized pipeline.
  75249. * @returns An instantiated pipeline from the serialized object.
  75250. */
  75251. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75252. }
  75253. }
  75254. declare module BABYLON {
  75255. /** @hidden */
  75256. export var ssaoPixelShader: {
  75257. name: string;
  75258. shader: string;
  75259. };
  75260. }
  75261. declare module BABYLON {
  75262. /**
  75263. * Render pipeline to produce ssao effect
  75264. */
  75265. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75266. /**
  75267. * @ignore
  75268. * The PassPostProcess id in the pipeline that contains the original scene color
  75269. */
  75270. SSAOOriginalSceneColorEffect: string;
  75271. /**
  75272. * @ignore
  75273. * The SSAO PostProcess id in the pipeline
  75274. */
  75275. SSAORenderEffect: string;
  75276. /**
  75277. * @ignore
  75278. * The horizontal blur PostProcess id in the pipeline
  75279. */
  75280. SSAOBlurHRenderEffect: string;
  75281. /**
  75282. * @ignore
  75283. * The vertical blur PostProcess id in the pipeline
  75284. */
  75285. SSAOBlurVRenderEffect: string;
  75286. /**
  75287. * @ignore
  75288. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75289. */
  75290. SSAOCombineRenderEffect: string;
  75291. /**
  75292. * The output strength of the SSAO post-process. Default value is 1.0.
  75293. */
  75294. totalStrength: number;
  75295. /**
  75296. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75297. */
  75298. radius: number;
  75299. /**
  75300. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75301. * Must not be equal to fallOff and superior to fallOff.
  75302. * Default value is 0.0075
  75303. */
  75304. area: number;
  75305. /**
  75306. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75307. * Must not be equal to area and inferior to area.
  75308. * Default value is 0.000001
  75309. */
  75310. fallOff: number;
  75311. /**
  75312. * The base color of the SSAO post-process
  75313. * The final result is "base + ssao" between [0, 1]
  75314. */
  75315. base: number;
  75316. private _scene;
  75317. private _depthTexture;
  75318. private _randomTexture;
  75319. private _originalColorPostProcess;
  75320. private _ssaoPostProcess;
  75321. private _blurHPostProcess;
  75322. private _blurVPostProcess;
  75323. private _ssaoCombinePostProcess;
  75324. private _firstUpdate;
  75325. /**
  75326. * Gets active scene
  75327. */
  75328. get scene(): Scene;
  75329. /**
  75330. * @constructor
  75331. * @param name - The rendering pipeline name
  75332. * @param scene - The scene linked to this pipeline
  75333. * @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 }
  75334. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75335. */
  75336. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75337. /**
  75338. * Get the class name
  75339. * @returns "SSAORenderingPipeline"
  75340. */
  75341. getClassName(): string;
  75342. /**
  75343. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75344. */
  75345. dispose(disableDepthRender?: boolean): void;
  75346. private _createBlurPostProcess;
  75347. /** @hidden */
  75348. _rebuild(): void;
  75349. private _createSSAOPostProcess;
  75350. private _createSSAOCombinePostProcess;
  75351. private _createRandomTexture;
  75352. }
  75353. }
  75354. declare module BABYLON {
  75355. /**
  75356. * Contains all parameters needed for the prepass to perform
  75357. * screen space reflections
  75358. */
  75359. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75360. /**
  75361. * Is ssr enabled
  75362. */
  75363. enabled: boolean;
  75364. /**
  75365. * Name of the configuration
  75366. */
  75367. name: string;
  75368. /**
  75369. * Textures that should be present in the MRT for this effect to work
  75370. */
  75371. readonly texturesRequired: number[];
  75372. }
  75373. }
  75374. declare module BABYLON {
  75375. /** @hidden */
  75376. export var screenSpaceReflectionPixelShader: {
  75377. name: string;
  75378. shader: string;
  75379. };
  75380. }
  75381. declare module BABYLON {
  75382. /**
  75383. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75384. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75385. */
  75386. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75387. /**
  75388. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75389. */
  75390. threshold: number;
  75391. /**
  75392. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75393. */
  75394. strength: number;
  75395. /**
  75396. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75397. */
  75398. reflectionSpecularFalloffExponent: number;
  75399. /**
  75400. * 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]
  75401. */
  75402. step: number;
  75403. /**
  75404. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75405. */
  75406. roughnessFactor: number;
  75407. private _forceGeometryBuffer;
  75408. private _geometryBufferRenderer;
  75409. private _prePassRenderer;
  75410. private _enableSmoothReflections;
  75411. private _reflectionSamples;
  75412. private _smoothSteps;
  75413. /**
  75414. * Gets a string identifying the name of the class
  75415. * @returns "ScreenSpaceReflectionPostProcess" string
  75416. */
  75417. getClassName(): string;
  75418. /**
  75419. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75420. * @param name The name of the effect.
  75421. * @param scene The scene containing the objects to calculate reflections.
  75422. * @param options The required width/height ratio to downsize to before computing the render pass.
  75423. * @param camera The camera to apply the render pass to.
  75424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75425. * @param engine The engine which the post process will be applied. (default: current engine)
  75426. * @param reusable If the post process can be reused on the same frame. (default: false)
  75427. * @param textureType Type of textures used when performing the post process. (default: 0)
  75428. * @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)
  75429. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75430. */
  75431. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75432. /**
  75433. * Gets wether or not smoothing reflections is enabled.
  75434. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75435. */
  75436. get enableSmoothReflections(): boolean;
  75437. /**
  75438. * Sets wether or not smoothing reflections is enabled.
  75439. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75440. */
  75441. set enableSmoothReflections(enabled: boolean);
  75442. /**
  75443. * Gets the number of samples taken while computing reflections. More samples count is high,
  75444. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75445. */
  75446. get reflectionSamples(): number;
  75447. /**
  75448. * Sets the number of samples taken while computing reflections. More samples count is high,
  75449. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75450. */
  75451. set reflectionSamples(samples: number);
  75452. /**
  75453. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75454. * more the post-process will require GPU power and can generate a drop in FPS.
  75455. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75456. */
  75457. get smoothSteps(): number;
  75458. set smoothSteps(steps: number);
  75459. private _updateEffectDefines;
  75460. /** @hidden */
  75461. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75462. }
  75463. }
  75464. declare module BABYLON {
  75465. /** @hidden */
  75466. export var standardPixelShader: {
  75467. name: string;
  75468. shader: string;
  75469. };
  75470. }
  75471. declare module BABYLON {
  75472. /**
  75473. * Standard rendering pipeline
  75474. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75475. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75476. */
  75477. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75478. /**
  75479. * Public members
  75480. */
  75481. /**
  75482. * Post-process which contains the original scene color before the pipeline applies all the effects
  75483. */
  75484. originalPostProcess: Nullable<PostProcess>;
  75485. /**
  75486. * Post-process used to down scale an image x4
  75487. */
  75488. downSampleX4PostProcess: Nullable<PostProcess>;
  75489. /**
  75490. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75491. */
  75492. brightPassPostProcess: Nullable<PostProcess>;
  75493. /**
  75494. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75495. */
  75496. blurHPostProcesses: PostProcess[];
  75497. /**
  75498. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75499. */
  75500. blurVPostProcesses: PostProcess[];
  75501. /**
  75502. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75503. */
  75504. textureAdderPostProcess: Nullable<PostProcess>;
  75505. /**
  75506. * Post-process used to create volumetric lighting effect
  75507. */
  75508. volumetricLightPostProcess: Nullable<PostProcess>;
  75509. /**
  75510. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75511. */
  75512. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75513. /**
  75514. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75515. */
  75516. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75517. /**
  75518. * Post-process used to merge the volumetric light effect and the real scene color
  75519. */
  75520. volumetricLightMergePostProces: Nullable<PostProcess>;
  75521. /**
  75522. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75523. */
  75524. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75525. /**
  75526. * Base post-process used to calculate the average luminance of the final image for HDR
  75527. */
  75528. luminancePostProcess: Nullable<PostProcess>;
  75529. /**
  75530. * Post-processes used to create down sample post-processes in order to get
  75531. * the average luminance of the final image for HDR
  75532. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75533. */
  75534. luminanceDownSamplePostProcesses: PostProcess[];
  75535. /**
  75536. * Post-process used to create a HDR effect (light adaptation)
  75537. */
  75538. hdrPostProcess: Nullable<PostProcess>;
  75539. /**
  75540. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75541. */
  75542. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75543. /**
  75544. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75545. */
  75546. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75547. /**
  75548. * Post-process used to merge the final HDR post-process and the real scene color
  75549. */
  75550. hdrFinalPostProcess: Nullable<PostProcess>;
  75551. /**
  75552. * Post-process used to create a lens flare effect
  75553. */
  75554. lensFlarePostProcess: Nullable<PostProcess>;
  75555. /**
  75556. * Post-process that merges the result of the lens flare post-process and the real scene color
  75557. */
  75558. lensFlareComposePostProcess: Nullable<PostProcess>;
  75559. /**
  75560. * Post-process used to create a motion blur effect
  75561. */
  75562. motionBlurPostProcess: Nullable<PostProcess>;
  75563. /**
  75564. * Post-process used to create a depth of field effect
  75565. */
  75566. depthOfFieldPostProcess: Nullable<PostProcess>;
  75567. /**
  75568. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75569. */
  75570. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75571. /**
  75572. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75573. */
  75574. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75575. /**
  75576. * Represents the brightness threshold in order to configure the illuminated surfaces
  75577. */
  75578. brightThreshold: number;
  75579. /**
  75580. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75581. */
  75582. blurWidth: number;
  75583. /**
  75584. * Sets if the blur for highlighted surfaces must be only horizontal
  75585. */
  75586. horizontalBlur: boolean;
  75587. /**
  75588. * Gets the overall exposure used by the pipeline
  75589. */
  75590. get exposure(): number;
  75591. /**
  75592. * Sets the overall exposure used by the pipeline
  75593. */
  75594. set exposure(value: number);
  75595. /**
  75596. * Texture used typically to simulate "dirty" on camera lens
  75597. */
  75598. lensTexture: Nullable<Texture>;
  75599. /**
  75600. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75601. */
  75602. volumetricLightCoefficient: number;
  75603. /**
  75604. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75605. */
  75606. volumetricLightPower: number;
  75607. /**
  75608. * Used the set the blur intensity to smooth the volumetric lights
  75609. */
  75610. volumetricLightBlurScale: number;
  75611. /**
  75612. * Light (spot or directional) used to generate the volumetric lights rays
  75613. * The source light must have a shadow generate so the pipeline can get its
  75614. * depth map
  75615. */
  75616. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75617. /**
  75618. * For eye adaptation, represents the minimum luminance the eye can see
  75619. */
  75620. hdrMinimumLuminance: number;
  75621. /**
  75622. * For eye adaptation, represents the decrease luminance speed
  75623. */
  75624. hdrDecreaseRate: number;
  75625. /**
  75626. * For eye adaptation, represents the increase luminance speed
  75627. */
  75628. hdrIncreaseRate: number;
  75629. /**
  75630. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75631. */
  75632. get hdrAutoExposure(): boolean;
  75633. /**
  75634. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75635. */
  75636. set hdrAutoExposure(value: boolean);
  75637. /**
  75638. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75639. */
  75640. lensColorTexture: Nullable<Texture>;
  75641. /**
  75642. * The overall strengh for the lens flare effect
  75643. */
  75644. lensFlareStrength: number;
  75645. /**
  75646. * Dispersion coefficient for lens flare ghosts
  75647. */
  75648. lensFlareGhostDispersal: number;
  75649. /**
  75650. * Main lens flare halo width
  75651. */
  75652. lensFlareHaloWidth: number;
  75653. /**
  75654. * Based on the lens distortion effect, defines how much the lens flare result
  75655. * is distorted
  75656. */
  75657. lensFlareDistortionStrength: number;
  75658. /**
  75659. * Configures the blur intensity used for for lens flare (halo)
  75660. */
  75661. lensFlareBlurWidth: number;
  75662. /**
  75663. * Lens star texture must be used to simulate rays on the flares and is available
  75664. * in the documentation
  75665. */
  75666. lensStarTexture: Nullable<Texture>;
  75667. /**
  75668. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75669. * flare effect by taking account of the dirt texture
  75670. */
  75671. lensFlareDirtTexture: Nullable<Texture>;
  75672. /**
  75673. * Represents the focal length for the depth of field effect
  75674. */
  75675. depthOfFieldDistance: number;
  75676. /**
  75677. * Represents the blur intensity for the blurred part of the depth of field effect
  75678. */
  75679. depthOfFieldBlurWidth: number;
  75680. /**
  75681. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75682. */
  75683. get motionStrength(): number;
  75684. /**
  75685. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75686. */
  75687. set motionStrength(strength: number);
  75688. /**
  75689. * Gets wether or not the motion blur post-process is object based or screen based.
  75690. */
  75691. get objectBasedMotionBlur(): boolean;
  75692. /**
  75693. * Sets wether or not the motion blur post-process should be object based or screen based
  75694. */
  75695. set objectBasedMotionBlur(value: boolean);
  75696. /**
  75697. * List of animations for the pipeline (IAnimatable implementation)
  75698. */
  75699. animations: Animation[];
  75700. /**
  75701. * Private members
  75702. */
  75703. private _scene;
  75704. private _currentDepthOfFieldSource;
  75705. private _basePostProcess;
  75706. private _fixedExposure;
  75707. private _currentExposure;
  75708. private _hdrAutoExposure;
  75709. private _hdrCurrentLuminance;
  75710. private _motionStrength;
  75711. private _isObjectBasedMotionBlur;
  75712. private _floatTextureType;
  75713. private _camerasToBeAttached;
  75714. private _ratio;
  75715. private _bloomEnabled;
  75716. private _depthOfFieldEnabled;
  75717. private _vlsEnabled;
  75718. private _lensFlareEnabled;
  75719. private _hdrEnabled;
  75720. private _motionBlurEnabled;
  75721. private _fxaaEnabled;
  75722. private _screenSpaceReflectionsEnabled;
  75723. private _motionBlurSamples;
  75724. private _volumetricLightStepsCount;
  75725. private _samples;
  75726. /**
  75727. * @ignore
  75728. * Specifies if the bloom pipeline is enabled
  75729. */
  75730. get BloomEnabled(): boolean;
  75731. set BloomEnabled(enabled: boolean);
  75732. /**
  75733. * @ignore
  75734. * Specifies if the depth of field pipeline is enabed
  75735. */
  75736. get DepthOfFieldEnabled(): boolean;
  75737. set DepthOfFieldEnabled(enabled: boolean);
  75738. /**
  75739. * @ignore
  75740. * Specifies if the lens flare pipeline is enabed
  75741. */
  75742. get LensFlareEnabled(): boolean;
  75743. set LensFlareEnabled(enabled: boolean);
  75744. /**
  75745. * @ignore
  75746. * Specifies if the HDR pipeline is enabled
  75747. */
  75748. get HDREnabled(): boolean;
  75749. set HDREnabled(enabled: boolean);
  75750. /**
  75751. * @ignore
  75752. * Specifies if the volumetric lights scattering effect is enabled
  75753. */
  75754. get VLSEnabled(): boolean;
  75755. set VLSEnabled(enabled: boolean);
  75756. /**
  75757. * @ignore
  75758. * Specifies if the motion blur effect is enabled
  75759. */
  75760. get MotionBlurEnabled(): boolean;
  75761. set MotionBlurEnabled(enabled: boolean);
  75762. /**
  75763. * Specifies if anti-aliasing is enabled
  75764. */
  75765. get fxaaEnabled(): boolean;
  75766. set fxaaEnabled(enabled: boolean);
  75767. /**
  75768. * Specifies if screen space reflections are enabled.
  75769. */
  75770. get screenSpaceReflectionsEnabled(): boolean;
  75771. set screenSpaceReflectionsEnabled(enabled: boolean);
  75772. /**
  75773. * Specifies the number of steps used to calculate the volumetric lights
  75774. * Typically in interval [50, 200]
  75775. */
  75776. get volumetricLightStepsCount(): number;
  75777. set volumetricLightStepsCount(count: number);
  75778. /**
  75779. * Specifies the number of samples used for the motion blur effect
  75780. * Typically in interval [16, 64]
  75781. */
  75782. get motionBlurSamples(): number;
  75783. set motionBlurSamples(samples: number);
  75784. /**
  75785. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75786. */
  75787. get samples(): number;
  75788. set samples(sampleCount: number);
  75789. /**
  75790. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75791. * @constructor
  75792. * @param name The rendering pipeline name
  75793. * @param scene The scene linked to this pipeline
  75794. * @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)
  75795. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75796. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75797. */
  75798. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75799. private _buildPipeline;
  75800. private _createDownSampleX4PostProcess;
  75801. private _createBrightPassPostProcess;
  75802. private _createBlurPostProcesses;
  75803. private _createTextureAdderPostProcess;
  75804. private _createVolumetricLightPostProcess;
  75805. private _createLuminancePostProcesses;
  75806. private _createHdrPostProcess;
  75807. private _createLensFlarePostProcess;
  75808. private _createDepthOfFieldPostProcess;
  75809. private _createMotionBlurPostProcess;
  75810. private _getDepthTexture;
  75811. private _disposePostProcesses;
  75812. /**
  75813. * Dispose of the pipeline and stop all post processes
  75814. */
  75815. dispose(): void;
  75816. /**
  75817. * Serialize the rendering pipeline (Used when exporting)
  75818. * @returns the serialized object
  75819. */
  75820. serialize(): any;
  75821. /**
  75822. * Parse the serialized pipeline
  75823. * @param source Source pipeline.
  75824. * @param scene The scene to load the pipeline to.
  75825. * @param rootUrl The URL of the serialized pipeline.
  75826. * @returns An instantiated pipeline from the serialized object.
  75827. */
  75828. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75829. /**
  75830. * Luminance steps
  75831. */
  75832. static LuminanceSteps: number;
  75833. }
  75834. }
  75835. declare module BABYLON {
  75836. /** @hidden */
  75837. export var tonemapPixelShader: {
  75838. name: string;
  75839. shader: string;
  75840. };
  75841. }
  75842. declare module BABYLON {
  75843. /** Defines operator used for tonemapping */
  75844. export enum TonemappingOperator {
  75845. /** Hable */
  75846. Hable = 0,
  75847. /** Reinhard */
  75848. Reinhard = 1,
  75849. /** HejiDawson */
  75850. HejiDawson = 2,
  75851. /** Photographic */
  75852. Photographic = 3
  75853. }
  75854. /**
  75855. * Defines a post process to apply tone mapping
  75856. */
  75857. export class TonemapPostProcess extends PostProcess {
  75858. private _operator;
  75859. /** Defines the required exposure adjustement */
  75860. exposureAdjustment: number;
  75861. /**
  75862. * Gets a string identifying the name of the class
  75863. * @returns "TonemapPostProcess" string
  75864. */
  75865. getClassName(): string;
  75866. /**
  75867. * Creates a new TonemapPostProcess
  75868. * @param name defines the name of the postprocess
  75869. * @param _operator defines the operator to use
  75870. * @param exposureAdjustment defines the required exposure adjustement
  75871. * @param camera defines the camera to use (can be null)
  75872. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75873. * @param engine defines the hosting engine (can be ignore if camera is set)
  75874. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75875. */
  75876. constructor(name: string, _operator: TonemappingOperator,
  75877. /** Defines the required exposure adjustement */
  75878. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75879. }
  75880. }
  75881. declare module BABYLON {
  75882. /** @hidden */
  75883. export var volumetricLightScatteringPixelShader: {
  75884. name: string;
  75885. shader: string;
  75886. };
  75887. }
  75888. declare module BABYLON {
  75889. /** @hidden */
  75890. export var volumetricLightScatteringPassVertexShader: {
  75891. name: string;
  75892. shader: string;
  75893. };
  75894. }
  75895. declare module BABYLON {
  75896. /** @hidden */
  75897. export var volumetricLightScatteringPassPixelShader: {
  75898. name: string;
  75899. shader: string;
  75900. };
  75901. }
  75902. declare module BABYLON {
  75903. /**
  75904. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75905. */
  75906. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75907. private _volumetricLightScatteringPass;
  75908. private _volumetricLightScatteringRTT;
  75909. private _viewPort;
  75910. private _screenCoordinates;
  75911. private _cachedDefines;
  75912. /**
  75913. * If not undefined, the mesh position is computed from the attached node position
  75914. */
  75915. attachedNode: {
  75916. position: Vector3;
  75917. };
  75918. /**
  75919. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75920. */
  75921. customMeshPosition: Vector3;
  75922. /**
  75923. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75924. */
  75925. useCustomMeshPosition: boolean;
  75926. /**
  75927. * If the post-process should inverse the light scattering direction
  75928. */
  75929. invert: boolean;
  75930. /**
  75931. * The internal mesh used by the post-process
  75932. */
  75933. mesh: Mesh;
  75934. /**
  75935. * @hidden
  75936. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75937. */
  75938. get useDiffuseColor(): boolean;
  75939. set useDiffuseColor(useDiffuseColor: boolean);
  75940. /**
  75941. * Array containing the excluded meshes not rendered in the internal pass
  75942. */
  75943. excludedMeshes: AbstractMesh[];
  75944. /**
  75945. * Controls the overall intensity of the post-process
  75946. */
  75947. exposure: number;
  75948. /**
  75949. * Dissipates each sample's contribution in range [0, 1]
  75950. */
  75951. decay: number;
  75952. /**
  75953. * Controls the overall intensity of each sample
  75954. */
  75955. weight: number;
  75956. /**
  75957. * Controls the density of each sample
  75958. */
  75959. density: number;
  75960. /**
  75961. * @constructor
  75962. * @param name The post-process name
  75963. * @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)
  75964. * @param camera The camera that the post-process will be attached to
  75965. * @param mesh The mesh used to create the light scattering
  75966. * @param samples The post-process quality, default 100
  75967. * @param samplingModeThe post-process filtering mode
  75968. * @param engine The babylon engine
  75969. * @param reusable If the post-process is reusable
  75970. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75971. */
  75972. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75973. /**
  75974. * Returns the string "VolumetricLightScatteringPostProcess"
  75975. * @returns "VolumetricLightScatteringPostProcess"
  75976. */
  75977. getClassName(): string;
  75978. private _isReady;
  75979. /**
  75980. * Sets the new light position for light scattering effect
  75981. * @param position The new custom light position
  75982. */
  75983. setCustomMeshPosition(position: Vector3): void;
  75984. /**
  75985. * Returns the light position for light scattering effect
  75986. * @return Vector3 The custom light position
  75987. */
  75988. getCustomMeshPosition(): Vector3;
  75989. /**
  75990. * Disposes the internal assets and detaches the post-process from the camera
  75991. */
  75992. dispose(camera: Camera): void;
  75993. /**
  75994. * Returns the render target texture used by the post-process
  75995. * @return the render target texture used by the post-process
  75996. */
  75997. getPass(): RenderTargetTexture;
  75998. private _meshExcluded;
  75999. private _createPass;
  76000. private _updateMeshScreenCoordinates;
  76001. /**
  76002. * Creates a default mesh for the Volumeric Light Scattering post-process
  76003. * @param name The mesh name
  76004. * @param scene The scene where to create the mesh
  76005. * @return the default mesh
  76006. */
  76007. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76008. }
  76009. }
  76010. declare module BABYLON {
  76011. /** @hidden */
  76012. export var screenSpaceCurvaturePixelShader: {
  76013. name: string;
  76014. shader: string;
  76015. };
  76016. }
  76017. declare module BABYLON {
  76018. /**
  76019. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76020. */
  76021. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76022. /**
  76023. * Defines how much ridge the curvature effect displays.
  76024. */
  76025. ridge: number;
  76026. /**
  76027. * Defines how much valley the curvature effect displays.
  76028. */
  76029. valley: number;
  76030. private _geometryBufferRenderer;
  76031. /**
  76032. * Gets a string identifying the name of the class
  76033. * @returns "ScreenSpaceCurvaturePostProcess" string
  76034. */
  76035. getClassName(): string;
  76036. /**
  76037. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76038. * @param name The name of the effect.
  76039. * @param scene The scene containing the objects to blur according to their velocity.
  76040. * @param options The required width/height ratio to downsize to before computing the render pass.
  76041. * @param camera The camera to apply the render pass to.
  76042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76043. * @param engine The engine which the post process will be applied. (default: current engine)
  76044. * @param reusable If the post process can be reused on the same frame. (default: false)
  76045. * @param textureType Type of textures used when performing the post process. (default: 0)
  76046. * @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)
  76047. */
  76048. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76049. /**
  76050. * Support test.
  76051. */
  76052. static get IsSupported(): boolean;
  76053. /** @hidden */
  76054. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76055. }
  76056. }
  76057. declare module BABYLON {
  76058. interface Scene {
  76059. /** @hidden (Backing field) */
  76060. _boundingBoxRenderer: BoundingBoxRenderer;
  76061. /** @hidden (Backing field) */
  76062. _forceShowBoundingBoxes: boolean;
  76063. /**
  76064. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76065. */
  76066. forceShowBoundingBoxes: boolean;
  76067. /**
  76068. * Gets the bounding box renderer associated with the scene
  76069. * @returns a BoundingBoxRenderer
  76070. */
  76071. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76072. }
  76073. interface AbstractMesh {
  76074. /** @hidden (Backing field) */
  76075. _showBoundingBox: boolean;
  76076. /**
  76077. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76078. */
  76079. showBoundingBox: boolean;
  76080. }
  76081. /**
  76082. * Component responsible of rendering the bounding box of the meshes in a scene.
  76083. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76084. */
  76085. export class BoundingBoxRenderer implements ISceneComponent {
  76086. /**
  76087. * The component name helpfull to identify the component in the list of scene components.
  76088. */
  76089. readonly name: string;
  76090. /**
  76091. * The scene the component belongs to.
  76092. */
  76093. scene: Scene;
  76094. /**
  76095. * Color of the bounding box lines placed in front of an object
  76096. */
  76097. frontColor: Color3;
  76098. /**
  76099. * Color of the bounding box lines placed behind an object
  76100. */
  76101. backColor: Color3;
  76102. /**
  76103. * Defines if the renderer should show the back lines or not
  76104. */
  76105. showBackLines: boolean;
  76106. /**
  76107. * Observable raised before rendering a bounding box
  76108. */
  76109. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76110. /**
  76111. * Observable raised after rendering a bounding box
  76112. */
  76113. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76114. /**
  76115. * Observable raised after resources are created
  76116. */
  76117. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76118. /**
  76119. * When false, no bounding boxes will be rendered
  76120. */
  76121. enabled: boolean;
  76122. /**
  76123. * @hidden
  76124. */
  76125. renderList: SmartArray<BoundingBox>;
  76126. private _colorShader;
  76127. private _vertexBuffers;
  76128. private _indexBuffer;
  76129. private _fillIndexBuffer;
  76130. private _fillIndexData;
  76131. /**
  76132. * Instantiates a new bounding box renderer in a scene.
  76133. * @param scene the scene the renderer renders in
  76134. */
  76135. constructor(scene: Scene);
  76136. /**
  76137. * Registers the component in a given scene
  76138. */
  76139. register(): void;
  76140. private _evaluateSubMesh;
  76141. private _preActiveMesh;
  76142. private _prepareResources;
  76143. private _createIndexBuffer;
  76144. /**
  76145. * Rebuilds the elements related to this component in case of
  76146. * context lost for instance.
  76147. */
  76148. rebuild(): void;
  76149. /**
  76150. * @hidden
  76151. */
  76152. reset(): void;
  76153. /**
  76154. * Render the bounding boxes of a specific rendering group
  76155. * @param renderingGroupId defines the rendering group to render
  76156. */
  76157. render(renderingGroupId: number): void;
  76158. /**
  76159. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76160. * @param mesh Define the mesh to render the occlusion bounding box for
  76161. */
  76162. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76163. /**
  76164. * Dispose and release the resources attached to this renderer.
  76165. */
  76166. dispose(): void;
  76167. }
  76168. }
  76169. declare module BABYLON {
  76170. interface Scene {
  76171. /** @hidden (Backing field) */
  76172. _depthRenderer: {
  76173. [id: string]: DepthRenderer;
  76174. };
  76175. /**
  76176. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76177. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76178. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76179. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76180. * @returns the created depth renderer
  76181. */
  76182. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76183. /**
  76184. * Disables a depth renderer for a given camera
  76185. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76186. */
  76187. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76188. }
  76189. /**
  76190. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76191. * in several rendering techniques.
  76192. */
  76193. export class DepthRendererSceneComponent implements ISceneComponent {
  76194. /**
  76195. * The component name helpfull to identify the component in the list of scene components.
  76196. */
  76197. readonly name: string;
  76198. /**
  76199. * The scene the component belongs to.
  76200. */
  76201. scene: Scene;
  76202. /**
  76203. * Creates a new instance of the component for the given scene
  76204. * @param scene Defines the scene to register the component in
  76205. */
  76206. constructor(scene: Scene);
  76207. /**
  76208. * Registers the component in a given scene
  76209. */
  76210. register(): void;
  76211. /**
  76212. * Rebuilds the elements related to this component in case of
  76213. * context lost for instance.
  76214. */
  76215. rebuild(): void;
  76216. /**
  76217. * Disposes the component and the associated ressources
  76218. */
  76219. dispose(): void;
  76220. private _gatherRenderTargets;
  76221. private _gatherActiveCameraRenderTargets;
  76222. }
  76223. }
  76224. declare module BABYLON {
  76225. interface AbstractScene {
  76226. /** @hidden (Backing field) */
  76227. _prePassRenderer: Nullable<PrePassRenderer>;
  76228. /**
  76229. * Gets or Sets the current prepass renderer associated to the scene.
  76230. */
  76231. prePassRenderer: Nullable<PrePassRenderer>;
  76232. /**
  76233. * Enables the prepass and associates it with the scene
  76234. * @returns the PrePassRenderer
  76235. */
  76236. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76237. /**
  76238. * Disables the prepass associated with the scene
  76239. */
  76240. disablePrePassRenderer(): void;
  76241. }
  76242. /**
  76243. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76244. * in several rendering techniques.
  76245. */
  76246. export class PrePassRendererSceneComponent implements ISceneComponent {
  76247. /**
  76248. * The component name helpful to identify the component in the list of scene components.
  76249. */
  76250. readonly name: string;
  76251. /**
  76252. * The scene the component belongs to.
  76253. */
  76254. scene: Scene;
  76255. /**
  76256. * Creates a new instance of the component for the given scene
  76257. * @param scene Defines the scene to register the component in
  76258. */
  76259. constructor(scene: Scene);
  76260. /**
  76261. * Registers the component in a given scene
  76262. */
  76263. register(): void;
  76264. private _beforeCameraDraw;
  76265. private _afterCameraDraw;
  76266. private _beforeClearStage;
  76267. private _beforeRenderingMeshStage;
  76268. private _afterRenderingMeshStage;
  76269. /**
  76270. * Rebuilds the elements related to this component in case of
  76271. * context lost for instance.
  76272. */
  76273. rebuild(): void;
  76274. /**
  76275. * Disposes the component and the associated ressources
  76276. */
  76277. dispose(): void;
  76278. }
  76279. }
  76280. declare module BABYLON {
  76281. /** @hidden */
  76282. export var fibonacci: {
  76283. name: string;
  76284. shader: string;
  76285. };
  76286. }
  76287. declare module BABYLON {
  76288. /** @hidden */
  76289. export var diffusionProfile: {
  76290. name: string;
  76291. shader: string;
  76292. };
  76293. }
  76294. declare module BABYLON {
  76295. /** @hidden */
  76296. export var subSurfaceScatteringPixelShader: {
  76297. name: string;
  76298. shader: string;
  76299. };
  76300. }
  76301. declare module BABYLON {
  76302. /**
  76303. * Sub surface scattering post process
  76304. */
  76305. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76306. /**
  76307. * Gets a string identifying the name of the class
  76308. * @returns "SubSurfaceScatteringPostProcess" string
  76309. */
  76310. getClassName(): string;
  76311. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76312. }
  76313. }
  76314. declare module BABYLON {
  76315. /**
  76316. * Contains all parameters needed for the prepass to perform
  76317. * screen space subsurface scattering
  76318. */
  76319. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76320. /** @hidden */
  76321. static _SceneComponentInitialization: (scene: Scene) => void;
  76322. private _ssDiffusionS;
  76323. private _ssFilterRadii;
  76324. private _ssDiffusionD;
  76325. /**
  76326. * Post process to attach for screen space subsurface scattering
  76327. */
  76328. postProcess: SubSurfaceScatteringPostProcess;
  76329. /**
  76330. * Diffusion profile color for subsurface scattering
  76331. */
  76332. get ssDiffusionS(): number[];
  76333. /**
  76334. * Diffusion profile max color channel value for subsurface scattering
  76335. */
  76336. get ssDiffusionD(): number[];
  76337. /**
  76338. * Diffusion profile filter radius for subsurface scattering
  76339. */
  76340. get ssFilterRadii(): number[];
  76341. /**
  76342. * Is subsurface enabled
  76343. */
  76344. enabled: boolean;
  76345. /**
  76346. * Name of the configuration
  76347. */
  76348. name: string;
  76349. /**
  76350. * Diffusion profile colors for subsurface scattering
  76351. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76352. * See ...
  76353. * Note that you can only store up to 5 of them
  76354. */
  76355. ssDiffusionProfileColors: Color3[];
  76356. /**
  76357. * Defines the ratio real world => scene units.
  76358. * Used for subsurface scattering
  76359. */
  76360. metersPerUnit: number;
  76361. /**
  76362. * Textures that should be present in the MRT for this effect to work
  76363. */
  76364. readonly texturesRequired: number[];
  76365. private _scene;
  76366. /**
  76367. * Builds a subsurface configuration object
  76368. * @param scene The scene
  76369. */
  76370. constructor(scene: Scene);
  76371. /**
  76372. * Adds a new diffusion profile.
  76373. * Useful for more realistic subsurface scattering on diverse materials.
  76374. * @param color The color of the diffusion profile. Should be the average color of the material.
  76375. * @return The index of the diffusion profile for the material subsurface configuration
  76376. */
  76377. addDiffusionProfile(color: Color3): number;
  76378. /**
  76379. * Creates the sss post process
  76380. * @return The created post process
  76381. */
  76382. createPostProcess(): SubSurfaceScatteringPostProcess;
  76383. /**
  76384. * Deletes all diffusion profiles.
  76385. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76386. */
  76387. clearAllDiffusionProfiles(): void;
  76388. /**
  76389. * Disposes this object
  76390. */
  76391. dispose(): void;
  76392. /**
  76393. * @hidden
  76394. * https://zero-radiance.github.io/post/sampling-diffusion/
  76395. *
  76396. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76397. * ------------------------------------------------------------------------------------
  76398. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76399. * PDF[r, phi, s] = r * R[r, phi, s]
  76400. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76401. * ------------------------------------------------------------------------------------
  76402. * We importance sample the color channel with the widest scattering distance.
  76403. */
  76404. getDiffusionProfileParameters(color: Color3): number;
  76405. /**
  76406. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76407. * 'u' is the random number (the value of the CDF): [0, 1).
  76408. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76409. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76410. */
  76411. private _sampleBurleyDiffusionProfile;
  76412. }
  76413. }
  76414. declare module BABYLON {
  76415. interface AbstractScene {
  76416. /** @hidden (Backing field) */
  76417. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76418. /**
  76419. * Gets or Sets the current prepass renderer associated to the scene.
  76420. */
  76421. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76422. /**
  76423. * Enables the subsurface effect for prepass
  76424. * @returns the SubSurfaceConfiguration
  76425. */
  76426. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76427. /**
  76428. * Disables the subsurface effect for prepass
  76429. */
  76430. disableSubSurfaceForPrePass(): void;
  76431. }
  76432. /**
  76433. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76434. * in several rendering techniques.
  76435. */
  76436. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76437. /**
  76438. * The component name helpful to identify the component in the list of scene components.
  76439. */
  76440. readonly name: string;
  76441. /**
  76442. * The scene the component belongs to.
  76443. */
  76444. scene: Scene;
  76445. /**
  76446. * Creates a new instance of the component for the given scene
  76447. * @param scene Defines the scene to register the component in
  76448. */
  76449. constructor(scene: Scene);
  76450. /**
  76451. * Registers the component in a given scene
  76452. */
  76453. register(): void;
  76454. /**
  76455. * Serializes the component data to the specified json object
  76456. * @param serializationObject The object to serialize to
  76457. */
  76458. serialize(serializationObject: any): void;
  76459. /**
  76460. * Adds all the elements from the container to the scene
  76461. * @param container the container holding the elements
  76462. */
  76463. addFromContainer(container: AbstractScene): void;
  76464. /**
  76465. * Removes all the elements in the container from the scene
  76466. * @param container contains the elements to remove
  76467. * @param dispose if the removed element should be disposed (default: false)
  76468. */
  76469. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76470. /**
  76471. * Rebuilds the elements related to this component in case of
  76472. * context lost for instance.
  76473. */
  76474. rebuild(): void;
  76475. /**
  76476. * Disposes the component and the associated ressources
  76477. */
  76478. dispose(): void;
  76479. }
  76480. }
  76481. declare module BABYLON {
  76482. /** @hidden */
  76483. export var outlinePixelShader: {
  76484. name: string;
  76485. shader: string;
  76486. };
  76487. }
  76488. declare module BABYLON {
  76489. /** @hidden */
  76490. export var outlineVertexShader: {
  76491. name: string;
  76492. shader: string;
  76493. };
  76494. }
  76495. declare module BABYLON {
  76496. interface Scene {
  76497. /** @hidden */
  76498. _outlineRenderer: OutlineRenderer;
  76499. /**
  76500. * Gets the outline renderer associated with the scene
  76501. * @returns a OutlineRenderer
  76502. */
  76503. getOutlineRenderer(): OutlineRenderer;
  76504. }
  76505. interface AbstractMesh {
  76506. /** @hidden (Backing field) */
  76507. _renderOutline: boolean;
  76508. /**
  76509. * Gets or sets a boolean indicating if the outline must be rendered as well
  76510. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76511. */
  76512. renderOutline: boolean;
  76513. /** @hidden (Backing field) */
  76514. _renderOverlay: boolean;
  76515. /**
  76516. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76517. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76518. */
  76519. renderOverlay: boolean;
  76520. }
  76521. /**
  76522. * This class is responsible to draw bothe outline/overlay of meshes.
  76523. * It should not be used directly but through the available method on mesh.
  76524. */
  76525. export class OutlineRenderer implements ISceneComponent {
  76526. /**
  76527. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76528. */
  76529. private static _StencilReference;
  76530. /**
  76531. * The name of the component. Each component must have a unique name.
  76532. */
  76533. name: string;
  76534. /**
  76535. * The scene the component belongs to.
  76536. */
  76537. scene: Scene;
  76538. /**
  76539. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76540. */
  76541. zOffset: number;
  76542. private _engine;
  76543. private _effect;
  76544. private _cachedDefines;
  76545. private _savedDepthWrite;
  76546. /**
  76547. * Instantiates a new outline renderer. (There could be only one per scene).
  76548. * @param scene Defines the scene it belongs to
  76549. */
  76550. constructor(scene: Scene);
  76551. /**
  76552. * Register the component to one instance of a scene.
  76553. */
  76554. register(): void;
  76555. /**
  76556. * Rebuilds the elements related to this component in case of
  76557. * context lost for instance.
  76558. */
  76559. rebuild(): void;
  76560. /**
  76561. * Disposes the component and the associated ressources.
  76562. */
  76563. dispose(): void;
  76564. /**
  76565. * Renders the outline in the canvas.
  76566. * @param subMesh Defines the sumesh to render
  76567. * @param batch Defines the batch of meshes in case of instances
  76568. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76569. */
  76570. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76571. /**
  76572. * Returns whether or not the outline renderer is ready for a given submesh.
  76573. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76574. * @param subMesh Defines the submesh to check readyness for
  76575. * @param useInstances Defines wheter wee are trying to render instances or not
  76576. * @returns true if ready otherwise false
  76577. */
  76578. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76579. private _beforeRenderingMesh;
  76580. private _afterRenderingMesh;
  76581. }
  76582. }
  76583. declare module BABYLON {
  76584. /**
  76585. * Defines the basic options interface of a Sprite Frame Source Size.
  76586. */
  76587. export interface ISpriteJSONSpriteSourceSize {
  76588. /**
  76589. * number of the original width of the Frame
  76590. */
  76591. w: number;
  76592. /**
  76593. * number of the original height of the Frame
  76594. */
  76595. h: number;
  76596. }
  76597. /**
  76598. * Defines the basic options interface of a Sprite Frame Data.
  76599. */
  76600. export interface ISpriteJSONSpriteFrameData {
  76601. /**
  76602. * number of the x offset of the Frame
  76603. */
  76604. x: number;
  76605. /**
  76606. * number of the y offset of the Frame
  76607. */
  76608. y: number;
  76609. /**
  76610. * number of the width of the Frame
  76611. */
  76612. w: number;
  76613. /**
  76614. * number of the height of the Frame
  76615. */
  76616. h: number;
  76617. }
  76618. /**
  76619. * Defines the basic options interface of a JSON Sprite.
  76620. */
  76621. export interface ISpriteJSONSprite {
  76622. /**
  76623. * string name of the Frame
  76624. */
  76625. filename: string;
  76626. /**
  76627. * ISpriteJSONSpriteFrame basic object of the frame data
  76628. */
  76629. frame: ISpriteJSONSpriteFrameData;
  76630. /**
  76631. * boolean to flag is the frame was rotated.
  76632. */
  76633. rotated: boolean;
  76634. /**
  76635. * boolean to flag is the frame was trimmed.
  76636. */
  76637. trimmed: boolean;
  76638. /**
  76639. * ISpriteJSONSpriteFrame basic object of the source data
  76640. */
  76641. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76642. /**
  76643. * ISpriteJSONSpriteFrame basic object of the source data
  76644. */
  76645. sourceSize: ISpriteJSONSpriteSourceSize;
  76646. }
  76647. /**
  76648. * Defines the basic options interface of a JSON atlas.
  76649. */
  76650. export interface ISpriteJSONAtlas {
  76651. /**
  76652. * Array of objects that contain the frame data.
  76653. */
  76654. frames: Array<ISpriteJSONSprite>;
  76655. /**
  76656. * object basic object containing the sprite meta data.
  76657. */
  76658. meta?: object;
  76659. }
  76660. }
  76661. declare module BABYLON {
  76662. /** @hidden */
  76663. export var spriteMapPixelShader: {
  76664. name: string;
  76665. shader: string;
  76666. };
  76667. }
  76668. declare module BABYLON {
  76669. /** @hidden */
  76670. export var spriteMapVertexShader: {
  76671. name: string;
  76672. shader: string;
  76673. };
  76674. }
  76675. declare module BABYLON {
  76676. /**
  76677. * Defines the basic options interface of a SpriteMap
  76678. */
  76679. export interface ISpriteMapOptions {
  76680. /**
  76681. * Vector2 of the number of cells in the grid.
  76682. */
  76683. stageSize?: Vector2;
  76684. /**
  76685. * Vector2 of the size of the output plane in World Units.
  76686. */
  76687. outputSize?: Vector2;
  76688. /**
  76689. * Vector3 of the position of the output plane in World Units.
  76690. */
  76691. outputPosition?: Vector3;
  76692. /**
  76693. * Vector3 of the rotation of the output plane.
  76694. */
  76695. outputRotation?: Vector3;
  76696. /**
  76697. * number of layers that the system will reserve in resources.
  76698. */
  76699. layerCount?: number;
  76700. /**
  76701. * number of max animation frames a single cell will reserve in resources.
  76702. */
  76703. maxAnimationFrames?: number;
  76704. /**
  76705. * number cell index of the base tile when the system compiles.
  76706. */
  76707. baseTile?: number;
  76708. /**
  76709. * boolean flip the sprite after its been repositioned by the framing data.
  76710. */
  76711. flipU?: boolean;
  76712. /**
  76713. * Vector3 scalar of the global RGB values of the SpriteMap.
  76714. */
  76715. colorMultiply?: Vector3;
  76716. }
  76717. /**
  76718. * Defines the IDisposable interface in order to be cleanable from resources.
  76719. */
  76720. export interface ISpriteMap extends IDisposable {
  76721. /**
  76722. * String name of the SpriteMap.
  76723. */
  76724. name: string;
  76725. /**
  76726. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76727. */
  76728. atlasJSON: ISpriteJSONAtlas;
  76729. /**
  76730. * Texture of the SpriteMap.
  76731. */
  76732. spriteSheet: Texture;
  76733. /**
  76734. * The parameters to initialize the SpriteMap with.
  76735. */
  76736. options: ISpriteMapOptions;
  76737. }
  76738. /**
  76739. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76740. */
  76741. export class SpriteMap implements ISpriteMap {
  76742. /** The Name of the spriteMap */
  76743. name: string;
  76744. /** The JSON file with the frame and meta data */
  76745. atlasJSON: ISpriteJSONAtlas;
  76746. /** The systems Sprite Sheet Texture */
  76747. spriteSheet: Texture;
  76748. /** Arguments passed with the Constructor */
  76749. options: ISpriteMapOptions;
  76750. /** Public Sprite Storage array, parsed from atlasJSON */
  76751. sprites: Array<ISpriteJSONSprite>;
  76752. /** Returns the Number of Sprites in the System */
  76753. get spriteCount(): number;
  76754. /** Returns the Position of Output Plane*/
  76755. get position(): Vector3;
  76756. /** Returns the Position of Output Plane*/
  76757. set position(v: Vector3);
  76758. /** Returns the Rotation of Output Plane*/
  76759. get rotation(): Vector3;
  76760. /** Returns the Rotation of Output Plane*/
  76761. set rotation(v: Vector3);
  76762. /** Sets the AnimationMap*/
  76763. get animationMap(): RawTexture;
  76764. /** Sets the AnimationMap*/
  76765. set animationMap(v: RawTexture);
  76766. /** Scene that the SpriteMap was created in */
  76767. private _scene;
  76768. /** Texture Buffer of Float32 that holds tile frame data*/
  76769. private _frameMap;
  76770. /** Texture Buffers of Float32 that holds tileMap data*/
  76771. private _tileMaps;
  76772. /** Texture Buffer of Float32 that holds Animation Data*/
  76773. private _animationMap;
  76774. /** Custom ShaderMaterial Central to the System*/
  76775. private _material;
  76776. /** Custom ShaderMaterial Central to the System*/
  76777. private _output;
  76778. /** Systems Time Ticker*/
  76779. private _time;
  76780. /**
  76781. * Creates a new SpriteMap
  76782. * @param name defines the SpriteMaps Name
  76783. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76784. * @param spriteSheet is the Texture that the Sprites are on.
  76785. * @param options a basic deployment configuration
  76786. * @param scene The Scene that the map is deployed on
  76787. */
  76788. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76789. /**
  76790. * Returns tileID location
  76791. * @returns Vector2 the cell position ID
  76792. */
  76793. getTileID(): Vector2;
  76794. /**
  76795. * Gets the UV location of the mouse over the SpriteMap.
  76796. * @returns Vector2 the UV position of the mouse interaction
  76797. */
  76798. getMousePosition(): Vector2;
  76799. /**
  76800. * Creates the "frame" texture Buffer
  76801. * -------------------------------------
  76802. * Structure of frames
  76803. * "filename": "Falling-Water-2.png",
  76804. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76805. * "rotated": true,
  76806. * "trimmed": true,
  76807. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76808. * "sourceSize": {"w":32,"h":32}
  76809. * @returns RawTexture of the frameMap
  76810. */
  76811. private _createFrameBuffer;
  76812. /**
  76813. * Creates the tileMap texture Buffer
  76814. * @param buffer normally and array of numbers, or a false to generate from scratch
  76815. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76816. * @returns RawTexture of the tileMap
  76817. */
  76818. private _createTileBuffer;
  76819. /**
  76820. * Modifies the data of the tileMaps
  76821. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76822. * @param pos is the iVector2 Coordinates of the Tile
  76823. * @param tile The SpriteIndex of the new Tile
  76824. */
  76825. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76826. /**
  76827. * Creates the animationMap texture Buffer
  76828. * @param buffer normally and array of numbers, or a false to generate from scratch
  76829. * @returns RawTexture of the animationMap
  76830. */
  76831. private _createTileAnimationBuffer;
  76832. /**
  76833. * Modifies the data of the animationMap
  76834. * @param cellID is the Index of the Sprite
  76835. * @param _frame is the target Animation frame
  76836. * @param toCell is the Target Index of the next frame of the animation
  76837. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76838. * @param speed is a global scalar of the time variable on the map.
  76839. */
  76840. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76841. /**
  76842. * Exports the .tilemaps file
  76843. */
  76844. saveTileMaps(): void;
  76845. /**
  76846. * Imports the .tilemaps file
  76847. * @param url of the .tilemaps file
  76848. */
  76849. loadTileMaps(url: string): void;
  76850. /**
  76851. * Release associated resources
  76852. */
  76853. dispose(): void;
  76854. }
  76855. }
  76856. declare module BABYLON {
  76857. /**
  76858. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76859. * @see https://doc.babylonjs.com/babylon101/sprites
  76860. */
  76861. export class SpritePackedManager extends SpriteManager {
  76862. /** defines the packed manager's name */
  76863. name: string;
  76864. /**
  76865. * Creates a new sprite manager from a packed sprite sheet
  76866. * @param name defines the manager's name
  76867. * @param imgUrl defines the sprite sheet url
  76868. * @param capacity defines the maximum allowed number of sprites
  76869. * @param scene defines the hosting scene
  76870. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76871. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76872. * @param samplingMode defines the smapling mode to use with spritesheet
  76873. * @param fromPacked set to true; do not alter
  76874. */
  76875. constructor(
  76876. /** defines the packed manager's name */
  76877. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76878. }
  76879. }
  76880. declare module BABYLON {
  76881. /**
  76882. * Defines the list of states available for a task inside a AssetsManager
  76883. */
  76884. export enum AssetTaskState {
  76885. /**
  76886. * Initialization
  76887. */
  76888. INIT = 0,
  76889. /**
  76890. * Running
  76891. */
  76892. RUNNING = 1,
  76893. /**
  76894. * Done
  76895. */
  76896. DONE = 2,
  76897. /**
  76898. * Error
  76899. */
  76900. ERROR = 3
  76901. }
  76902. /**
  76903. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76904. */
  76905. export abstract class AbstractAssetTask {
  76906. /**
  76907. * Task name
  76908. */ name: string;
  76909. /**
  76910. * Callback called when the task is successful
  76911. */
  76912. onSuccess: (task: any) => void;
  76913. /**
  76914. * Callback called when the task is not successful
  76915. */
  76916. onError: (task: any, message?: string, exception?: any) => void;
  76917. /**
  76918. * Creates a new AssetsManager
  76919. * @param name defines the name of the task
  76920. */
  76921. constructor(
  76922. /**
  76923. * Task name
  76924. */ name: string);
  76925. private _isCompleted;
  76926. private _taskState;
  76927. private _errorObject;
  76928. /**
  76929. * Get if the task is completed
  76930. */
  76931. get isCompleted(): boolean;
  76932. /**
  76933. * Gets the current state of the task
  76934. */
  76935. get taskState(): AssetTaskState;
  76936. /**
  76937. * Gets the current error object (if task is in error)
  76938. */
  76939. get errorObject(): {
  76940. message?: string;
  76941. exception?: any;
  76942. };
  76943. /**
  76944. * Internal only
  76945. * @hidden
  76946. */
  76947. _setErrorObject(message?: string, exception?: any): void;
  76948. /**
  76949. * Execute the current task
  76950. * @param scene defines the scene where you want your assets to be loaded
  76951. * @param onSuccess is a callback called when the task is successfully executed
  76952. * @param onError is a callback called if an error occurs
  76953. */
  76954. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76955. /**
  76956. * Execute the current task
  76957. * @param scene defines the scene where you want your assets to be loaded
  76958. * @param onSuccess is a callback called when the task is successfully executed
  76959. * @param onError is a callback called if an error occurs
  76960. */
  76961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76962. /**
  76963. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76964. * This can be used with failed tasks that have the reason for failure fixed.
  76965. */
  76966. reset(): void;
  76967. private onErrorCallback;
  76968. private onDoneCallback;
  76969. }
  76970. /**
  76971. * Define the interface used by progress events raised during assets loading
  76972. */
  76973. export interface IAssetsProgressEvent {
  76974. /**
  76975. * Defines the number of remaining tasks to process
  76976. */
  76977. remainingCount: number;
  76978. /**
  76979. * Defines the total number of tasks
  76980. */
  76981. totalCount: number;
  76982. /**
  76983. * Defines the task that was just processed
  76984. */
  76985. task: AbstractAssetTask;
  76986. }
  76987. /**
  76988. * Class used to share progress information about assets loading
  76989. */
  76990. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76991. /**
  76992. * Defines the number of remaining tasks to process
  76993. */
  76994. remainingCount: number;
  76995. /**
  76996. * Defines the total number of tasks
  76997. */
  76998. totalCount: number;
  76999. /**
  77000. * Defines the task that was just processed
  77001. */
  77002. task: AbstractAssetTask;
  77003. /**
  77004. * Creates a AssetsProgressEvent
  77005. * @param remainingCount defines the number of remaining tasks to process
  77006. * @param totalCount defines the total number of tasks
  77007. * @param task defines the task that was just processed
  77008. */
  77009. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77010. }
  77011. /**
  77012. * Define a task used by AssetsManager to load assets into a container
  77013. */
  77014. export class ContainerAssetTask extends AbstractAssetTask {
  77015. /**
  77016. * Defines the name of the task
  77017. */
  77018. name: string;
  77019. /**
  77020. * Defines the list of mesh's names you want to load
  77021. */
  77022. meshesNames: any;
  77023. /**
  77024. * Defines the root url to use as a base to load your meshes and associated resources
  77025. */
  77026. rootUrl: string;
  77027. /**
  77028. * Defines the filename or File of the scene to load from
  77029. */
  77030. sceneFilename: string | File;
  77031. /**
  77032. * Get the loaded asset container
  77033. */
  77034. loadedContainer: AssetContainer;
  77035. /**
  77036. * Gets the list of loaded meshes
  77037. */
  77038. loadedMeshes: Array<AbstractMesh>;
  77039. /**
  77040. * Gets the list of loaded particle systems
  77041. */
  77042. loadedParticleSystems: Array<IParticleSystem>;
  77043. /**
  77044. * Gets the list of loaded skeletons
  77045. */
  77046. loadedSkeletons: Array<Skeleton>;
  77047. /**
  77048. * Gets the list of loaded animation groups
  77049. */
  77050. loadedAnimationGroups: Array<AnimationGroup>;
  77051. /**
  77052. * Callback called when the task is successful
  77053. */
  77054. onSuccess: (task: ContainerAssetTask) => void;
  77055. /**
  77056. * Callback called when the task is successful
  77057. */
  77058. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77059. /**
  77060. * Creates a new ContainerAssetTask
  77061. * @param name defines the name of the task
  77062. * @param meshesNames defines the list of mesh's names you want to load
  77063. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77064. * @param sceneFilename defines the filename or File of the scene to load from
  77065. */
  77066. constructor(
  77067. /**
  77068. * Defines the name of the task
  77069. */
  77070. name: string,
  77071. /**
  77072. * Defines the list of mesh's names you want to load
  77073. */
  77074. meshesNames: any,
  77075. /**
  77076. * Defines the root url to use as a base to load your meshes and associated resources
  77077. */
  77078. rootUrl: string,
  77079. /**
  77080. * Defines the filename or File of the scene to load from
  77081. */
  77082. sceneFilename: string | File);
  77083. /**
  77084. * Execute the current task
  77085. * @param scene defines the scene where you want your assets to be loaded
  77086. * @param onSuccess is a callback called when the task is successfully executed
  77087. * @param onError is a callback called if an error occurs
  77088. */
  77089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77090. }
  77091. /**
  77092. * Define a task used by AssetsManager to load meshes
  77093. */
  77094. export class MeshAssetTask extends AbstractAssetTask {
  77095. /**
  77096. * Defines the name of the task
  77097. */
  77098. name: string;
  77099. /**
  77100. * Defines the list of mesh's names you want to load
  77101. */
  77102. meshesNames: any;
  77103. /**
  77104. * Defines the root url to use as a base to load your meshes and associated resources
  77105. */
  77106. rootUrl: string;
  77107. /**
  77108. * Defines the filename or File of the scene to load from
  77109. */
  77110. sceneFilename: string | File;
  77111. /**
  77112. * Gets the list of loaded meshes
  77113. */
  77114. loadedMeshes: Array<AbstractMesh>;
  77115. /**
  77116. * Gets the list of loaded particle systems
  77117. */
  77118. loadedParticleSystems: Array<IParticleSystem>;
  77119. /**
  77120. * Gets the list of loaded skeletons
  77121. */
  77122. loadedSkeletons: Array<Skeleton>;
  77123. /**
  77124. * Gets the list of loaded animation groups
  77125. */
  77126. loadedAnimationGroups: Array<AnimationGroup>;
  77127. /**
  77128. * Callback called when the task is successful
  77129. */
  77130. onSuccess: (task: MeshAssetTask) => void;
  77131. /**
  77132. * Callback called when the task is successful
  77133. */
  77134. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77135. /**
  77136. * Creates a new MeshAssetTask
  77137. * @param name defines the name of the task
  77138. * @param meshesNames defines the list of mesh's names you want to load
  77139. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77140. * @param sceneFilename defines the filename or File of the scene to load from
  77141. */
  77142. constructor(
  77143. /**
  77144. * Defines the name of the task
  77145. */
  77146. name: string,
  77147. /**
  77148. * Defines the list of mesh's names you want to load
  77149. */
  77150. meshesNames: any,
  77151. /**
  77152. * Defines the root url to use as a base to load your meshes and associated resources
  77153. */
  77154. rootUrl: string,
  77155. /**
  77156. * Defines the filename or File of the scene to load from
  77157. */
  77158. sceneFilename: string | File);
  77159. /**
  77160. * Execute the current task
  77161. * @param scene defines the scene where you want your assets to be loaded
  77162. * @param onSuccess is a callback called when the task is successfully executed
  77163. * @param onError is a callback called if an error occurs
  77164. */
  77165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77166. }
  77167. /**
  77168. * Define a task used by AssetsManager to load text content
  77169. */
  77170. export class TextFileAssetTask extends AbstractAssetTask {
  77171. /**
  77172. * Defines the name of the task
  77173. */
  77174. name: string;
  77175. /**
  77176. * Defines the location of the file to load
  77177. */
  77178. url: string;
  77179. /**
  77180. * Gets the loaded text string
  77181. */
  77182. text: string;
  77183. /**
  77184. * Callback called when the task is successful
  77185. */
  77186. onSuccess: (task: TextFileAssetTask) => void;
  77187. /**
  77188. * Callback called when the task is successful
  77189. */
  77190. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77191. /**
  77192. * Creates a new TextFileAssetTask object
  77193. * @param name defines the name of the task
  77194. * @param url defines the location of the file to load
  77195. */
  77196. constructor(
  77197. /**
  77198. * Defines the name of the task
  77199. */
  77200. name: string,
  77201. /**
  77202. * Defines the location of the file to load
  77203. */
  77204. url: string);
  77205. /**
  77206. * Execute the current task
  77207. * @param scene defines the scene where you want your assets to be loaded
  77208. * @param onSuccess is a callback called when the task is successfully executed
  77209. * @param onError is a callback called if an error occurs
  77210. */
  77211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77212. }
  77213. /**
  77214. * Define a task used by AssetsManager to load binary data
  77215. */
  77216. export class BinaryFileAssetTask extends AbstractAssetTask {
  77217. /**
  77218. * Defines the name of the task
  77219. */
  77220. name: string;
  77221. /**
  77222. * Defines the location of the file to load
  77223. */
  77224. url: string;
  77225. /**
  77226. * Gets the lodaded data (as an array buffer)
  77227. */
  77228. data: ArrayBuffer;
  77229. /**
  77230. * Callback called when the task is successful
  77231. */
  77232. onSuccess: (task: BinaryFileAssetTask) => void;
  77233. /**
  77234. * Callback called when the task is successful
  77235. */
  77236. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77237. /**
  77238. * Creates a new BinaryFileAssetTask object
  77239. * @param name defines the name of the new task
  77240. * @param url defines the location of the file to load
  77241. */
  77242. constructor(
  77243. /**
  77244. * Defines the name of the task
  77245. */
  77246. name: string,
  77247. /**
  77248. * Defines the location of the file to load
  77249. */
  77250. url: string);
  77251. /**
  77252. * Execute the current task
  77253. * @param scene defines the scene where you want your assets to be loaded
  77254. * @param onSuccess is a callback called when the task is successfully executed
  77255. * @param onError is a callback called if an error occurs
  77256. */
  77257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77258. }
  77259. /**
  77260. * Define a task used by AssetsManager to load images
  77261. */
  77262. export class ImageAssetTask extends AbstractAssetTask {
  77263. /**
  77264. * Defines the name of the task
  77265. */
  77266. name: string;
  77267. /**
  77268. * Defines the location of the image to load
  77269. */
  77270. url: string;
  77271. /**
  77272. * Gets the loaded images
  77273. */
  77274. image: HTMLImageElement;
  77275. /**
  77276. * Callback called when the task is successful
  77277. */
  77278. onSuccess: (task: ImageAssetTask) => void;
  77279. /**
  77280. * Callback called when the task is successful
  77281. */
  77282. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77283. /**
  77284. * Creates a new ImageAssetTask
  77285. * @param name defines the name of the task
  77286. * @param url defines the location of the image to load
  77287. */
  77288. constructor(
  77289. /**
  77290. * Defines the name of the task
  77291. */
  77292. name: string,
  77293. /**
  77294. * Defines the location of the image to load
  77295. */
  77296. url: string);
  77297. /**
  77298. * Execute the current task
  77299. * @param scene defines the scene where you want your assets to be loaded
  77300. * @param onSuccess is a callback called when the task is successfully executed
  77301. * @param onError is a callback called if an error occurs
  77302. */
  77303. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77304. }
  77305. /**
  77306. * Defines the interface used by texture loading tasks
  77307. */
  77308. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77309. /**
  77310. * Gets the loaded texture
  77311. */
  77312. texture: TEX;
  77313. }
  77314. /**
  77315. * Define a task used by AssetsManager to load 2D textures
  77316. */
  77317. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77318. /**
  77319. * Defines the name of the task
  77320. */
  77321. name: string;
  77322. /**
  77323. * Defines the location of the file to load
  77324. */
  77325. url: string;
  77326. /**
  77327. * Defines if mipmap should not be generated (default is false)
  77328. */
  77329. noMipmap?: boolean | undefined;
  77330. /**
  77331. * Defines if texture must be inverted on Y axis (default is true)
  77332. */
  77333. invertY: boolean;
  77334. /**
  77335. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77336. */
  77337. samplingMode: number;
  77338. /**
  77339. * Gets the loaded texture
  77340. */
  77341. texture: Texture;
  77342. /**
  77343. * Callback called when the task is successful
  77344. */
  77345. onSuccess: (task: TextureAssetTask) => void;
  77346. /**
  77347. * Callback called when the task is successful
  77348. */
  77349. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77350. /**
  77351. * Creates a new TextureAssetTask object
  77352. * @param name defines the name of the task
  77353. * @param url defines the location of the file to load
  77354. * @param noMipmap defines if mipmap should not be generated (default is false)
  77355. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77356. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77357. */
  77358. constructor(
  77359. /**
  77360. * Defines the name of the task
  77361. */
  77362. name: string,
  77363. /**
  77364. * Defines the location of the file to load
  77365. */
  77366. url: string,
  77367. /**
  77368. * Defines if mipmap should not be generated (default is false)
  77369. */
  77370. noMipmap?: boolean | undefined,
  77371. /**
  77372. * Defines if texture must be inverted on Y axis (default is true)
  77373. */
  77374. invertY?: boolean,
  77375. /**
  77376. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77377. */
  77378. samplingMode?: number);
  77379. /**
  77380. * Execute the current task
  77381. * @param scene defines the scene where you want your assets to be loaded
  77382. * @param onSuccess is a callback called when the task is successfully executed
  77383. * @param onError is a callback called if an error occurs
  77384. */
  77385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77386. }
  77387. /**
  77388. * Define a task used by AssetsManager to load cube textures
  77389. */
  77390. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77391. /**
  77392. * Defines the name of the task
  77393. */
  77394. name: string;
  77395. /**
  77396. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77397. */
  77398. url: string;
  77399. /**
  77400. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77401. */
  77402. extensions?: string[] | undefined;
  77403. /**
  77404. * Defines if mipmaps should not be generated (default is false)
  77405. */
  77406. noMipmap?: boolean | undefined;
  77407. /**
  77408. * Defines the explicit list of files (undefined by default)
  77409. */
  77410. files?: string[] | undefined;
  77411. /**
  77412. * Gets the loaded texture
  77413. */
  77414. texture: CubeTexture;
  77415. /**
  77416. * Callback called when the task is successful
  77417. */
  77418. onSuccess: (task: CubeTextureAssetTask) => void;
  77419. /**
  77420. * Callback called when the task is successful
  77421. */
  77422. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77423. /**
  77424. * Creates a new CubeTextureAssetTask
  77425. * @param name defines the name of the task
  77426. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77427. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77428. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77429. * @param files defines the explicit list of files (undefined by default)
  77430. */
  77431. constructor(
  77432. /**
  77433. * Defines the name of the task
  77434. */
  77435. name: string,
  77436. /**
  77437. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77438. */
  77439. url: string,
  77440. /**
  77441. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77442. */
  77443. extensions?: string[] | undefined,
  77444. /**
  77445. * Defines if mipmaps should not be generated (default is false)
  77446. */
  77447. noMipmap?: boolean | undefined,
  77448. /**
  77449. * Defines the explicit list of files (undefined by default)
  77450. */
  77451. files?: string[] | undefined);
  77452. /**
  77453. * Execute the current task
  77454. * @param scene defines the scene where you want your assets to be loaded
  77455. * @param onSuccess is a callback called when the task is successfully executed
  77456. * @param onError is a callback called if an error occurs
  77457. */
  77458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77459. }
  77460. /**
  77461. * Define a task used by AssetsManager to load HDR cube textures
  77462. */
  77463. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77464. /**
  77465. * Defines the name of the task
  77466. */
  77467. name: string;
  77468. /**
  77469. * Defines the location of the file to load
  77470. */
  77471. url: string;
  77472. /**
  77473. * Defines the desired size (the more it increases the longer the generation will be)
  77474. */
  77475. size: number;
  77476. /**
  77477. * Defines if mipmaps should not be generated (default is false)
  77478. */
  77479. noMipmap: boolean;
  77480. /**
  77481. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77482. */
  77483. generateHarmonics: boolean;
  77484. /**
  77485. * 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)
  77486. */
  77487. gammaSpace: boolean;
  77488. /**
  77489. * Internal Use Only
  77490. */
  77491. reserved: boolean;
  77492. /**
  77493. * Gets the loaded texture
  77494. */
  77495. texture: HDRCubeTexture;
  77496. /**
  77497. * Callback called when the task is successful
  77498. */
  77499. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77500. /**
  77501. * Callback called when the task is successful
  77502. */
  77503. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77504. /**
  77505. * Creates a new HDRCubeTextureAssetTask object
  77506. * @param name defines the name of the task
  77507. * @param url defines the location of the file to load
  77508. * @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.
  77509. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77510. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77511. * @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)
  77512. * @param reserved Internal use only
  77513. */
  77514. constructor(
  77515. /**
  77516. * Defines the name of the task
  77517. */
  77518. name: string,
  77519. /**
  77520. * Defines the location of the file to load
  77521. */
  77522. url: string,
  77523. /**
  77524. * Defines the desired size (the more it increases the longer the generation will be)
  77525. */
  77526. size: number,
  77527. /**
  77528. * Defines if mipmaps should not be generated (default is false)
  77529. */
  77530. noMipmap?: boolean,
  77531. /**
  77532. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77533. */
  77534. generateHarmonics?: boolean,
  77535. /**
  77536. * 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)
  77537. */
  77538. gammaSpace?: boolean,
  77539. /**
  77540. * Internal Use Only
  77541. */
  77542. reserved?: boolean);
  77543. /**
  77544. * Execute the current task
  77545. * @param scene defines the scene where you want your assets to be loaded
  77546. * @param onSuccess is a callback called when the task is successfully executed
  77547. * @param onError is a callback called if an error occurs
  77548. */
  77549. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77550. }
  77551. /**
  77552. * Define a task used by AssetsManager to load Equirectangular cube textures
  77553. */
  77554. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77555. /**
  77556. * Defines the name of the task
  77557. */
  77558. name: string;
  77559. /**
  77560. * Defines the location of the file to load
  77561. */
  77562. url: string;
  77563. /**
  77564. * Defines the desired size (the more it increases the longer the generation will be)
  77565. */
  77566. size: number;
  77567. /**
  77568. * Defines if mipmaps should not be generated (default is false)
  77569. */
  77570. noMipmap: boolean;
  77571. /**
  77572. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77573. * but the standard material would require them in Gamma space) (default is true)
  77574. */
  77575. gammaSpace: boolean;
  77576. /**
  77577. * Gets the loaded texture
  77578. */
  77579. texture: EquiRectangularCubeTexture;
  77580. /**
  77581. * Callback called when the task is successful
  77582. */
  77583. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77584. /**
  77585. * Callback called when the task is successful
  77586. */
  77587. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77588. /**
  77589. * Creates a new EquiRectangularCubeTextureAssetTask object
  77590. * @param name defines the name of the task
  77591. * @param url defines the location of the file to load
  77592. * @param size defines the desired size (the more it increases the longer the generation will be)
  77593. * If the size is omitted this implies you are using a preprocessed cubemap.
  77594. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77595. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77596. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77597. * (default is true)
  77598. */
  77599. constructor(
  77600. /**
  77601. * Defines the name of the task
  77602. */
  77603. name: string,
  77604. /**
  77605. * Defines the location of the file to load
  77606. */
  77607. url: string,
  77608. /**
  77609. * Defines the desired size (the more it increases the longer the generation will be)
  77610. */
  77611. size: number,
  77612. /**
  77613. * Defines if mipmaps should not be generated (default is false)
  77614. */
  77615. noMipmap?: boolean,
  77616. /**
  77617. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77618. * but the standard material would require them in Gamma space) (default is true)
  77619. */
  77620. gammaSpace?: boolean);
  77621. /**
  77622. * Execute the current task
  77623. * @param scene defines the scene where you want your assets to be loaded
  77624. * @param onSuccess is a callback called when the task is successfully executed
  77625. * @param onError is a callback called if an error occurs
  77626. */
  77627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77628. }
  77629. /**
  77630. * This class can be used to easily import assets into a scene
  77631. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77632. */
  77633. export class AssetsManager {
  77634. private _scene;
  77635. private _isLoading;
  77636. protected _tasks: AbstractAssetTask[];
  77637. protected _waitingTasksCount: number;
  77638. protected _totalTasksCount: number;
  77639. /**
  77640. * Callback called when all tasks are processed
  77641. */
  77642. onFinish: (tasks: AbstractAssetTask[]) => void;
  77643. /**
  77644. * Callback called when a task is successful
  77645. */
  77646. onTaskSuccess: (task: AbstractAssetTask) => void;
  77647. /**
  77648. * Callback called when a task had an error
  77649. */
  77650. onTaskError: (task: AbstractAssetTask) => void;
  77651. /**
  77652. * Callback called when a task is done (whatever the result is)
  77653. */
  77654. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77655. /**
  77656. * Observable called when all tasks are processed
  77657. */
  77658. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77659. /**
  77660. * Observable called when a task had an error
  77661. */
  77662. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77663. /**
  77664. * Observable called when all tasks were executed
  77665. */
  77666. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77667. /**
  77668. * Observable called when a task is done (whatever the result is)
  77669. */
  77670. onProgressObservable: Observable<IAssetsProgressEvent>;
  77671. /**
  77672. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77673. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77674. */
  77675. useDefaultLoadingScreen: boolean;
  77676. /**
  77677. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77678. * when all assets have been downloaded.
  77679. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77680. */
  77681. autoHideLoadingUI: boolean;
  77682. /**
  77683. * Creates a new AssetsManager
  77684. * @param scene defines the scene to work on
  77685. */
  77686. constructor(scene: Scene);
  77687. /**
  77688. * Add a ContainerAssetTask to the list of active tasks
  77689. * @param taskName defines the name of the new task
  77690. * @param meshesNames defines the name of meshes to load
  77691. * @param rootUrl defines the root url to use to locate files
  77692. * @param sceneFilename defines the filename of the scene file
  77693. * @returns a new ContainerAssetTask object
  77694. */
  77695. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77696. /**
  77697. * Add a MeshAssetTask to the list of active tasks
  77698. * @param taskName defines the name of the new task
  77699. * @param meshesNames defines the name of meshes to load
  77700. * @param rootUrl defines the root url to use to locate files
  77701. * @param sceneFilename defines the filename of the scene file
  77702. * @returns a new MeshAssetTask object
  77703. */
  77704. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77705. /**
  77706. * Add a TextFileAssetTask to the list of active tasks
  77707. * @param taskName defines the name of the new task
  77708. * @param url defines the url of the file to load
  77709. * @returns a new TextFileAssetTask object
  77710. */
  77711. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77712. /**
  77713. * Add a BinaryFileAssetTask to the list of active tasks
  77714. * @param taskName defines the name of the new task
  77715. * @param url defines the url of the file to load
  77716. * @returns a new BinaryFileAssetTask object
  77717. */
  77718. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77719. /**
  77720. * Add a ImageAssetTask to the list of active tasks
  77721. * @param taskName defines the name of the new task
  77722. * @param url defines the url of the file to load
  77723. * @returns a new ImageAssetTask object
  77724. */
  77725. addImageTask(taskName: string, url: string): ImageAssetTask;
  77726. /**
  77727. * Add a TextureAssetTask to the list of active tasks
  77728. * @param taskName defines the name of the new task
  77729. * @param url defines the url of the file to load
  77730. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77731. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77732. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77733. * @returns a new TextureAssetTask object
  77734. */
  77735. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77736. /**
  77737. * Add a CubeTextureAssetTask to the list of active tasks
  77738. * @param taskName defines the name of the new task
  77739. * @param url defines the url of the file to load
  77740. * @param extensions defines the extension to use to load the cube map (can be null)
  77741. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77742. * @param files defines the list of files to load (can be null)
  77743. * @returns a new CubeTextureAssetTask object
  77744. */
  77745. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77746. /**
  77747. *
  77748. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77749. * @param taskName defines the name of the new task
  77750. * @param url defines the url of the file to load
  77751. * @param size defines the size you want for the cubemap (can be null)
  77752. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77753. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77754. * @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)
  77755. * @param reserved Internal use only
  77756. * @returns a new HDRCubeTextureAssetTask object
  77757. */
  77758. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77759. /**
  77760. *
  77761. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77762. * @param taskName defines the name of the new task
  77763. * @param url defines the url of the file to load
  77764. * @param size defines the size you want for the cubemap (can be null)
  77765. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77766. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77767. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77768. * @returns a new EquiRectangularCubeTextureAssetTask object
  77769. */
  77770. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77771. /**
  77772. * Remove a task from the assets manager.
  77773. * @param task the task to remove
  77774. */
  77775. removeTask(task: AbstractAssetTask): void;
  77776. private _decreaseWaitingTasksCount;
  77777. private _runTask;
  77778. /**
  77779. * Reset the AssetsManager and remove all tasks
  77780. * @return the current instance of the AssetsManager
  77781. */
  77782. reset(): AssetsManager;
  77783. /**
  77784. * Start the loading process
  77785. * @return the current instance of the AssetsManager
  77786. */
  77787. load(): AssetsManager;
  77788. /**
  77789. * Start the loading process as an async operation
  77790. * @return a promise returning the list of failed tasks
  77791. */
  77792. loadAsync(): Promise<void>;
  77793. }
  77794. }
  77795. declare module BABYLON {
  77796. /**
  77797. * Wrapper class for promise with external resolve and reject.
  77798. */
  77799. export class Deferred<T> {
  77800. /**
  77801. * The promise associated with this deferred object.
  77802. */
  77803. readonly promise: Promise<T>;
  77804. private _resolve;
  77805. private _reject;
  77806. /**
  77807. * The resolve method of the promise associated with this deferred object.
  77808. */
  77809. get resolve(): (value: T | PromiseLike<T>) => void;
  77810. /**
  77811. * The reject method of the promise associated with this deferred object.
  77812. */
  77813. get reject(): (reason?: any) => void;
  77814. /**
  77815. * Constructor for this deferred object.
  77816. */
  77817. constructor();
  77818. }
  77819. }
  77820. declare module BABYLON {
  77821. /**
  77822. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77823. */
  77824. export class MeshExploder {
  77825. private _centerMesh;
  77826. private _meshes;
  77827. private _meshesOrigins;
  77828. private _toCenterVectors;
  77829. private _scaledDirection;
  77830. private _newPosition;
  77831. private _centerPosition;
  77832. /**
  77833. * Explodes meshes from a center mesh.
  77834. * @param meshes The meshes to explode.
  77835. * @param centerMesh The mesh to be center of explosion.
  77836. */
  77837. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77838. private _setCenterMesh;
  77839. /**
  77840. * Get class name
  77841. * @returns "MeshExploder"
  77842. */
  77843. getClassName(): string;
  77844. /**
  77845. * "Exploded meshes"
  77846. * @returns Array of meshes with the centerMesh at index 0.
  77847. */
  77848. getMeshes(): Array<Mesh>;
  77849. /**
  77850. * Explodes meshes giving a specific direction
  77851. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77852. */
  77853. explode(direction?: number): void;
  77854. }
  77855. }
  77856. declare module BABYLON {
  77857. /**
  77858. * Class used to help managing file picking and drag'n'drop
  77859. */
  77860. export class FilesInput {
  77861. /**
  77862. * List of files ready to be loaded
  77863. */
  77864. static get FilesToLoad(): {
  77865. [key: string]: File;
  77866. };
  77867. /**
  77868. * Callback called when a file is processed
  77869. */
  77870. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77871. /**
  77872. * Function used when loading the scene file
  77873. */
  77874. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77875. private _engine;
  77876. private _currentScene;
  77877. private _sceneLoadedCallback;
  77878. private _progressCallback;
  77879. private _additionalRenderLoopLogicCallback;
  77880. private _textureLoadingCallback;
  77881. private _startingProcessingFilesCallback;
  77882. private _onReloadCallback;
  77883. private _errorCallback;
  77884. private _elementToMonitor;
  77885. private _sceneFileToLoad;
  77886. private _filesToLoad;
  77887. /**
  77888. * Creates a new FilesInput
  77889. * @param engine defines the rendering engine
  77890. * @param scene defines the hosting scene
  77891. * @param sceneLoadedCallback callback called when scene is loaded
  77892. * @param progressCallback callback called to track progress
  77893. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77894. * @param textureLoadingCallback callback called when a texture is loading
  77895. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77896. * @param onReloadCallback callback called when a reload is requested
  77897. * @param errorCallback callback call if an error occurs
  77898. */
  77899. 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>);
  77900. private _dragEnterHandler;
  77901. private _dragOverHandler;
  77902. private _dropHandler;
  77903. /**
  77904. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77905. * @param elementToMonitor defines the DOM element to track
  77906. */
  77907. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77908. /** Gets the current list of files to load */
  77909. get filesToLoad(): File[];
  77910. /**
  77911. * Release all associated resources
  77912. */
  77913. dispose(): void;
  77914. private renderFunction;
  77915. private drag;
  77916. private drop;
  77917. private _traverseFolder;
  77918. private _processFiles;
  77919. /**
  77920. * Load files from a drop event
  77921. * @param event defines the drop event to use as source
  77922. */
  77923. loadFiles(event: any): void;
  77924. private _processReload;
  77925. /**
  77926. * Reload the current scene from the loaded files
  77927. */
  77928. reload(): void;
  77929. }
  77930. }
  77931. declare module BABYLON {
  77932. /**
  77933. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77934. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77935. */
  77936. export class SceneOptimization {
  77937. /**
  77938. * Defines the priority of this optimization (0 by default which means first in the list)
  77939. */
  77940. priority: number;
  77941. /**
  77942. * Gets a string describing the action executed by the current optimization
  77943. * @returns description string
  77944. */
  77945. getDescription(): string;
  77946. /**
  77947. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77948. * @param scene defines the current scene where to apply this optimization
  77949. * @param optimizer defines the current optimizer
  77950. * @returns true if everything that can be done was applied
  77951. */
  77952. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77953. /**
  77954. * Creates the SceneOptimization object
  77955. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77956. * @param desc defines the description associated with the optimization
  77957. */
  77958. constructor(
  77959. /**
  77960. * Defines the priority of this optimization (0 by default which means first in the list)
  77961. */
  77962. priority?: number);
  77963. }
  77964. /**
  77965. * Defines an optimization used to reduce the size of render target textures
  77966. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77967. */
  77968. export class TextureOptimization extends SceneOptimization {
  77969. /**
  77970. * Defines the priority of this optimization (0 by default which means first in the list)
  77971. */
  77972. priority: number;
  77973. /**
  77974. * 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
  77975. */
  77976. maximumSize: number;
  77977. /**
  77978. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77979. */
  77980. step: number;
  77981. /**
  77982. * Gets a string describing the action executed by the current optimization
  77983. * @returns description string
  77984. */
  77985. getDescription(): string;
  77986. /**
  77987. * Creates the TextureOptimization object
  77988. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77989. * @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
  77990. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77991. */
  77992. constructor(
  77993. /**
  77994. * Defines the priority of this optimization (0 by default which means first in the list)
  77995. */
  77996. priority?: number,
  77997. /**
  77998. * 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
  77999. */
  78000. maximumSize?: number,
  78001. /**
  78002. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78003. */
  78004. step?: number);
  78005. /**
  78006. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78007. * @param scene defines the current scene where to apply this optimization
  78008. * @param optimizer defines the current optimizer
  78009. * @returns true if everything that can be done was applied
  78010. */
  78011. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78012. }
  78013. /**
  78014. * Defines an optimization used to increase or decrease the rendering resolution
  78015. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78016. */
  78017. export class HardwareScalingOptimization extends SceneOptimization {
  78018. /**
  78019. * Defines the priority of this optimization (0 by default which means first in the list)
  78020. */
  78021. priority: number;
  78022. /**
  78023. * Defines the maximum scale to use (2 by default)
  78024. */
  78025. maximumScale: number;
  78026. /**
  78027. * Defines the step to use between two passes (0.5 by default)
  78028. */
  78029. step: number;
  78030. private _currentScale;
  78031. private _directionOffset;
  78032. /**
  78033. * Gets a string describing the action executed by the current optimization
  78034. * @return description string
  78035. */
  78036. getDescription(): string;
  78037. /**
  78038. * Creates the HardwareScalingOptimization object
  78039. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78040. * @param maximumScale defines the maximum scale to use (2 by default)
  78041. * @param step defines the step to use between two passes (0.5 by default)
  78042. */
  78043. constructor(
  78044. /**
  78045. * Defines the priority of this optimization (0 by default which means first in the list)
  78046. */
  78047. priority?: number,
  78048. /**
  78049. * Defines the maximum scale to use (2 by default)
  78050. */
  78051. maximumScale?: number,
  78052. /**
  78053. * Defines the step to use between two passes (0.5 by default)
  78054. */
  78055. step?: number);
  78056. /**
  78057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78058. * @param scene defines the current scene where to apply this optimization
  78059. * @param optimizer defines the current optimizer
  78060. * @returns true if everything that can be done was applied
  78061. */
  78062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78063. }
  78064. /**
  78065. * Defines an optimization used to remove shadows
  78066. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78067. */
  78068. export class ShadowsOptimization extends SceneOptimization {
  78069. /**
  78070. * Gets a string describing the action executed by the current optimization
  78071. * @return description string
  78072. */
  78073. getDescription(): string;
  78074. /**
  78075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78076. * @param scene defines the current scene where to apply this optimization
  78077. * @param optimizer defines the current optimizer
  78078. * @returns true if everything that can be done was applied
  78079. */
  78080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78081. }
  78082. /**
  78083. * Defines an optimization used to turn post-processes off
  78084. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78085. */
  78086. export class PostProcessesOptimization extends SceneOptimization {
  78087. /**
  78088. * Gets a string describing the action executed by the current optimization
  78089. * @return description string
  78090. */
  78091. getDescription(): string;
  78092. /**
  78093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78094. * @param scene defines the current scene where to apply this optimization
  78095. * @param optimizer defines the current optimizer
  78096. * @returns true if everything that can be done was applied
  78097. */
  78098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78099. }
  78100. /**
  78101. * Defines an optimization used to turn lens flares off
  78102. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78103. */
  78104. export class LensFlaresOptimization extends SceneOptimization {
  78105. /**
  78106. * Gets a string describing the action executed by the current optimization
  78107. * @return description string
  78108. */
  78109. getDescription(): string;
  78110. /**
  78111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78112. * @param scene defines the current scene where to apply this optimization
  78113. * @param optimizer defines the current optimizer
  78114. * @returns true if everything that can be done was applied
  78115. */
  78116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78117. }
  78118. /**
  78119. * Defines an optimization based on user defined callback.
  78120. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78121. */
  78122. export class CustomOptimization extends SceneOptimization {
  78123. /**
  78124. * Callback called to apply the custom optimization.
  78125. */
  78126. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78127. /**
  78128. * Callback called to get custom description
  78129. */
  78130. onGetDescription: () => string;
  78131. /**
  78132. * Gets a string describing the action executed by the current optimization
  78133. * @returns description string
  78134. */
  78135. getDescription(): string;
  78136. /**
  78137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78138. * @param scene defines the current scene where to apply this optimization
  78139. * @param optimizer defines the current optimizer
  78140. * @returns true if everything that can be done was applied
  78141. */
  78142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78143. }
  78144. /**
  78145. * Defines an optimization used to turn particles off
  78146. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78147. */
  78148. export class ParticlesOptimization extends SceneOptimization {
  78149. /**
  78150. * Gets a string describing the action executed by the current optimization
  78151. * @return description string
  78152. */
  78153. getDescription(): string;
  78154. /**
  78155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78156. * @param scene defines the current scene where to apply this optimization
  78157. * @param optimizer defines the current optimizer
  78158. * @returns true if everything that can be done was applied
  78159. */
  78160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78161. }
  78162. /**
  78163. * Defines an optimization used to turn render targets off
  78164. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78165. */
  78166. export class RenderTargetsOptimization extends SceneOptimization {
  78167. /**
  78168. * Gets a string describing the action executed by the current optimization
  78169. * @return description string
  78170. */
  78171. getDescription(): string;
  78172. /**
  78173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78174. * @param scene defines the current scene where to apply this optimization
  78175. * @param optimizer defines the current optimizer
  78176. * @returns true if everything that can be done was applied
  78177. */
  78178. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78179. }
  78180. /**
  78181. * Defines an optimization used to merge meshes with compatible materials
  78182. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78183. */
  78184. export class MergeMeshesOptimization extends SceneOptimization {
  78185. private static _UpdateSelectionTree;
  78186. /**
  78187. * Gets or sets a boolean which defines if optimization octree has to be updated
  78188. */
  78189. static get UpdateSelectionTree(): boolean;
  78190. /**
  78191. * Gets or sets a boolean which defines if optimization octree has to be updated
  78192. */
  78193. static set UpdateSelectionTree(value: boolean);
  78194. /**
  78195. * Gets a string describing the action executed by the current optimization
  78196. * @return description string
  78197. */
  78198. getDescription(): string;
  78199. private _canBeMerged;
  78200. /**
  78201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78202. * @param scene defines the current scene where to apply this optimization
  78203. * @param optimizer defines the current optimizer
  78204. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78205. * @returns true if everything that can be done was applied
  78206. */
  78207. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78208. }
  78209. /**
  78210. * Defines a list of options used by SceneOptimizer
  78211. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78212. */
  78213. export class SceneOptimizerOptions {
  78214. /**
  78215. * Defines the target frame rate to reach (60 by default)
  78216. */
  78217. targetFrameRate: number;
  78218. /**
  78219. * Defines the interval between two checkes (2000ms by default)
  78220. */
  78221. trackerDuration: number;
  78222. /**
  78223. * Gets the list of optimizations to apply
  78224. */
  78225. optimizations: SceneOptimization[];
  78226. /**
  78227. * Creates a new list of options used by SceneOptimizer
  78228. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78229. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78230. */
  78231. constructor(
  78232. /**
  78233. * Defines the target frame rate to reach (60 by default)
  78234. */
  78235. targetFrameRate?: number,
  78236. /**
  78237. * Defines the interval between two checkes (2000ms by default)
  78238. */
  78239. trackerDuration?: number);
  78240. /**
  78241. * Add a new optimization
  78242. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78243. * @returns the current SceneOptimizerOptions
  78244. */
  78245. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78246. /**
  78247. * Add a new custom optimization
  78248. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78249. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78250. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78251. * @returns the current SceneOptimizerOptions
  78252. */
  78253. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78254. /**
  78255. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78256. * @param targetFrameRate defines the target frame rate (60 by default)
  78257. * @returns a SceneOptimizerOptions object
  78258. */
  78259. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78260. /**
  78261. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78262. * @param targetFrameRate defines the target frame rate (60 by default)
  78263. * @returns a SceneOptimizerOptions object
  78264. */
  78265. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78266. /**
  78267. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78268. * @param targetFrameRate defines the target frame rate (60 by default)
  78269. * @returns a SceneOptimizerOptions object
  78270. */
  78271. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78272. }
  78273. /**
  78274. * Class used to run optimizations in order to reach a target frame rate
  78275. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78276. */
  78277. export class SceneOptimizer implements IDisposable {
  78278. private _isRunning;
  78279. private _options;
  78280. private _scene;
  78281. private _currentPriorityLevel;
  78282. private _targetFrameRate;
  78283. private _trackerDuration;
  78284. private _currentFrameRate;
  78285. private _sceneDisposeObserver;
  78286. private _improvementMode;
  78287. /**
  78288. * Defines an observable called when the optimizer reaches the target frame rate
  78289. */
  78290. onSuccessObservable: Observable<SceneOptimizer>;
  78291. /**
  78292. * Defines an observable called when the optimizer enables an optimization
  78293. */
  78294. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78295. /**
  78296. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78297. */
  78298. onFailureObservable: Observable<SceneOptimizer>;
  78299. /**
  78300. * Gets a boolean indicating if the optimizer is in improvement mode
  78301. */
  78302. get isInImprovementMode(): boolean;
  78303. /**
  78304. * Gets the current priority level (0 at start)
  78305. */
  78306. get currentPriorityLevel(): number;
  78307. /**
  78308. * Gets the current frame rate checked by the SceneOptimizer
  78309. */
  78310. get currentFrameRate(): number;
  78311. /**
  78312. * Gets or sets the current target frame rate (60 by default)
  78313. */
  78314. get targetFrameRate(): number;
  78315. /**
  78316. * Gets or sets the current target frame rate (60 by default)
  78317. */
  78318. set targetFrameRate(value: number);
  78319. /**
  78320. * Gets or sets the current interval between two checks (every 2000ms by default)
  78321. */
  78322. get trackerDuration(): number;
  78323. /**
  78324. * Gets or sets the current interval between two checks (every 2000ms by default)
  78325. */
  78326. set trackerDuration(value: number);
  78327. /**
  78328. * Gets the list of active optimizations
  78329. */
  78330. get optimizations(): SceneOptimization[];
  78331. /**
  78332. * Creates a new SceneOptimizer
  78333. * @param scene defines the scene to work on
  78334. * @param options defines the options to use with the SceneOptimizer
  78335. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78336. * @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)
  78337. */
  78338. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78339. /**
  78340. * Stops the current optimizer
  78341. */
  78342. stop(): void;
  78343. /**
  78344. * Reset the optimizer to initial step (current priority level = 0)
  78345. */
  78346. reset(): void;
  78347. /**
  78348. * Start the optimizer. By default it will try to reach a specific framerate
  78349. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78350. */
  78351. start(): void;
  78352. private _checkCurrentState;
  78353. /**
  78354. * Release all resources
  78355. */
  78356. dispose(): void;
  78357. /**
  78358. * Helper function to create a SceneOptimizer with one single line of code
  78359. * @param scene defines the scene to work on
  78360. * @param options defines the options to use with the SceneOptimizer
  78361. * @param onSuccess defines a callback to call on success
  78362. * @param onFailure defines a callback to call on failure
  78363. * @returns the new SceneOptimizer object
  78364. */
  78365. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78366. }
  78367. }
  78368. declare module BABYLON {
  78369. /**
  78370. * Class used to serialize a scene into a string
  78371. */
  78372. export class SceneSerializer {
  78373. /**
  78374. * Clear cache used by a previous serialization
  78375. */
  78376. static ClearCache(): void;
  78377. /**
  78378. * Serialize a scene into a JSON compatible object
  78379. * @param scene defines the scene to serialize
  78380. * @returns a JSON compatible object
  78381. */
  78382. static Serialize(scene: Scene): any;
  78383. /**
  78384. * Serialize a mesh into a JSON compatible object
  78385. * @param toSerialize defines the mesh to serialize
  78386. * @param withParents defines if parents must be serialized as well
  78387. * @param withChildren defines if children must be serialized as well
  78388. * @returns a JSON compatible object
  78389. */
  78390. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78391. }
  78392. }
  78393. declare module BABYLON {
  78394. /**
  78395. * This represents the different options available for the video capture.
  78396. */
  78397. export interface VideoRecorderOptions {
  78398. /** Defines the mime type of the video. */
  78399. mimeType: string;
  78400. /** Defines the FPS the video should be recorded at. */
  78401. fps: number;
  78402. /** Defines the chunk size for the recording data. */
  78403. recordChunckSize: number;
  78404. /** The audio tracks to attach to the recording. */
  78405. audioTracks?: MediaStreamTrack[];
  78406. }
  78407. /**
  78408. * This can help with recording videos from BabylonJS.
  78409. * This is based on the available WebRTC functionalities of the browser.
  78410. *
  78411. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78412. */
  78413. export class VideoRecorder {
  78414. private static readonly _defaultOptions;
  78415. /**
  78416. * Returns whether or not the VideoRecorder is available in your browser.
  78417. * @param engine Defines the Babylon Engine.
  78418. * @returns true if supported otherwise false.
  78419. */
  78420. static IsSupported(engine: Engine): boolean;
  78421. private readonly _options;
  78422. private _canvas;
  78423. private _mediaRecorder;
  78424. private _recordedChunks;
  78425. private _fileName;
  78426. private _resolve;
  78427. private _reject;
  78428. /**
  78429. * True when a recording is already in progress.
  78430. */
  78431. get isRecording(): boolean;
  78432. /**
  78433. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78434. * @param engine Defines the BabylonJS Engine you wish to record.
  78435. * @param options Defines options that can be used to customize the capture.
  78436. */
  78437. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78438. /**
  78439. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78440. */
  78441. stopRecording(): void;
  78442. /**
  78443. * Starts recording the canvas for a max duration specified in parameters.
  78444. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78445. * If null no automatic download will start and you can rely on the promise to get the data back.
  78446. * @param maxDuration Defines the maximum recording time in seconds.
  78447. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78448. * @return A promise callback at the end of the recording with the video data in Blob.
  78449. */
  78450. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78451. /**
  78452. * Releases internal resources used during the recording.
  78453. */
  78454. dispose(): void;
  78455. private _handleDataAvailable;
  78456. private _handleError;
  78457. private _handleStop;
  78458. }
  78459. }
  78460. declare module BABYLON {
  78461. /**
  78462. * Class containing a set of static utilities functions for screenshots
  78463. */
  78464. export class ScreenshotTools {
  78465. /**
  78466. * Captures a screenshot of the current rendering
  78467. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78468. * @param engine defines the rendering engine
  78469. * @param camera defines the source camera
  78470. * @param size This parameter can be set to a single number or to an object with the
  78471. * following (optional) properties: precision, width, height. If a single number is passed,
  78472. * it will be used for both width and height. If an object is passed, the screenshot size
  78473. * will be derived from the parameters. The precision property is a multiplier allowing
  78474. * rendering at a higher or lower resolution
  78475. * @param successCallback defines the callback receives a single parameter which contains the
  78476. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78477. * src parameter of an <img> to display it
  78478. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78479. * Check your browser for supported MIME types
  78480. * @param forceDownload force the system to download the image even if a successCallback is provided
  78481. */
  78482. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78483. /**
  78484. * Captures a screenshot of the current rendering
  78485. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78486. * @param engine defines the rendering engine
  78487. * @param camera defines the source camera
  78488. * @param size This parameter can be set to a single number or to an object with the
  78489. * following (optional) properties: precision, width, height. If a single number is passed,
  78490. * it will be used for both width and height. If an object is passed, the screenshot size
  78491. * will be derived from the parameters. The precision property is a multiplier allowing
  78492. * rendering at a higher or lower resolution
  78493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78494. * Check your browser for supported MIME types
  78495. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78496. * to the src parameter of an <img> to display it
  78497. */
  78498. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78499. /**
  78500. * 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)
  78501. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78502. * @param engine defines the rendering engine
  78503. * @param camera defines the source camera
  78504. * @param width defines the expected width
  78505. * @param height defines the expected height
  78506. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78507. * Check your browser for supported MIME types
  78508. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78509. * to the src parameter of an <img> to display it
  78510. */
  78511. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78512. /**
  78513. * Generates an image screenshot from the specified camera.
  78514. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78515. * @param engine The engine to use for rendering
  78516. * @param camera The camera to use for rendering
  78517. * @param size This parameter can be set to a single number or to an object with the
  78518. * following (optional) properties: precision, width, height. If a single number is passed,
  78519. * it will be used for both width and height. If an object is passed, the screenshot size
  78520. * will be derived from the parameters. The precision property is a multiplier allowing
  78521. * rendering at a higher or lower resolution
  78522. * @param successCallback The callback receives a single parameter which contains the
  78523. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78524. * src parameter of an <img> to display it
  78525. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78526. * Check your browser for supported MIME types
  78527. * @param samples Texture samples (default: 1)
  78528. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78529. * @param fileName A name for for the downloaded file.
  78530. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78531. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78532. */
  78533. 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;
  78534. /**
  78535. * Generates an image screenshot from the specified camera.
  78536. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78537. * @param engine The engine to use for rendering
  78538. * @param camera The camera to use for rendering
  78539. * @param size This parameter can be set to a single number or to an object with the
  78540. * following (optional) properties: precision, width, height. If a single number is passed,
  78541. * it will be used for both width and height. If an object is passed, the screenshot size
  78542. * will be derived from the parameters. The precision property is a multiplier allowing
  78543. * rendering at a higher or lower resolution
  78544. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78545. * Check your browser for supported MIME types
  78546. * @param samples Texture samples (default: 1)
  78547. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78548. * @param fileName A name for for the downloaded file.
  78549. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78551. * to the src parameter of an <img> to display it
  78552. */
  78553. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78554. /**
  78555. * Gets height and width for screenshot size
  78556. * @private
  78557. */
  78558. private static _getScreenshotSize;
  78559. }
  78560. }
  78561. declare module BABYLON {
  78562. /**
  78563. * Interface for a data buffer
  78564. */
  78565. export interface IDataBuffer {
  78566. /**
  78567. * Reads bytes from the data buffer.
  78568. * @param byteOffset The byte offset to read
  78569. * @param byteLength The byte length to read
  78570. * @returns A promise that resolves when the bytes are read
  78571. */
  78572. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78573. /**
  78574. * The byte length of the buffer.
  78575. */
  78576. readonly byteLength: number;
  78577. }
  78578. /**
  78579. * Utility class for reading from a data buffer
  78580. */
  78581. export class DataReader {
  78582. /**
  78583. * The data buffer associated with this data reader.
  78584. */
  78585. readonly buffer: IDataBuffer;
  78586. /**
  78587. * The current byte offset from the beginning of the data buffer.
  78588. */
  78589. byteOffset: number;
  78590. private _dataView;
  78591. private _dataByteOffset;
  78592. /**
  78593. * Constructor
  78594. * @param buffer The buffer to read
  78595. */
  78596. constructor(buffer: IDataBuffer);
  78597. /**
  78598. * Loads the given byte length.
  78599. * @param byteLength The byte length to load
  78600. * @returns A promise that resolves when the load is complete
  78601. */
  78602. loadAsync(byteLength: number): Promise<void>;
  78603. /**
  78604. * Read a unsigned 32-bit integer from the currently loaded data range.
  78605. * @returns The 32-bit integer read
  78606. */
  78607. readUint32(): number;
  78608. /**
  78609. * Read a byte array from the currently loaded data range.
  78610. * @param byteLength The byte length to read
  78611. * @returns The byte array read
  78612. */
  78613. readUint8Array(byteLength: number): Uint8Array;
  78614. /**
  78615. * Read a string from the currently loaded data range.
  78616. * @param byteLength The byte length to read
  78617. * @returns The string read
  78618. */
  78619. readString(byteLength: number): string;
  78620. /**
  78621. * Skips the given byte length the currently loaded data range.
  78622. * @param byteLength The byte length to skip
  78623. */
  78624. skipBytes(byteLength: number): void;
  78625. }
  78626. }
  78627. declare module BABYLON {
  78628. /**
  78629. * Class for storing data to local storage if available or in-memory storage otherwise
  78630. */
  78631. export class DataStorage {
  78632. private static _Storage;
  78633. private static _GetStorage;
  78634. /**
  78635. * Reads a string from the data storage
  78636. * @param key The key to read
  78637. * @param defaultValue The value if the key doesn't exist
  78638. * @returns The string value
  78639. */
  78640. static ReadString(key: string, defaultValue: string): string;
  78641. /**
  78642. * Writes a string to the data storage
  78643. * @param key The key to write
  78644. * @param value The value to write
  78645. */
  78646. static WriteString(key: string, value: string): void;
  78647. /**
  78648. * Reads a boolean from the data storage
  78649. * @param key The key to read
  78650. * @param defaultValue The value if the key doesn't exist
  78651. * @returns The boolean value
  78652. */
  78653. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78654. /**
  78655. * Writes a boolean to the data storage
  78656. * @param key The key to write
  78657. * @param value The value to write
  78658. */
  78659. static WriteBoolean(key: string, value: boolean): void;
  78660. /**
  78661. * Reads a number from the data storage
  78662. * @param key The key to read
  78663. * @param defaultValue The value if the key doesn't exist
  78664. * @returns The number value
  78665. */
  78666. static ReadNumber(key: string, defaultValue: number): number;
  78667. /**
  78668. * Writes a number to the data storage
  78669. * @param key The key to write
  78670. * @param value The value to write
  78671. */
  78672. static WriteNumber(key: string, value: number): void;
  78673. }
  78674. }
  78675. declare module BABYLON {
  78676. /**
  78677. * Class used to record delta files between 2 scene states
  78678. */
  78679. export class SceneRecorder {
  78680. private _trackedScene;
  78681. private _savedJSON;
  78682. /**
  78683. * Track a given scene. This means the current scene state will be considered the original state
  78684. * @param scene defines the scene to track
  78685. */
  78686. track(scene: Scene): void;
  78687. /**
  78688. * Get the delta between current state and original state
  78689. * @returns a string containing the delta
  78690. */
  78691. getDelta(): any;
  78692. private _compareArray;
  78693. private _compareObjects;
  78694. private _compareCollections;
  78695. private static GetShadowGeneratorById;
  78696. /**
  78697. * Apply a given delta to a given scene
  78698. * @param deltaJSON defines the JSON containing the delta
  78699. * @param scene defines the scene to apply the delta to
  78700. */
  78701. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78702. private static _ApplyPropertiesToEntity;
  78703. private static _ApplyDeltaForEntity;
  78704. }
  78705. }
  78706. declare module BABYLON {
  78707. /**
  78708. * A 3D trajectory consisting of an order list of vectors describing a
  78709. * path of motion through 3D space.
  78710. */
  78711. export class Trajectory {
  78712. private _points;
  78713. private readonly _segmentLength;
  78714. /**
  78715. * Serialize to JSON.
  78716. * @returns serialized JSON string
  78717. */
  78718. serialize(): string;
  78719. /**
  78720. * Deserialize from JSON.
  78721. * @param json serialized JSON string
  78722. * @returns deserialized Trajectory
  78723. */
  78724. static Deserialize(json: string): Trajectory;
  78725. /**
  78726. * Create a new empty Trajectory.
  78727. * @param segmentLength radius of discretization for Trajectory points
  78728. */
  78729. constructor(segmentLength?: number);
  78730. /**
  78731. * Get the length of the Trajectory.
  78732. * @returns length of the Trajectory
  78733. */
  78734. getLength(): number;
  78735. /**
  78736. * Append a new point to the Trajectory.
  78737. * NOTE: This implementation has many allocations.
  78738. * @param point point to append to the Trajectory
  78739. */
  78740. add(point: DeepImmutable<Vector3>): void;
  78741. /**
  78742. * Create a new Trajectory with a segment length chosen to make it
  78743. * probable that the new Trajectory will have a specified number of
  78744. * segments. This operation is imprecise.
  78745. * @param targetResolution number of segments desired
  78746. * @returns new Trajectory with approximately the requested number of segments
  78747. */
  78748. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78749. /**
  78750. * Convert Trajectory segments into tokenized representation. This
  78751. * representation is an array of numbers where each nth number is the
  78752. * index of the token which is most similar to the nth segment of the
  78753. * Trajectory.
  78754. * @param tokens list of vectors which serve as discrete tokens
  78755. * @returns list of indices of most similar token per segment
  78756. */
  78757. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78758. private static _forwardDir;
  78759. private static _inverseFromVec;
  78760. private static _upDir;
  78761. private static _fromToVec;
  78762. private static _lookMatrix;
  78763. /**
  78764. * Transform the rotation (i.e., direction) of a segment to isolate
  78765. * the relative transformation represented by the segment. This operation
  78766. * may or may not succeed due to singularities in the equations that define
  78767. * motion relativity in this context.
  78768. * @param priorVec the origin of the prior segment
  78769. * @param fromVec the origin of the current segment
  78770. * @param toVec the destination of the current segment
  78771. * @param result reference to output variable
  78772. * @returns whether or not transformation was successful
  78773. */
  78774. private static _transformSegmentDirToRef;
  78775. private static _bestMatch;
  78776. private static _score;
  78777. private static _bestScore;
  78778. /**
  78779. * Determine which token vector is most similar to the
  78780. * segment vector.
  78781. * @param segment segment vector
  78782. * @param tokens token vector list
  78783. * @returns index of the most similar token to the segment
  78784. */
  78785. private static _tokenizeSegment;
  78786. }
  78787. /**
  78788. * Class representing a set of known, named trajectories to which Trajectories can be
  78789. * added and using which Trajectories can be recognized.
  78790. */
  78791. export class TrajectoryClassifier {
  78792. private _maximumAllowableMatchCost;
  78793. private _vector3Alphabet;
  78794. private _levenshteinAlphabet;
  78795. private _nameToDescribedTrajectory;
  78796. /**
  78797. * Serialize to JSON.
  78798. * @returns JSON serialization
  78799. */
  78800. serialize(): string;
  78801. /**
  78802. * Deserialize from JSON.
  78803. * @param json JSON serialization
  78804. * @returns deserialized TrajectorySet
  78805. */
  78806. static Deserialize(json: string): TrajectoryClassifier;
  78807. /**
  78808. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78809. * VERY naive, need to be generating these things from known
  78810. * sets. Better version later, probably eliminating this one.
  78811. * @returns auto-generated TrajectorySet
  78812. */
  78813. static Generate(): TrajectoryClassifier;
  78814. private constructor();
  78815. /**
  78816. * Add a new Trajectory to the set with a given name.
  78817. * @param trajectory new Trajectory to be added
  78818. * @param classification name to which to add the Trajectory
  78819. */
  78820. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78821. /**
  78822. * Remove a known named trajectory and all Trajectories associated with it.
  78823. * @param classification name to remove
  78824. * @returns whether anything was removed
  78825. */
  78826. deleteClassification(classification: string): boolean;
  78827. /**
  78828. * Attempt to recognize a Trajectory from among all the classifications
  78829. * already known to the classifier.
  78830. * @param trajectory Trajectory to be recognized
  78831. * @returns classification of Trajectory if recognized, null otherwise
  78832. */
  78833. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78834. }
  78835. }
  78836. declare module BABYLON {
  78837. /**
  78838. * An interface for all Hit test features
  78839. */
  78840. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78841. /**
  78842. * Triggered when new babylon (transformed) hit test results are available
  78843. */
  78844. onHitTestResultObservable: Observable<T[]>;
  78845. }
  78846. /**
  78847. * Options used for hit testing
  78848. */
  78849. export interface IWebXRLegacyHitTestOptions {
  78850. /**
  78851. * Only test when user interacted with the scene. Default - hit test every frame
  78852. */
  78853. testOnPointerDownOnly?: boolean;
  78854. /**
  78855. * The node to use to transform the local results to world coordinates
  78856. */
  78857. worldParentNode?: TransformNode;
  78858. }
  78859. /**
  78860. * Interface defining the babylon result of raycasting/hit-test
  78861. */
  78862. export interface IWebXRLegacyHitResult {
  78863. /**
  78864. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78865. */
  78866. transformationMatrix: Matrix;
  78867. /**
  78868. * The native hit test result
  78869. */
  78870. xrHitResult: XRHitResult | XRHitTestResult;
  78871. }
  78872. /**
  78873. * The currently-working hit-test module.
  78874. * Hit test (or Ray-casting) is used to interact with the real world.
  78875. * For further information read here - https://github.com/immersive-web/hit-test
  78876. */
  78877. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78878. /**
  78879. * options to use when constructing this feature
  78880. */
  78881. readonly options: IWebXRLegacyHitTestOptions;
  78882. private _direction;
  78883. private _mat;
  78884. private _onSelectEnabled;
  78885. private _origin;
  78886. /**
  78887. * The module's name
  78888. */
  78889. static readonly Name: string;
  78890. /**
  78891. * The (Babylon) version of this module.
  78892. * This is an integer representing the implementation version.
  78893. * This number does not correspond to the WebXR specs version
  78894. */
  78895. static readonly Version: number;
  78896. /**
  78897. * Populated with the last native XR Hit Results
  78898. */
  78899. lastNativeXRHitResults: XRHitResult[];
  78900. /**
  78901. * Triggered when new babylon (transformed) hit test results are available
  78902. */
  78903. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78904. /**
  78905. * Creates a new instance of the (legacy version) hit test feature
  78906. * @param _xrSessionManager an instance of WebXRSessionManager
  78907. * @param options options to use when constructing this feature
  78908. */
  78909. constructor(_xrSessionManager: WebXRSessionManager,
  78910. /**
  78911. * options to use when constructing this feature
  78912. */
  78913. options?: IWebXRLegacyHitTestOptions);
  78914. /**
  78915. * execute a hit test with an XR Ray
  78916. *
  78917. * @param xrSession a native xrSession that will execute this hit test
  78918. * @param xrRay the ray (position and direction) to use for ray-casting
  78919. * @param referenceSpace native XR reference space to use for the hit-test
  78920. * @param filter filter function that will filter the results
  78921. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78922. */
  78923. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78924. /**
  78925. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78926. * @param event the (select) event to use to select with
  78927. * @param referenceSpace the reference space to use for this hit test
  78928. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78929. */
  78930. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78931. /**
  78932. * attach this feature
  78933. * Will usually be called by the features manager
  78934. *
  78935. * @returns true if successful.
  78936. */
  78937. attach(): boolean;
  78938. /**
  78939. * detach this feature.
  78940. * Will usually be called by the features manager
  78941. *
  78942. * @returns true if successful.
  78943. */
  78944. detach(): boolean;
  78945. /**
  78946. * Dispose this feature and all of the resources attached
  78947. */
  78948. dispose(): void;
  78949. protected _onXRFrame(frame: XRFrame): void;
  78950. private _onHitTestResults;
  78951. private _onSelect;
  78952. }
  78953. }
  78954. declare module BABYLON {
  78955. /**
  78956. * Options used for hit testing (version 2)
  78957. */
  78958. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78959. /**
  78960. * Do not create a permanent hit test. Will usually be used when only
  78961. * transient inputs are needed.
  78962. */
  78963. disablePermanentHitTest?: boolean;
  78964. /**
  78965. * Enable transient (for example touch-based) hit test inspections
  78966. */
  78967. enableTransientHitTest?: boolean;
  78968. /**
  78969. * Offset ray for the permanent hit test
  78970. */
  78971. offsetRay?: Vector3;
  78972. /**
  78973. * Offset ray for the transient hit test
  78974. */
  78975. transientOffsetRay?: Vector3;
  78976. /**
  78977. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78978. */
  78979. useReferenceSpace?: boolean;
  78980. /**
  78981. * Override the default entity type(s) of the hit-test result
  78982. */
  78983. entityTypes?: XRHitTestTrackableType[];
  78984. }
  78985. /**
  78986. * Interface defining the babylon result of hit-test
  78987. */
  78988. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78989. /**
  78990. * The input source that generated this hit test (if transient)
  78991. */
  78992. inputSource?: XRInputSource;
  78993. /**
  78994. * Is this a transient hit test
  78995. */
  78996. isTransient?: boolean;
  78997. /**
  78998. * Position of the hit test result
  78999. */
  79000. position: Vector3;
  79001. /**
  79002. * Rotation of the hit test result
  79003. */
  79004. rotationQuaternion: Quaternion;
  79005. /**
  79006. * The native hit test result
  79007. */
  79008. xrHitResult: XRHitTestResult;
  79009. }
  79010. /**
  79011. * The currently-working hit-test module.
  79012. * Hit test (or Ray-casting) is used to interact with the real world.
  79013. * For further information read here - https://github.com/immersive-web/hit-test
  79014. *
  79015. * Tested on chrome (mobile) 80.
  79016. */
  79017. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79018. /**
  79019. * options to use when constructing this feature
  79020. */
  79021. readonly options: IWebXRHitTestOptions;
  79022. private _tmpMat;
  79023. private _tmpPos;
  79024. private _tmpQuat;
  79025. private _transientXrHitTestSource;
  79026. private _xrHitTestSource;
  79027. private initHitTestSource;
  79028. /**
  79029. * The module's name
  79030. */
  79031. static readonly Name: string;
  79032. /**
  79033. * The (Babylon) version of this module.
  79034. * This is an integer representing the implementation version.
  79035. * This number does not correspond to the WebXR specs version
  79036. */
  79037. static readonly Version: number;
  79038. /**
  79039. * When set to true, each hit test will have its own position/rotation objects
  79040. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79041. * the developers will clone them or copy them as they see fit.
  79042. */
  79043. autoCloneTransformation: boolean;
  79044. /**
  79045. * Triggered when new babylon (transformed) hit test results are available
  79046. * Note - this will be called when results come back from the device. It can be an empty array!!
  79047. */
  79048. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79049. /**
  79050. * Use this to temporarily pause hit test checks.
  79051. */
  79052. paused: boolean;
  79053. /**
  79054. * Creates a new instance of the hit test feature
  79055. * @param _xrSessionManager an instance of WebXRSessionManager
  79056. * @param options options to use when constructing this feature
  79057. */
  79058. constructor(_xrSessionManager: WebXRSessionManager,
  79059. /**
  79060. * options to use when constructing this feature
  79061. */
  79062. options?: IWebXRHitTestOptions);
  79063. /**
  79064. * attach this feature
  79065. * Will usually be called by the features manager
  79066. *
  79067. * @returns true if successful.
  79068. */
  79069. attach(): boolean;
  79070. /**
  79071. * detach this feature.
  79072. * Will usually be called by the features manager
  79073. *
  79074. * @returns true if successful.
  79075. */
  79076. detach(): boolean;
  79077. /**
  79078. * Dispose this feature and all of the resources attached
  79079. */
  79080. dispose(): void;
  79081. protected _onXRFrame(frame: XRFrame): void;
  79082. private _processWebXRHitTestResult;
  79083. }
  79084. }
  79085. declare module BABYLON {
  79086. /**
  79087. * Configuration options of the anchor system
  79088. */
  79089. export interface IWebXRAnchorSystemOptions {
  79090. /**
  79091. * a node that will be used to convert local to world coordinates
  79092. */
  79093. worldParentNode?: TransformNode;
  79094. /**
  79095. * If set to true a reference of the created anchors will be kept until the next session starts
  79096. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79097. */
  79098. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79099. }
  79100. /**
  79101. * A babylon container for an XR Anchor
  79102. */
  79103. export interface IWebXRAnchor {
  79104. /**
  79105. * A babylon-assigned ID for this anchor
  79106. */
  79107. id: number;
  79108. /**
  79109. * Transformation matrix to apply to an object attached to this anchor
  79110. */
  79111. transformationMatrix: Matrix;
  79112. /**
  79113. * The native anchor object
  79114. */
  79115. xrAnchor: XRAnchor;
  79116. /**
  79117. * if defined, this object will be constantly updated by the anchor's position and rotation
  79118. */
  79119. attachedNode?: TransformNode;
  79120. /**
  79121. * Remove this anchor from the scene
  79122. */
  79123. remove(): void;
  79124. }
  79125. /**
  79126. * An implementation of the anchor system for WebXR.
  79127. * For further information see https://github.com/immersive-web/anchors/
  79128. */
  79129. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79130. private _options;
  79131. private _lastFrameDetected;
  79132. private _trackedAnchors;
  79133. private _referenceSpaceForFrameAnchors;
  79134. private _futureAnchors;
  79135. /**
  79136. * The module's name
  79137. */
  79138. static readonly Name: string;
  79139. /**
  79140. * The (Babylon) version of this module.
  79141. * This is an integer representing the implementation version.
  79142. * This number does not correspond to the WebXR specs version
  79143. */
  79144. static readonly Version: number;
  79145. /**
  79146. * Observers registered here will be executed when a new anchor was added to the session
  79147. */
  79148. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79149. /**
  79150. * Observers registered here will be executed when an anchor was removed from the session
  79151. */
  79152. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79153. /**
  79154. * Observers registered here will be executed when an existing anchor updates
  79155. * This can execute N times every frame
  79156. */
  79157. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79158. /**
  79159. * Set the reference space to use for anchor creation, when not using a hit test.
  79160. * Will default to the session's reference space if not defined
  79161. */
  79162. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79163. /**
  79164. * constructs a new anchor system
  79165. * @param _xrSessionManager an instance of WebXRSessionManager
  79166. * @param _options configuration object for this feature
  79167. */
  79168. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79169. private _tmpVector;
  79170. private _tmpQuaternion;
  79171. private _populateTmpTransformation;
  79172. /**
  79173. * Create a new anchor point using a hit test result at a specific point in the scene
  79174. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79175. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79176. *
  79177. * @param hitTestResult The hit test result to use for this anchor creation
  79178. * @param position an optional position offset for this anchor
  79179. * @param rotationQuaternion an optional rotation offset for this anchor
  79180. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79181. */
  79182. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79183. /**
  79184. * Add a new anchor at a specific position and rotation
  79185. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79186. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79187. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79188. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79189. *
  79190. * @param position the position in which to add an anchor
  79191. * @param rotationQuaternion an optional rotation for the anchor transformation
  79192. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79193. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79194. */
  79195. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79196. /**
  79197. * Get the list of anchors currently being tracked by the system
  79198. */
  79199. get anchors(): IWebXRAnchor[];
  79200. /**
  79201. * detach this feature.
  79202. * Will usually be called by the features manager
  79203. *
  79204. * @returns true if successful.
  79205. */
  79206. detach(): boolean;
  79207. /**
  79208. * Dispose this feature and all of the resources attached
  79209. */
  79210. dispose(): void;
  79211. protected _onXRFrame(frame: XRFrame): void;
  79212. /**
  79213. * avoiding using Array.find for global support.
  79214. * @param xrAnchor the plane to find in the array
  79215. */
  79216. private _findIndexInAnchorArray;
  79217. private _updateAnchorWithXRFrame;
  79218. private _createAnchorAtTransformation;
  79219. }
  79220. }
  79221. declare module BABYLON {
  79222. /**
  79223. * Options used in the plane detector module
  79224. */
  79225. export interface IWebXRPlaneDetectorOptions {
  79226. /**
  79227. * The node to use to transform the local results to world coordinates
  79228. */
  79229. worldParentNode?: TransformNode;
  79230. /**
  79231. * If set to true a reference of the created planes will be kept until the next session starts
  79232. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79233. */
  79234. doNotRemovePlanesOnSessionEnded?: boolean;
  79235. /**
  79236. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79237. */
  79238. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79239. }
  79240. /**
  79241. * A babylon interface for a WebXR plane.
  79242. * A Plane is actually a polygon, built from N points in space
  79243. *
  79244. * Supported in chrome 79, not supported in canary 81 ATM
  79245. */
  79246. export interface IWebXRPlane {
  79247. /**
  79248. * a babylon-assigned ID for this polygon
  79249. */
  79250. id: number;
  79251. /**
  79252. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79253. */
  79254. polygonDefinition: Array<Vector3>;
  79255. /**
  79256. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79257. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79258. */
  79259. transformationMatrix: Matrix;
  79260. /**
  79261. * the native xr-plane object
  79262. */
  79263. xrPlane: XRPlane;
  79264. }
  79265. /**
  79266. * The plane detector is used to detect planes in the real world when in AR
  79267. * For more information see https://github.com/immersive-web/real-world-geometry/
  79268. */
  79269. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79270. private _options;
  79271. private _detectedPlanes;
  79272. private _enabled;
  79273. private _lastFrameDetected;
  79274. /**
  79275. * The module's name
  79276. */
  79277. static readonly Name: string;
  79278. /**
  79279. * The (Babylon) version of this module.
  79280. * This is an integer representing the implementation version.
  79281. * This number does not correspond to the WebXR specs version
  79282. */
  79283. static readonly Version: number;
  79284. /**
  79285. * Observers registered here will be executed when a new plane was added to the session
  79286. */
  79287. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79288. /**
  79289. * Observers registered here will be executed when a plane is no longer detected in the session
  79290. */
  79291. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79292. /**
  79293. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79294. * This can execute N times every frame
  79295. */
  79296. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79297. /**
  79298. * construct a new Plane Detector
  79299. * @param _xrSessionManager an instance of xr Session manager
  79300. * @param _options configuration to use when constructing this feature
  79301. */
  79302. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79303. /**
  79304. * detach this feature.
  79305. * Will usually be called by the features manager
  79306. *
  79307. * @returns true if successful.
  79308. */
  79309. detach(): boolean;
  79310. /**
  79311. * Dispose this feature and all of the resources attached
  79312. */
  79313. dispose(): void;
  79314. /**
  79315. * Check if the needed objects are defined.
  79316. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79317. */
  79318. isCompatible(): boolean;
  79319. protected _onXRFrame(frame: XRFrame): void;
  79320. private _init;
  79321. private _updatePlaneWithXRPlane;
  79322. /**
  79323. * avoiding using Array.find for global support.
  79324. * @param xrPlane the plane to find in the array
  79325. */
  79326. private _findIndexInPlaneArray;
  79327. }
  79328. }
  79329. declare module BABYLON {
  79330. /**
  79331. * Options interface for the background remover plugin
  79332. */
  79333. export interface IWebXRBackgroundRemoverOptions {
  79334. /**
  79335. * Further background meshes to disable when entering AR
  79336. */
  79337. backgroundMeshes?: AbstractMesh[];
  79338. /**
  79339. * flags to configure the removal of the environment helper.
  79340. * If not set, the entire background will be removed. If set, flags should be set as well.
  79341. */
  79342. environmentHelperRemovalFlags?: {
  79343. /**
  79344. * Should the skybox be removed (default false)
  79345. */
  79346. skyBox?: boolean;
  79347. /**
  79348. * Should the ground be removed (default false)
  79349. */
  79350. ground?: boolean;
  79351. };
  79352. /**
  79353. * don't disable the environment helper
  79354. */
  79355. ignoreEnvironmentHelper?: boolean;
  79356. }
  79357. /**
  79358. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79359. */
  79360. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79361. /**
  79362. * read-only options to be used in this module
  79363. */
  79364. readonly options: IWebXRBackgroundRemoverOptions;
  79365. /**
  79366. * The module's name
  79367. */
  79368. static readonly Name: string;
  79369. /**
  79370. * The (Babylon) version of this module.
  79371. * This is an integer representing the implementation version.
  79372. * This number does not correspond to the WebXR specs version
  79373. */
  79374. static readonly Version: number;
  79375. /**
  79376. * registered observers will be triggered when the background state changes
  79377. */
  79378. onBackgroundStateChangedObservable: Observable<boolean>;
  79379. /**
  79380. * constructs a new background remover module
  79381. * @param _xrSessionManager the session manager for this module
  79382. * @param options read-only options to be used in this module
  79383. */
  79384. constructor(_xrSessionManager: WebXRSessionManager,
  79385. /**
  79386. * read-only options to be used in this module
  79387. */
  79388. options?: IWebXRBackgroundRemoverOptions);
  79389. /**
  79390. * attach this feature
  79391. * Will usually be called by the features manager
  79392. *
  79393. * @returns true if successful.
  79394. */
  79395. attach(): boolean;
  79396. /**
  79397. * detach this feature.
  79398. * Will usually be called by the features manager
  79399. *
  79400. * @returns true if successful.
  79401. */
  79402. detach(): boolean;
  79403. /**
  79404. * Dispose this feature and all of the resources attached
  79405. */
  79406. dispose(): void;
  79407. protected _onXRFrame(_xrFrame: XRFrame): void;
  79408. private _setBackgroundState;
  79409. }
  79410. }
  79411. declare module BABYLON {
  79412. /**
  79413. * Options for the controller physics feature
  79414. */
  79415. export class IWebXRControllerPhysicsOptions {
  79416. /**
  79417. * Should the headset get its own impostor
  79418. */
  79419. enableHeadsetImpostor?: boolean;
  79420. /**
  79421. * Optional parameters for the headset impostor
  79422. */
  79423. headsetImpostorParams?: {
  79424. /**
  79425. * The type of impostor to create. Default is sphere
  79426. */
  79427. impostorType: number;
  79428. /**
  79429. * the size of the impostor. Defaults to 10cm
  79430. */
  79431. impostorSize?: number | {
  79432. width: number;
  79433. height: number;
  79434. depth: number;
  79435. };
  79436. /**
  79437. * Friction definitions
  79438. */
  79439. friction?: number;
  79440. /**
  79441. * Restitution
  79442. */
  79443. restitution?: number;
  79444. };
  79445. /**
  79446. * The physics properties of the future impostors
  79447. */
  79448. physicsProperties?: {
  79449. /**
  79450. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79451. * Note that this requires a physics engine that supports mesh impostors!
  79452. */
  79453. useControllerMesh?: boolean;
  79454. /**
  79455. * The type of impostor to create. Default is sphere
  79456. */
  79457. impostorType?: number;
  79458. /**
  79459. * the size of the impostor. Defaults to 10cm
  79460. */
  79461. impostorSize?: number | {
  79462. width: number;
  79463. height: number;
  79464. depth: number;
  79465. };
  79466. /**
  79467. * Friction definitions
  79468. */
  79469. friction?: number;
  79470. /**
  79471. * Restitution
  79472. */
  79473. restitution?: number;
  79474. };
  79475. /**
  79476. * the xr input to use with this pointer selection
  79477. */
  79478. xrInput: WebXRInput;
  79479. }
  79480. /**
  79481. * Add physics impostor to your webxr controllers,
  79482. * including naive calculation of their linear and angular velocity
  79483. */
  79484. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79485. private readonly _options;
  79486. private _attachController;
  79487. private _controllers;
  79488. private _debugMode;
  79489. private _delta;
  79490. private _headsetImpostor?;
  79491. private _headsetMesh?;
  79492. private _lastTimestamp;
  79493. private _tmpQuaternion;
  79494. private _tmpVector;
  79495. /**
  79496. * The module's name
  79497. */
  79498. static readonly Name: string;
  79499. /**
  79500. * The (Babylon) version of this module.
  79501. * This is an integer representing the implementation version.
  79502. * This number does not correspond to the webxr specs version
  79503. */
  79504. static readonly Version: number;
  79505. /**
  79506. * Construct a new Controller Physics Feature
  79507. * @param _xrSessionManager the corresponding xr session manager
  79508. * @param _options options to create this feature with
  79509. */
  79510. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79511. /**
  79512. * @hidden
  79513. * enable debugging - will show console outputs and the impostor mesh
  79514. */
  79515. _enablePhysicsDebug(): void;
  79516. /**
  79517. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79518. * @param xrController the controller to add
  79519. */
  79520. addController(xrController: WebXRInputSource): void;
  79521. /**
  79522. * attach this feature
  79523. * Will usually be called by the features manager
  79524. *
  79525. * @returns true if successful.
  79526. */
  79527. attach(): boolean;
  79528. /**
  79529. * detach this feature.
  79530. * Will usually be called by the features manager
  79531. *
  79532. * @returns true if successful.
  79533. */
  79534. detach(): boolean;
  79535. /**
  79536. * Get the headset impostor, if enabled
  79537. * @returns the impostor
  79538. */
  79539. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79540. /**
  79541. * Get the physics impostor of a specific controller.
  79542. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79543. * @param controller the controller or the controller id of which to get the impostor
  79544. * @returns the impostor or null
  79545. */
  79546. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79547. /**
  79548. * Update the physics properties provided in the constructor
  79549. * @param newProperties the new properties object
  79550. */
  79551. setPhysicsProperties(newProperties: {
  79552. impostorType?: number;
  79553. impostorSize?: number | {
  79554. width: number;
  79555. height: number;
  79556. depth: number;
  79557. };
  79558. friction?: number;
  79559. restitution?: number;
  79560. }): void;
  79561. protected _onXRFrame(_xrFrame: any): void;
  79562. private _detachController;
  79563. }
  79564. }
  79565. declare module BABYLON {
  79566. /**
  79567. * A babylon interface for a "WebXR" feature point.
  79568. * Represents the position and confidence value of a given feature point.
  79569. */
  79570. export interface IWebXRFeaturePoint {
  79571. /**
  79572. * Represents the position of the feature point in world space.
  79573. */
  79574. position: Vector3;
  79575. /**
  79576. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79577. */
  79578. confidenceValue: number;
  79579. }
  79580. /**
  79581. * The feature point system is used to detect feature points from real world geometry.
  79582. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79583. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79584. */
  79585. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79586. private _enabled;
  79587. private _featurePointCloud;
  79588. /**
  79589. * The module's name
  79590. */
  79591. static readonly Name: string;
  79592. /**
  79593. * The (Babylon) version of this module.
  79594. * This is an integer representing the implementation version.
  79595. * This number does not correspond to the WebXR specs version
  79596. */
  79597. static readonly Version: number;
  79598. /**
  79599. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79600. * Will notify the observers about which feature points have been added.
  79601. */
  79602. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79603. /**
  79604. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79605. * Will notify the observers about which feature points have been updated.
  79606. */
  79607. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79608. /**
  79609. * The current feature point cloud maintained across frames.
  79610. */
  79611. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79612. /**
  79613. * construct the feature point system
  79614. * @param _xrSessionManager an instance of xr Session manager
  79615. */
  79616. constructor(_xrSessionManager: WebXRSessionManager);
  79617. /**
  79618. * Detach this feature.
  79619. * Will usually be called by the features manager
  79620. *
  79621. * @returns true if successful.
  79622. */
  79623. detach(): boolean;
  79624. /**
  79625. * Dispose this feature and all of the resources attached
  79626. */
  79627. dispose(): void;
  79628. /**
  79629. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79630. */
  79631. protected _onXRFrame(frame: XRFrame): void;
  79632. /**
  79633. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79634. */
  79635. private _init;
  79636. }
  79637. }
  79638. declare module BABYLON {
  79639. /**
  79640. * Configuration interface for the hand tracking feature
  79641. */
  79642. export interface IWebXRHandTrackingOptions {
  79643. /**
  79644. * The xrInput that will be used as source for new hands
  79645. */
  79646. xrInput: WebXRInput;
  79647. /**
  79648. * Configuration object for the joint meshes
  79649. */
  79650. jointMeshes?: {
  79651. /**
  79652. * Should the meshes created be invisible (defaults to false)
  79653. */
  79654. invisible?: boolean;
  79655. /**
  79656. * A source mesh to be used to create instances. Defaults to a sphere.
  79657. * This mesh will be the source for all other (25) meshes.
  79658. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79659. */
  79660. sourceMesh?: Mesh;
  79661. /**
  79662. * This function will be called after a mesh was created for a specific joint.
  79663. * Using this function you can either manipulate the instance or return a new mesh.
  79664. * When returning a new mesh the instance created before will be disposed
  79665. */
  79666. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79667. /**
  79668. * Should the source mesh stay visible. Defaults to false
  79669. */
  79670. keepOriginalVisible?: boolean;
  79671. /**
  79672. * Scale factor for all instances (defaults to 2)
  79673. */
  79674. scaleFactor?: number;
  79675. /**
  79676. * Should each instance have its own physics impostor
  79677. */
  79678. enablePhysics?: boolean;
  79679. /**
  79680. * If enabled, override default physics properties
  79681. */
  79682. physicsProps?: {
  79683. friction?: number;
  79684. restitution?: number;
  79685. impostorType?: number;
  79686. };
  79687. /**
  79688. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79689. */
  79690. disableDefaultHandMesh?: boolean;
  79691. /**
  79692. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79693. */
  79694. handMeshes?: {
  79695. right: AbstractMesh;
  79696. left: AbstractMesh;
  79697. };
  79698. /**
  79699. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79700. */
  79701. rigMapping?: {
  79702. right: string[];
  79703. left: string[];
  79704. };
  79705. };
  79706. }
  79707. /**
  79708. * Parts of the hands divided to writs and finger names
  79709. */
  79710. export const enum HandPart {
  79711. /**
  79712. * HandPart - Wrist
  79713. */
  79714. WRIST = "wrist",
  79715. /**
  79716. * HandPart - The THumb
  79717. */
  79718. THUMB = "thumb",
  79719. /**
  79720. * HandPart - Index finger
  79721. */
  79722. INDEX = "index",
  79723. /**
  79724. * HandPart - Middle finger
  79725. */
  79726. MIDDLE = "middle",
  79727. /**
  79728. * HandPart - Ring finger
  79729. */
  79730. RING = "ring",
  79731. /**
  79732. * HandPart - Little finger
  79733. */
  79734. LITTLE = "little"
  79735. }
  79736. /**
  79737. * Representing a single hand (with its corresponding native XRHand object)
  79738. */
  79739. export class WebXRHand implements IDisposable {
  79740. /** the controller to which the hand correlates */
  79741. readonly xrController: WebXRInputSource;
  79742. /** the meshes to be used to track the hand joints */
  79743. readonly trackedMeshes: AbstractMesh[];
  79744. private _handMesh?;
  79745. private _rigMapping?;
  79746. private _scene;
  79747. private _defaultHandMesh;
  79748. private _transformNodeMapping;
  79749. /**
  79750. * Hand-parts definition (key is HandPart)
  79751. */
  79752. handPartsDefinition: {
  79753. [key: string]: number[];
  79754. };
  79755. /**
  79756. * Observers will be triggered when the mesh for this hand was initialized.
  79757. */
  79758. onHandMeshReadyObservable: Observable<WebXRHand>;
  79759. /**
  79760. * Populate the HandPartsDefinition object.
  79761. * This is called as a side effect since certain browsers don't have XRHand defined.
  79762. */
  79763. private generateHandPartsDefinition;
  79764. /**
  79765. * Construct a new hand object
  79766. * @param xrController the controller to which the hand correlates
  79767. * @param trackedMeshes the meshes to be used to track the hand joints
  79768. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79769. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79770. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79771. */
  79772. constructor(
  79773. /** the controller to which the hand correlates */
  79774. xrController: WebXRInputSource,
  79775. /** the meshes to be used to track the hand joints */
  79776. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79777. /**
  79778. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79779. */
  79780. get handMesh(): AbstractMesh | undefined;
  79781. /**
  79782. * Update this hand from the latest xr frame
  79783. * @param xrFrame xrFrame to update from
  79784. * @param referenceSpace The current viewer reference space
  79785. * @param scaleFactor optional scale factor for the meshes
  79786. */
  79787. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79788. /**
  79789. * Get meshes of part of the hand
  79790. * @param part the part of hand to get
  79791. * @returns An array of meshes that correlate to the hand part requested
  79792. */
  79793. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79794. /**
  79795. * Dispose this Hand object
  79796. */
  79797. dispose(): void;
  79798. private _generateDefaultHandMesh;
  79799. }
  79800. /**
  79801. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79802. */
  79803. export class WebXRHandTracking extends WebXRAbstractFeature {
  79804. /**
  79805. * options to use when constructing this feature
  79806. */
  79807. readonly options: IWebXRHandTrackingOptions;
  79808. private static _idCounter;
  79809. /**
  79810. * The module's name
  79811. */
  79812. static readonly Name: string;
  79813. /**
  79814. * The (Babylon) version of this module.
  79815. * This is an integer representing the implementation version.
  79816. * This number does not correspond to the WebXR specs version
  79817. */
  79818. static readonly Version: number;
  79819. /**
  79820. * This observable will notify registered observers when a new hand object was added and initialized
  79821. */
  79822. onHandAddedObservable: Observable<WebXRHand>;
  79823. /**
  79824. * This observable will notify its observers right before the hand object is disposed
  79825. */
  79826. onHandRemovedObservable: Observable<WebXRHand>;
  79827. private _hands;
  79828. /**
  79829. * Creates a new instance of the hit test feature
  79830. * @param _xrSessionManager an instance of WebXRSessionManager
  79831. * @param options options to use when constructing this feature
  79832. */
  79833. constructor(_xrSessionManager: WebXRSessionManager,
  79834. /**
  79835. * options to use when constructing this feature
  79836. */
  79837. options: IWebXRHandTrackingOptions);
  79838. /**
  79839. * Check if the needed objects are defined.
  79840. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79841. */
  79842. isCompatible(): boolean;
  79843. /**
  79844. * attach this feature
  79845. * Will usually be called by the features manager
  79846. *
  79847. * @returns true if successful.
  79848. */
  79849. attach(): boolean;
  79850. /**
  79851. * detach this feature.
  79852. * Will usually be called by the features manager
  79853. *
  79854. * @returns true if successful.
  79855. */
  79856. detach(): boolean;
  79857. /**
  79858. * Dispose this feature and all of the resources attached
  79859. */
  79860. dispose(): void;
  79861. /**
  79862. * Get the hand object according to the controller id
  79863. * @param controllerId the controller id to which we want to get the hand
  79864. * @returns null if not found or the WebXRHand object if found
  79865. */
  79866. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79867. /**
  79868. * Get a hand object according to the requested handedness
  79869. * @param handedness the handedness to request
  79870. * @returns null if not found or the WebXRHand object if found
  79871. */
  79872. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79873. protected _onXRFrame(_xrFrame: XRFrame): void;
  79874. private _attachHand;
  79875. private _detachHand;
  79876. }
  79877. }
  79878. declare module BABYLON {
  79879. /**
  79880. * Options used in the mesh detector module
  79881. */
  79882. export interface IWebXRMeshDetectorOptions {
  79883. /**
  79884. * The node to use to transform the local results to world coordinates
  79885. */
  79886. worldParentNode?: TransformNode;
  79887. /**
  79888. * If set to true a reference of the created meshes will be kept until the next session starts
  79889. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  79890. */
  79891. doNotRemoveMeshesOnSessionEnded?: boolean;
  79892. /**
  79893. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79894. */
  79895. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79896. /**
  79897. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  79898. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  79899. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  79900. */
  79901. convertCoordinateSystems?: boolean;
  79902. }
  79903. /**
  79904. * A babylon interface for a XR mesh's vertex data.
  79905. *
  79906. * Currently not supported by WebXR, available only with BabylonNative
  79907. */
  79908. export interface IWebXRVertexData {
  79909. /**
  79910. * A babylon-assigned ID for this mesh
  79911. */
  79912. id: number;
  79913. /**
  79914. * Data required for constructing a mesh in Babylon.js.
  79915. */
  79916. xrMesh: XRMesh;
  79917. /**
  79918. * The node to use to transform the local results to world coordinates.
  79919. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  79920. */
  79921. worldParentNode?: TransformNode;
  79922. /**
  79923. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  79924. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79925. */
  79926. positions?: Float32Array;
  79927. /**
  79928. * An array of indices in babylon space. right/left hand system is taken into account.
  79929. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79930. */
  79931. indices?: Uint32Array;
  79932. /**
  79933. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  79934. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  79935. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  79936. */
  79937. normals?: Float32Array;
  79938. /**
  79939. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  79940. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  79941. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79942. */
  79943. transformationMatrix?: Matrix;
  79944. }
  79945. /**
  79946. * The mesh detector is used to detect meshes in the real world when in AR
  79947. */
  79948. export class WebXRMeshDetector extends WebXRAbstractFeature {
  79949. private _options;
  79950. private _detectedMeshes;
  79951. /**
  79952. * The module's name
  79953. */
  79954. static readonly Name: string;
  79955. /**
  79956. * The (Babylon) version of this module.
  79957. * This is an integer representing the implementation version.
  79958. * This number does not correspond to the WebXR specs version
  79959. */
  79960. static readonly Version: number;
  79961. /**
  79962. * Observers registered here will be executed when a new mesh was added to the session
  79963. */
  79964. onMeshAddedObservable: Observable<IWebXRVertexData>;
  79965. /**
  79966. * Observers registered here will be executed when a mesh is no longer detected in the session
  79967. */
  79968. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  79969. /**
  79970. * Observers registered here will be executed when an existing mesh updates
  79971. */
  79972. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  79973. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  79974. detach(): boolean;
  79975. dispose(): void;
  79976. protected _onXRFrame(frame: XRFrame): void;
  79977. private _init;
  79978. private _updateVertexDataWithXRMesh;
  79979. }
  79980. }
  79981. declare module BABYLON {
  79982. /**
  79983. * Options interface for the background remover plugin
  79984. */
  79985. export interface IWebXRImageTrackingOptions {
  79986. /**
  79987. * A required array with images to track
  79988. */
  79989. images: {
  79990. /**
  79991. * The source of the image. can be a URL or an image bitmap
  79992. */
  79993. src: string | ImageBitmap;
  79994. /**
  79995. * The estimated width in the real world (in meters)
  79996. */
  79997. estimatedRealWorldWidth: number;
  79998. }[];
  79999. }
  80000. /**
  80001. * An object representing an image tracked by the system
  80002. */
  80003. export interface IWebXRTrackedImage {
  80004. /**
  80005. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80006. */
  80007. id: number;
  80008. /**
  80009. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80010. */
  80011. emulated?: boolean;
  80012. /**
  80013. * Just in case it is needed - the image bitmap that is being tracked
  80014. */
  80015. originalBitmap: ImageBitmap;
  80016. /**
  80017. * The native XR result image tracking result, untouched
  80018. */
  80019. xrTrackingResult?: XRImageTrackingResult;
  80020. /**
  80021. * Width in real world (meters)
  80022. */
  80023. realWorldWidth?: number;
  80024. /**
  80025. * A transformation matrix of this current image in the current reference space.
  80026. */
  80027. transformationMatrix: Matrix;
  80028. /**
  80029. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80030. */
  80031. ratio?: number;
  80032. }
  80033. /**
  80034. * Image tracking for immersive AR sessions.
  80035. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80036. */
  80037. export class WebXRImageTracking extends WebXRAbstractFeature {
  80038. /**
  80039. * read-only options to be used in this module
  80040. */
  80041. readonly options: IWebXRImageTrackingOptions;
  80042. /**
  80043. * The module's name
  80044. */
  80045. static readonly Name: string;
  80046. /**
  80047. * The (Babylon) version of this module.
  80048. * This is an integer representing the implementation version.
  80049. * This number does not correspond to the WebXR specs version
  80050. */
  80051. static readonly Version: number;
  80052. /**
  80053. * This will be triggered if the underlying system deems an image untrackable.
  80054. * The index is the index of the image from the array used to initialize the feature.
  80055. */
  80056. onUntrackableImageFoundObservable: Observable<number>;
  80057. /**
  80058. * An image was deemed trackable, and the system will start tracking it.
  80059. */
  80060. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80061. /**
  80062. * The image was found and its state was updated.
  80063. */
  80064. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80065. private _trackedImages;
  80066. private _originalTrackingRequest;
  80067. /**
  80068. * constructs the image tracking feature
  80069. * @param _xrSessionManager the session manager for this module
  80070. * @param options read-only options to be used in this module
  80071. */
  80072. constructor(_xrSessionManager: WebXRSessionManager,
  80073. /**
  80074. * read-only options to be used in this module
  80075. */
  80076. options: IWebXRImageTrackingOptions);
  80077. /**
  80078. * attach this feature
  80079. * Will usually be called by the features manager
  80080. *
  80081. * @returns true if successful.
  80082. */
  80083. attach(): boolean;
  80084. /**
  80085. * detach this feature.
  80086. * Will usually be called by the features manager
  80087. *
  80088. * @returns true if successful.
  80089. */
  80090. detach(): boolean;
  80091. /**
  80092. * Check if the needed objects are defined.
  80093. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80094. */
  80095. isCompatible(): boolean;
  80096. /**
  80097. * Get a tracked image by its ID.
  80098. *
  80099. * @param id the id of the image to load (position in the init array)
  80100. * @returns a trackable image, if exists in this location
  80101. */
  80102. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80103. /**
  80104. * Dispose this feature and all of the resources attached
  80105. */
  80106. dispose(): void;
  80107. /**
  80108. * Extends the session init object if needed
  80109. * @returns augmentation object fo the xr session init object.
  80110. */
  80111. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80112. protected _onXRFrame(_xrFrame: XRFrame): void;
  80113. private _init;
  80114. }
  80115. }
  80116. declare module BABYLON {
  80117. /**
  80118. * The motion controller class for all microsoft mixed reality controllers
  80119. */
  80120. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80121. protected readonly _mapping: {
  80122. defaultButton: {
  80123. valueNodeName: string;
  80124. unpressedNodeName: string;
  80125. pressedNodeName: string;
  80126. };
  80127. defaultAxis: {
  80128. valueNodeName: string;
  80129. minNodeName: string;
  80130. maxNodeName: string;
  80131. };
  80132. buttons: {
  80133. "xr-standard-trigger": {
  80134. rootNodeName: string;
  80135. componentProperty: string;
  80136. states: string[];
  80137. };
  80138. "xr-standard-squeeze": {
  80139. rootNodeName: string;
  80140. componentProperty: string;
  80141. states: string[];
  80142. };
  80143. "xr-standard-touchpad": {
  80144. rootNodeName: string;
  80145. labelAnchorNodeName: string;
  80146. touchPointNodeName: string;
  80147. };
  80148. "xr-standard-thumbstick": {
  80149. rootNodeName: string;
  80150. componentProperty: string;
  80151. states: string[];
  80152. };
  80153. };
  80154. axes: {
  80155. "xr-standard-touchpad": {
  80156. "x-axis": {
  80157. rootNodeName: string;
  80158. };
  80159. "y-axis": {
  80160. rootNodeName: string;
  80161. };
  80162. };
  80163. "xr-standard-thumbstick": {
  80164. "x-axis": {
  80165. rootNodeName: string;
  80166. };
  80167. "y-axis": {
  80168. rootNodeName: string;
  80169. };
  80170. };
  80171. };
  80172. };
  80173. /**
  80174. * The base url used to load the left and right controller models
  80175. */
  80176. static MODEL_BASE_URL: string;
  80177. /**
  80178. * The name of the left controller model file
  80179. */
  80180. static MODEL_LEFT_FILENAME: string;
  80181. /**
  80182. * The name of the right controller model file
  80183. */
  80184. static MODEL_RIGHT_FILENAME: string;
  80185. profileId: string;
  80186. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80187. protected _getFilenameAndPath(): {
  80188. filename: string;
  80189. path: string;
  80190. };
  80191. protected _getModelLoadingConstraints(): boolean;
  80192. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80193. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80194. protected _updateModel(): void;
  80195. }
  80196. }
  80197. declare module BABYLON {
  80198. /**
  80199. * The motion controller class for oculus touch (quest, rift).
  80200. * This class supports legacy mapping as well the standard xr mapping
  80201. */
  80202. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80203. private _forceLegacyControllers;
  80204. private _modelRootNode;
  80205. /**
  80206. * The base url used to load the left and right controller models
  80207. */
  80208. static MODEL_BASE_URL: string;
  80209. /**
  80210. * The name of the left controller model file
  80211. */
  80212. static MODEL_LEFT_FILENAME: string;
  80213. /**
  80214. * The name of the right controller model file
  80215. */
  80216. static MODEL_RIGHT_FILENAME: string;
  80217. /**
  80218. * Base Url for the Quest controller model.
  80219. */
  80220. static QUEST_MODEL_BASE_URL: string;
  80221. profileId: string;
  80222. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80223. protected _getFilenameAndPath(): {
  80224. filename: string;
  80225. path: string;
  80226. };
  80227. protected _getModelLoadingConstraints(): boolean;
  80228. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80229. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80230. protected _updateModel(): void;
  80231. /**
  80232. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80233. * between the touch and touch 2.
  80234. */
  80235. private _isQuest;
  80236. }
  80237. }
  80238. declare module BABYLON {
  80239. /**
  80240. * The motion controller class for the standard HTC-Vive controllers
  80241. */
  80242. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80243. private _modelRootNode;
  80244. /**
  80245. * The base url used to load the left and right controller models
  80246. */
  80247. static MODEL_BASE_URL: string;
  80248. /**
  80249. * File name for the controller model.
  80250. */
  80251. static MODEL_FILENAME: string;
  80252. profileId: string;
  80253. /**
  80254. * Create a new Vive motion controller object
  80255. * @param scene the scene to use to create this controller
  80256. * @param gamepadObject the corresponding gamepad object
  80257. * @param handedness the handedness of the controller
  80258. */
  80259. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80260. protected _getFilenameAndPath(): {
  80261. filename: string;
  80262. path: string;
  80263. };
  80264. protected _getModelLoadingConstraints(): boolean;
  80265. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80266. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80267. protected _updateModel(): void;
  80268. }
  80269. }
  80270. declare module BABYLON {
  80271. /**
  80272. * A cursor which tracks a point on a path
  80273. */
  80274. export class PathCursor {
  80275. private path;
  80276. /**
  80277. * Stores path cursor callbacks for when an onchange event is triggered
  80278. */
  80279. private _onchange;
  80280. /**
  80281. * The value of the path cursor
  80282. */
  80283. value: number;
  80284. /**
  80285. * The animation array of the path cursor
  80286. */
  80287. animations: Animation[];
  80288. /**
  80289. * Initializes the path cursor
  80290. * @param path The path to track
  80291. */
  80292. constructor(path: Path2);
  80293. /**
  80294. * Gets the cursor point on the path
  80295. * @returns A point on the path cursor at the cursor location
  80296. */
  80297. getPoint(): Vector3;
  80298. /**
  80299. * Moves the cursor ahead by the step amount
  80300. * @param step The amount to move the cursor forward
  80301. * @returns This path cursor
  80302. */
  80303. moveAhead(step?: number): PathCursor;
  80304. /**
  80305. * Moves the cursor behind by the step amount
  80306. * @param step The amount to move the cursor back
  80307. * @returns This path cursor
  80308. */
  80309. moveBack(step?: number): PathCursor;
  80310. /**
  80311. * Moves the cursor by the step amount
  80312. * If the step amount is greater than one, an exception is thrown
  80313. * @param step The amount to move the cursor
  80314. * @returns This path cursor
  80315. */
  80316. move(step: number): PathCursor;
  80317. /**
  80318. * Ensures that the value is limited between zero and one
  80319. * @returns This path cursor
  80320. */
  80321. private ensureLimits;
  80322. /**
  80323. * Runs onchange callbacks on change (used by the animation engine)
  80324. * @returns This path cursor
  80325. */
  80326. private raiseOnChange;
  80327. /**
  80328. * Executes a function on change
  80329. * @param f A path cursor onchange callback
  80330. * @returns This path cursor
  80331. */
  80332. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80333. }
  80334. }
  80335. declare module BABYLON {
  80336. /** @hidden */
  80337. export var blurPixelShader: {
  80338. name: string;
  80339. shader: string;
  80340. };
  80341. }
  80342. declare module BABYLON {
  80343. /** @hidden */
  80344. export var pointCloudVertexDeclaration: {
  80345. name: string;
  80346. shader: string;
  80347. };
  80348. }
  80349. // Mixins
  80350. interface Window {
  80351. mozIndexedDB: IDBFactory;
  80352. webkitIndexedDB: IDBFactory;
  80353. msIndexedDB: IDBFactory;
  80354. webkitURL: typeof URL;
  80355. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80356. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80357. WebGLRenderingContext: WebGLRenderingContext;
  80358. MSGesture: MSGesture;
  80359. CANNON: any;
  80360. AudioContext: AudioContext;
  80361. webkitAudioContext: AudioContext;
  80362. PointerEvent: any;
  80363. Math: Math;
  80364. Uint8Array: Uint8ArrayConstructor;
  80365. Float32Array: Float32ArrayConstructor;
  80366. mozURL: typeof URL;
  80367. msURL: typeof URL;
  80368. VRFrameData: any; // WebVR, from specs 1.1
  80369. DracoDecoderModule: any;
  80370. setImmediate(handler: (...args: any[]) => void): number;
  80371. }
  80372. interface HTMLCanvasElement {
  80373. requestPointerLock(): void;
  80374. msRequestPointerLock?(): void;
  80375. mozRequestPointerLock?(): void;
  80376. webkitRequestPointerLock?(): void;
  80377. /** Track wether a record is in progress */
  80378. isRecording: boolean;
  80379. /** Capture Stream method defined by some browsers */
  80380. captureStream(fps?: number): MediaStream;
  80381. }
  80382. interface CanvasRenderingContext2D {
  80383. msImageSmoothingEnabled: boolean;
  80384. }
  80385. interface MouseEvent {
  80386. mozMovementX: number;
  80387. mozMovementY: number;
  80388. webkitMovementX: number;
  80389. webkitMovementY: number;
  80390. msMovementX: number;
  80391. msMovementY: number;
  80392. }
  80393. interface Navigator {
  80394. mozGetVRDevices: (any: any) => any;
  80395. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80396. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80397. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80398. webkitGetGamepads(): Gamepad[];
  80399. msGetGamepads(): Gamepad[];
  80400. webkitGamepads(): Gamepad[];
  80401. }
  80402. interface HTMLVideoElement {
  80403. mozSrcObject: any;
  80404. }
  80405. interface Math {
  80406. fround(x: number): number;
  80407. imul(a: number, b: number): number;
  80408. log2(x: number): number;
  80409. }
  80410. interface WebGLRenderingContext {
  80411. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80412. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80413. vertexAttribDivisor(index: number, divisor: number): void;
  80414. createVertexArray(): any;
  80415. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80416. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80417. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80418. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80419. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80420. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80421. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80422. // Queries
  80423. createQuery(): WebGLQuery;
  80424. deleteQuery(query: WebGLQuery): void;
  80425. beginQuery(target: number, query: WebGLQuery): void;
  80426. endQuery(target: number): void;
  80427. getQueryParameter(query: WebGLQuery, pname: number): any;
  80428. getQuery(target: number, pname: number): any;
  80429. MAX_SAMPLES: number;
  80430. RGBA8: number;
  80431. READ_FRAMEBUFFER: number;
  80432. DRAW_FRAMEBUFFER: number;
  80433. UNIFORM_BUFFER: number;
  80434. HALF_FLOAT_OES: number;
  80435. RGBA16F: number;
  80436. RGBA32F: number;
  80437. R32F: number;
  80438. RG32F: number;
  80439. RGB32F: number;
  80440. R16F: number;
  80441. RG16F: number;
  80442. RGB16F: number;
  80443. RED: number;
  80444. RG: number;
  80445. R8: number;
  80446. RG8: number;
  80447. UNSIGNED_INT_24_8: number;
  80448. DEPTH24_STENCIL8: number;
  80449. MIN: number;
  80450. MAX: number;
  80451. /* Multiple Render Targets */
  80452. drawBuffers(buffers: number[]): void;
  80453. readBuffer(src: number): void;
  80454. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80455. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80456. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80457. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80458. // Occlusion Query
  80459. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80460. ANY_SAMPLES_PASSED: number;
  80461. QUERY_RESULT_AVAILABLE: number;
  80462. QUERY_RESULT: number;
  80463. }
  80464. interface WebGLProgram {
  80465. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80466. }
  80467. interface EXT_disjoint_timer_query {
  80468. QUERY_COUNTER_BITS_EXT: number;
  80469. TIME_ELAPSED_EXT: number;
  80470. TIMESTAMP_EXT: number;
  80471. GPU_DISJOINT_EXT: number;
  80472. QUERY_RESULT_EXT: number;
  80473. QUERY_RESULT_AVAILABLE_EXT: number;
  80474. queryCounterEXT(query: WebGLQuery, target: number): void;
  80475. createQueryEXT(): WebGLQuery;
  80476. beginQueryEXT(target: number, query: WebGLQuery): void;
  80477. endQueryEXT(target: number): void;
  80478. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80479. deleteQueryEXT(query: WebGLQuery): void;
  80480. }
  80481. interface WebGLUniformLocation {
  80482. _currentState: any;
  80483. }
  80484. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80485. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80486. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80487. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80488. interface WebGLRenderingContext {
  80489. readonly RASTERIZER_DISCARD: number;
  80490. readonly DEPTH_COMPONENT24: number;
  80491. readonly TEXTURE_3D: number;
  80492. readonly TEXTURE_2D_ARRAY: number;
  80493. readonly TEXTURE_COMPARE_FUNC: number;
  80494. readonly TEXTURE_COMPARE_MODE: number;
  80495. readonly COMPARE_REF_TO_TEXTURE: number;
  80496. readonly TEXTURE_WRAP_R: number;
  80497. readonly HALF_FLOAT: number;
  80498. readonly RGB8: number;
  80499. readonly RED_INTEGER: number;
  80500. readonly RG_INTEGER: number;
  80501. readonly RGB_INTEGER: number;
  80502. readonly RGBA_INTEGER: number;
  80503. readonly R8_SNORM: number;
  80504. readonly RG8_SNORM: number;
  80505. readonly RGB8_SNORM: number;
  80506. readonly RGBA8_SNORM: number;
  80507. readonly R8I: number;
  80508. readonly RG8I: number;
  80509. readonly RGB8I: number;
  80510. readonly RGBA8I: number;
  80511. readonly R8UI: number;
  80512. readonly RG8UI: number;
  80513. readonly RGB8UI: number;
  80514. readonly RGBA8UI: number;
  80515. readonly R16I: number;
  80516. readonly RG16I: number;
  80517. readonly RGB16I: number;
  80518. readonly RGBA16I: number;
  80519. readonly R16UI: number;
  80520. readonly RG16UI: number;
  80521. readonly RGB16UI: number;
  80522. readonly RGBA16UI: number;
  80523. readonly R32I: number;
  80524. readonly RG32I: number;
  80525. readonly RGB32I: number;
  80526. readonly RGBA32I: number;
  80527. readonly R32UI: number;
  80528. readonly RG32UI: number;
  80529. readonly RGB32UI: number;
  80530. readonly RGBA32UI: number;
  80531. readonly RGB10_A2UI: number;
  80532. readonly R11F_G11F_B10F: number;
  80533. readonly RGB9_E5: number;
  80534. readonly RGB10_A2: number;
  80535. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80536. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80537. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80538. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80539. readonly DEPTH_COMPONENT32F: number;
  80540. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80541. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80542. 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;
  80543. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80544. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80545. readonly TRANSFORM_FEEDBACK: number;
  80546. readonly INTERLEAVED_ATTRIBS: number;
  80547. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80548. createTransformFeedback(): WebGLTransformFeedback;
  80549. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80550. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80551. beginTransformFeedback(primitiveMode: number): void;
  80552. endTransformFeedback(): void;
  80553. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80554. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80555. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80556. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80557. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80558. }
  80559. interface ImageBitmap {
  80560. readonly width: number;
  80561. readonly height: number;
  80562. close(): void;
  80563. }
  80564. interface WebGLQuery extends WebGLObject {
  80565. }
  80566. declare var WebGLQuery: {
  80567. prototype: WebGLQuery;
  80568. new(): WebGLQuery;
  80569. };
  80570. interface WebGLSampler extends WebGLObject {
  80571. }
  80572. declare var WebGLSampler: {
  80573. prototype: WebGLSampler;
  80574. new(): WebGLSampler;
  80575. };
  80576. interface WebGLSync extends WebGLObject {
  80577. }
  80578. declare var WebGLSync: {
  80579. prototype: WebGLSync;
  80580. new(): WebGLSync;
  80581. };
  80582. interface WebGLTransformFeedback extends WebGLObject {
  80583. }
  80584. declare var WebGLTransformFeedback: {
  80585. prototype: WebGLTransformFeedback;
  80586. new(): WebGLTransformFeedback;
  80587. };
  80588. interface WebGLVertexArrayObject extends WebGLObject {
  80589. }
  80590. declare var WebGLVertexArrayObject: {
  80591. prototype: WebGLVertexArrayObject;
  80592. new(): WebGLVertexArrayObject;
  80593. };
  80594. interface Navigator {
  80595. readonly gpu: GPU | undefined;
  80596. }
  80597. interface GPUColorDict {
  80598. a: number;
  80599. b: number;
  80600. g: number;
  80601. r: number;
  80602. }
  80603. type GPUColor = [number, number, number, number] | GPUColorDict;
  80604. interface GPUOrigin2DDict {
  80605. x?: number;
  80606. y?: number;
  80607. }
  80608. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80609. interface GPUOrigin3DDict {
  80610. x?: number;
  80611. y?: number;
  80612. z?: number;
  80613. }
  80614. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80615. interface GPUExtent3DDict {
  80616. width: number;
  80617. height: number;
  80618. depth: number;
  80619. }
  80620. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80621. type GPUBindingResource =
  80622. | GPUSampler
  80623. | GPUTextureView
  80624. | GPUBufferBinding;
  80625. type GPUExtensionName =
  80626. | "texture-compression-bc"
  80627. | "timestamp-query"
  80628. | "pipeline-statistics-query"
  80629. | "depth-clamping"
  80630. | "depth24unorm-stencil8"
  80631. | "depth32float-stencil8";
  80632. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80633. type GPUBindingType =
  80634. | "uniform-buffer"
  80635. | "storage-buffer"
  80636. | "readonly-storage-buffer"
  80637. | "sampler"
  80638. | "comparison-sampler"
  80639. | "sampled-texture"
  80640. | "readonly-storage-texture"
  80641. | "writeonly-storage-texture";
  80642. type GPUBlendFactor =
  80643. | "zero"
  80644. | "one"
  80645. | "src-color"
  80646. | "one-minus-src-color"
  80647. | "src-alpha"
  80648. | "one-minus-src-alpha"
  80649. | "dst-color"
  80650. | "one-minus-dst-color"
  80651. | "dst-alpha"
  80652. | "one-minus-dst-alpha"
  80653. | "src-alpha-saturated"
  80654. | "blend-color"
  80655. | "one-minus-blend-color";
  80656. type GPUBlendOperation =
  80657. | "add"
  80658. | "subtract"
  80659. | "reverse-subtract"
  80660. | "min"
  80661. | "max";
  80662. type GPUCompareFunction =
  80663. | "never"
  80664. | "less"
  80665. | "equal"
  80666. | "less-equal"
  80667. | "greater"
  80668. | "not-equal"
  80669. | "greater-equal"
  80670. | "always";
  80671. type GPUCullMode = "none" | "front" | "back";
  80672. type GPUFilterMode = "nearest" | "linear";
  80673. type GPUFrontFace = "ccw" | "cw";
  80674. type GPUIndexFormat = "uint16" | "uint32";
  80675. type GPUInputStepMode = "vertex" | "instance";
  80676. type GPULoadOp = "load";
  80677. type GPUPrimitiveTopology =
  80678. | "point-list"
  80679. | "line-list"
  80680. | "line-strip"
  80681. | "triangle-list"
  80682. | "triangle-strip";
  80683. type GPUStencilOperation =
  80684. | "keep"
  80685. | "zero"
  80686. | "replace"
  80687. | "invert"
  80688. | "increment-clamp"
  80689. | "decrement-clamp"
  80690. | "increment-wrap"
  80691. | "decrement-wrap";
  80692. type GPUStoreOp = "store" | "clear";
  80693. type GPUTextureDimension = "1d" | "2d" | "3d";
  80694. type GPUTextureFormat =
  80695. | "r8unorm"
  80696. | "r8snorm"
  80697. | "r8uint"
  80698. | "r8sint"
  80699. | "r16uint"
  80700. | "r16sint"
  80701. | "r16float"
  80702. | "rg8unorm"
  80703. | "rg8snorm"
  80704. | "rg8uint"
  80705. | "rg8sint"
  80706. | "r32uint"
  80707. | "r32sint"
  80708. | "r32float"
  80709. | "rg16uint"
  80710. | "rg16sint"
  80711. | "rg16float"
  80712. | "rgba8unorm"
  80713. | "rgba8unorm-srgb"
  80714. | "rgba8snorm"
  80715. | "rgba8uint"
  80716. | "rgba8sint"
  80717. | "bgra8unorm"
  80718. | "bgra8unorm-srgb"
  80719. | "rgb9e5ufloat"
  80720. | "rgb10a2unorm"
  80721. | "rg11b10ufloat"
  80722. | "rg32uint"
  80723. | "rg32sint"
  80724. | "rg32float"
  80725. | "rgba16uint"
  80726. | "rgba16sint"
  80727. | "rgba16float"
  80728. | "rgba32uint"
  80729. | "rgba32sint"
  80730. | "rgba32float"
  80731. | "stencil8"
  80732. | "depth16unorm"
  80733. | "depth24plus"
  80734. | "depth24plus-stencil8"
  80735. | "depth32float"
  80736. | "bc1-rgba-unorm"
  80737. | "bc1-rgba-unorm-srgb"
  80738. | "bc2-rgba-unorm"
  80739. | "bc2-rgba-unorm-srgb"
  80740. | "bc3-rgba-unorm"
  80741. | "bc3-rgba-unorm-srgb"
  80742. | "bc4-r-unorm"
  80743. | "bc4-r-snorm"
  80744. | "bc5-rg-unorm"
  80745. | "bc5-rg-snorm"
  80746. | "bc6h-rgb-ufloat"
  80747. | "bc6h-rgb-float"
  80748. | "bc7-rgba-unorm"
  80749. | "bc7-rgba-unorm-srgb"
  80750. | "depth24unorm-stencil8"
  80751. | "depth32float-stencil8";
  80752. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80753. type GPUTextureViewDimension =
  80754. | "1d"
  80755. | "2d"
  80756. | "2d-array"
  80757. | "cube"
  80758. | "cube-array"
  80759. | "3d";
  80760. type GPUVertexFormat =
  80761. | "uchar2"
  80762. | "uchar4"
  80763. | "char2"
  80764. | "char4"
  80765. | "uchar2norm"
  80766. | "uchar4norm"
  80767. | "char2norm"
  80768. | "char4norm"
  80769. | "ushort2"
  80770. | "ushort4"
  80771. | "short2"
  80772. | "short4"
  80773. | "ushort2norm"
  80774. | "ushort4norm"
  80775. | "short2norm"
  80776. | "short4norm"
  80777. | "half2"
  80778. | "half4"
  80779. | "float"
  80780. | "float2"
  80781. | "float3"
  80782. | "float4"
  80783. | "uint"
  80784. | "uint2"
  80785. | "uint3"
  80786. | "uint4"
  80787. | "int"
  80788. | "int2"
  80789. | "int3"
  80790. | "int4";
  80791. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80792. type GPUBufferUsageFlags = number;
  80793. type GPUColorWriteFlags = number;
  80794. type GPUShaderStageFlags = number;
  80795. type GPUTextureUsageFlags = number;
  80796. type GPUMapModeFlags = number;
  80797. interface GPUBindGroupEntry {
  80798. binding: number;
  80799. resource: GPUBindingResource;
  80800. }
  80801. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80802. layout: GPUBindGroupLayout;
  80803. entries: Iterable<GPUBindGroupEntry>;
  80804. }
  80805. interface GPUBindGroupLayoutEntry {
  80806. binding: number;
  80807. visibility: GPUShaderStageFlags;
  80808. type: GPUBindingType;
  80809. hasDynamicOffset?: boolean;
  80810. minBufferBindingSize?: number;
  80811. viewDimension?: GPUTextureViewDimension;
  80812. textureComponentType?: GPUTextureComponentType;
  80813. storageTextureFormat?: GPUTextureFormat;
  80814. }
  80815. interface GPUBindGroupLayoutDescriptor
  80816. extends GPUObjectDescriptorBase {
  80817. entries: Iterable<GPUBindGroupLayoutEntry>;
  80818. }
  80819. interface GPUBlendDescriptor {
  80820. dstFactor?: GPUBlendFactor;
  80821. operation?: GPUBlendOperation;
  80822. srcFactor?: GPUBlendFactor;
  80823. }
  80824. interface GPUColorStateDescriptor {
  80825. format: GPUTextureFormat;
  80826. alphaBlend?: GPUBlendDescriptor;
  80827. colorBlend?: GPUBlendDescriptor;
  80828. writeMask?: GPUColorWriteFlags;
  80829. }
  80830. interface GPUBufferBinding {
  80831. buffer: GPUBuffer;
  80832. offset?: number;
  80833. size?: number;
  80834. }
  80835. interface GPUTextureDataLayout {
  80836. offset?: number;
  80837. bytesPerRow: number;
  80838. rowsPerImage?: number;
  80839. }
  80840. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80841. buffer: GPUBuffer;
  80842. }
  80843. interface GPUTextureCopyView {
  80844. texture: GPUTexture;
  80845. mipLevel?: number;
  80846. origin?: GPUOrigin3D;
  80847. }
  80848. interface GPUImageBitmapCopyView {
  80849. imageBitmap: ImageBitmap;
  80850. origin?: GPUOrigin2D;
  80851. }
  80852. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80853. size: number;
  80854. usage: GPUBufferUsageFlags;
  80855. mappedAtCreation?: boolean;
  80856. }
  80857. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80858. label?: string;
  80859. measureExecutionTime?: boolean;
  80860. }
  80861. interface GPUComputePipelineDescriptor
  80862. extends GPUPipelineDescriptorBase {
  80863. computeStage: GPUProgrammableStageDescriptor;
  80864. }
  80865. interface GPUDepthStencilStateDescriptor {
  80866. format: GPUTextureFormat;
  80867. depthWriteEnabled?: boolean;
  80868. depthCompare?: GPUCompareFunction;
  80869. stencilFront?: GPUStencilStateFaceDescriptor;
  80870. stencilBack?: GPUStencilStateFaceDescriptor;
  80871. stencilReadMask?: number;
  80872. stencilWriteMask?: number;
  80873. }
  80874. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80875. extensions?: Iterable<GPUExtensionName>;
  80876. limits?: GPULimits;
  80877. }
  80878. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80879. initialValue?: number;
  80880. label?: string;
  80881. signalQueue?: GPUQueue;
  80882. }
  80883. interface GPUVertexAttributeDescriptor {
  80884. format: GPUVertexFormat;
  80885. offset: number;
  80886. shaderLocation: number;
  80887. }
  80888. interface GPUVertexBufferLayoutDescriptor {
  80889. arrayStride: number;
  80890. stepMode?: GPUInputStepMode;
  80891. attributes: Iterable<GPUVertexAttributeDescriptor>;
  80892. }
  80893. interface GPUVertexStateDescriptor {
  80894. indexFormat?: GPUIndexFormat;
  80895. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  80896. }
  80897. interface GPULimits {
  80898. maxBindGroups?: number;
  80899. maxDynamicUniformBuffersPerPipelineLayout?: number;
  80900. maxDynamicStorageBuffersPerPipelineLayout?: number;
  80901. maxSampledTexturesPerShaderStage?: number;
  80902. maxSamplersPerShaderStage?: number;
  80903. maxStorageBuffersPerShaderStage?: number;
  80904. maxStorageTexturesPerShaderStage?: number;
  80905. maxUniformBuffersPerShaderStage?: number;
  80906. maxUniformBufferBindingSize?: number;
  80907. }
  80908. interface GPUPipelineDescriptorBase {
  80909. label?: string;
  80910. layout?: GPUPipelineLayout;
  80911. }
  80912. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  80913. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  80914. }
  80915. interface GPUProgrammableStageDescriptor {
  80916. module: GPUShaderModule;
  80917. entryPoint: string;
  80918. }
  80919. interface GPURasterizationStateDescriptor {
  80920. frontFace?: GPUFrontFace;
  80921. cullMode?: GPUCullMode;
  80922. clampDepth?: boolean;
  80923. depthBias?: number;
  80924. depthBiasSlopeScale?: number;
  80925. depthBiasClamp?: number;
  80926. }
  80927. interface GPURenderPassColorAttachmentDescriptor {
  80928. attachment: GPUTextureView;
  80929. resolveTarget?: GPUTextureView;
  80930. loadValue: GPULoadOp | GPUColor;
  80931. storeOp?: GPUStoreOp;
  80932. }
  80933. interface GPURenderPassDepthStencilAttachmentDescriptor {
  80934. attachment: GPUTextureView;
  80935. depthLoadValue: GPULoadOp | number;
  80936. depthStoreOp: GPUStoreOp;
  80937. depthReadOnly?: boolean;
  80938. stencilLoadValue: GPULoadOp | number;
  80939. stencilStoreOp: GPUStoreOp;
  80940. stencilReadOnly?: boolean;
  80941. }
  80942. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  80943. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  80944. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  80945. }
  80946. interface GPURenderPipelineDescriptor
  80947. extends GPUPipelineDescriptorBase {
  80948. vertexStage: GPUProgrammableStageDescriptor;
  80949. fragmentStage?: GPUProgrammableStageDescriptor;
  80950. primitiveTopology: GPUPrimitiveTopology;
  80951. rasterizationState?: GPURasterizationStateDescriptor;
  80952. colorStates: Iterable<GPUColorStateDescriptor>;
  80953. depthStencilState?: GPUDepthStencilStateDescriptor;
  80954. vertexState?: GPUVertexStateDescriptor;
  80955. sampleCount?: number;
  80956. sampleMask?: number;
  80957. alphaToCoverageEnabled?: boolean;
  80958. }
  80959. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  80960. addressModeU?: GPUAddressMode;
  80961. addressModeV?: GPUAddressMode;
  80962. addressModeW?: GPUAddressMode;
  80963. magFilter?: GPUFilterMode;
  80964. minFilter?: GPUFilterMode;
  80965. mipmapFilter?: GPUFilterMode;
  80966. lodMinClamp?: number;
  80967. lodMaxClamp?: number;
  80968. compare?: GPUCompareFunction;
  80969. maxAnisotropy?: number;
  80970. }
  80971. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  80972. code: Uint32Array | string;
  80973. label?: string;
  80974. sourceMap?: object;
  80975. }
  80976. interface GPUStencilStateFaceDescriptor {
  80977. compare?: GPUCompareFunction;
  80978. depthFailOp?: GPUStencilOperation;
  80979. passOp?: GPUStencilOperation;
  80980. failOp?: GPUStencilOperation;
  80981. }
  80982. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  80983. device: GPUDevice;
  80984. format: GPUTextureFormat;
  80985. usage?: GPUTextureUsageFlags;
  80986. }
  80987. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  80988. size: GPUExtent3D;
  80989. mipLevelCount?: number;
  80990. sampleCount?: number;
  80991. dimension?: GPUTextureDimension;
  80992. format: GPUTextureFormat;
  80993. usage: GPUTextureUsageFlags;
  80994. }
  80995. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  80996. format?: GPUTextureFormat;
  80997. dimension?: GPUTextureViewDimension;
  80998. aspect?: GPUTextureAspect;
  80999. baseArrayLayer?: number;
  81000. baseMipLevel?: number;
  81001. arrayLayerCount?: number;
  81002. mipLevelCount?: number;
  81003. }
  81004. declare class GPUAdapter {
  81005. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81006. private __brand: void;
  81007. readonly name: string;
  81008. readonly extensions: GPUExtensionName[];
  81009. readonly limits: Required<GPULimits>;
  81010. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81011. }
  81012. declare class GPUBindGroup implements GPUObjectBase {
  81013. private __brand: void;
  81014. label: string | undefined;
  81015. }
  81016. declare class GPUBindGroupLayout implements GPUObjectBase {
  81017. private __brand: void;
  81018. label: string | undefined;
  81019. }
  81020. declare class GPUBuffer implements GPUObjectBase {
  81021. private __brand: void;
  81022. label: string | undefined;
  81023. destroy(): void;
  81024. unmap(): void;
  81025. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81026. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81027. }
  81028. declare class GPUCommandBuffer implements GPUObjectBase {
  81029. private __brand: void;
  81030. label: string | undefined;
  81031. readonly executionTime: Promise<number>;
  81032. }
  81033. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81034. declare class GPUCommandEncoder implements GPUObjectBase {
  81035. private __brand: void;
  81036. label: string | undefined;
  81037. beginComputePass(
  81038. descriptor?: GPUComputePassDescriptor
  81039. ): GPUComputePassEncoder;
  81040. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81041. copyBufferToBuffer(
  81042. source: GPUBuffer,
  81043. sourceOffset: number,
  81044. destination: GPUBuffer,
  81045. destinationOffset: number,
  81046. size: number
  81047. ): void;
  81048. copyBufferToTexture(
  81049. source: GPUBufferCopyView,
  81050. destination: GPUTextureCopyView,
  81051. copySize: GPUExtent3D
  81052. ): void;
  81053. copyTextureToBuffer(
  81054. source: GPUTextureCopyView,
  81055. destination: GPUBufferCopyView,
  81056. copySize: GPUExtent3D
  81057. ): void;
  81058. copyTextureToTexture(
  81059. source: GPUTextureCopyView,
  81060. destination: GPUTextureCopyView,
  81061. copySize: GPUExtent3D
  81062. ): void;
  81063. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81064. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81065. popDebugGroup(): void;
  81066. pushDebugGroup(groupLabel: string): void;
  81067. insertDebugMarker(markerLabel: string): void;
  81068. }
  81069. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81070. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81071. private __brand: void;
  81072. label: string | undefined;
  81073. setBindGroup(
  81074. index: number,
  81075. bindGroup: GPUBindGroup,
  81076. dynamicOffsets?: Iterable<number>
  81077. ): void;
  81078. popDebugGroup(): void;
  81079. pushDebugGroup(groupLabel: string): void;
  81080. insertDebugMarker(markerLabel: string): void;
  81081. setPipeline(pipeline: GPUComputePipeline): void;
  81082. dispatch(x: number, y?: number, z?: number): void;
  81083. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81084. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81085. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81086. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81087. endPass(): void;
  81088. }
  81089. declare class GPUComputePipeline implements GPUPipelineBase {
  81090. private __brand: void;
  81091. label: string | undefined;
  81092. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81093. }
  81094. interface GPUObjectBase {
  81095. label: string | undefined;
  81096. }
  81097. interface GPUObjectDescriptorBase {
  81098. label?: string;
  81099. }
  81100. // SwapChain / CanvasContext
  81101. declare class GPUCanvasContext {
  81102. private __brand: void;
  81103. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81104. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81105. }
  81106. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81107. private __brand: void;
  81108. label: string | undefined;
  81109. readonly adapter: GPUAdapter;
  81110. readonly extensions: GPUExtensionName[];
  81111. readonly limits: Required<GPULimits>;
  81112. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81113. createBindGroupLayout(
  81114. descriptor: GPUBindGroupLayoutDescriptor
  81115. ): GPUBindGroupLayout;
  81116. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81117. createPipelineLayout(
  81118. descriptor: GPUPipelineLayoutDescriptor
  81119. ): GPUPipelineLayout;
  81120. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81121. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81122. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81123. createComputePipeline(
  81124. descriptor: GPUComputePipelineDescriptor
  81125. ): GPUComputePipeline;
  81126. createRenderPipeline(
  81127. descriptor: GPURenderPipelineDescriptor
  81128. ): GPURenderPipeline;
  81129. createReadyComputePipeline(
  81130. descriptor: GPUComputePipelineDescriptor
  81131. ): Promise<GPUComputePipeline>;
  81132. createReadyRenderPipeline(
  81133. descriptor: GPURenderPipelineDescriptor
  81134. ): Promise<GPURenderPipeline>;
  81135. createCommandEncoder(
  81136. descriptor?: GPUCommandEncoderDescriptor
  81137. ): GPUCommandEncoder;
  81138. createRenderBundleEncoder(
  81139. descriptor: GPURenderBundleEncoderDescriptor
  81140. ): GPURenderBundleEncoder;
  81141. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81142. defaultQueue: GPUQueue;
  81143. pushErrorScope(filter: GPUErrorFilter): void;
  81144. popErrorScope(): Promise<GPUError | null>;
  81145. onuncapturederror: Event | undefined;
  81146. readonly lost: Promise<GPUDeviceLostInfo>;
  81147. }
  81148. declare class GPUFence implements GPUObjectBase {
  81149. private __brand: void;
  81150. label: string | undefined;
  81151. getCompletedValue(): number;
  81152. onCompletion(completionValue: number): Promise<void>;
  81153. }
  81154. interface GPUPipelineBase extends GPUObjectBase {
  81155. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81156. }
  81157. declare class GPUPipelineLayout implements GPUObjectBase {
  81158. private __brand: void;
  81159. label: string | undefined;
  81160. }
  81161. interface GPUProgrammablePassEncoder {
  81162. setBindGroup(
  81163. index: number,
  81164. bindGroup: GPUBindGroup,
  81165. dynamicOffsets?: Iterable<number>
  81166. ): void;
  81167. popDebugGroup(): void;
  81168. pushDebugGroup(groupLabel: string): void;
  81169. insertDebugMarker(markerLabel: string): void;
  81170. }
  81171. declare class GPUQueue implements GPUObjectBase {
  81172. private __brand: void;
  81173. label: string | undefined;
  81174. signal(fence: GPUFence, signalValue: number): void;
  81175. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81176. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81177. writeBuffer(buffer: GPUBuffer,
  81178. bufferOffset: number,
  81179. data: BufferSource | ArrayBuffer,
  81180. dataOffset?: number,
  81181. size?: number): void;
  81182. writeTexture(destination: GPUTextureCopyView,
  81183. data: BufferSource | ArrayBuffer,
  81184. dataLayout: GPUTextureDataLayout,
  81185. size: GPUExtent3D): void;
  81186. copyImageBitmapToTexture(
  81187. source: GPUImageBitmapCopyView,
  81188. destination: GPUTextureCopyView,
  81189. copySize: GPUExtent3D
  81190. ): void;
  81191. }
  81192. type GPUQueryType =
  81193. | "occlusion"
  81194. | "timestamp"
  81195. | "pipeline-statistics";
  81196. type GPUPipelineStatisticName =
  81197. | "vertex-shader-invocations"
  81198. | "clipper-invocations"
  81199. | "clipper-primitives-out"
  81200. | "fragment-shader-invocations"
  81201. | "compute-shader-invocations";
  81202. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81203. type: GPUQueryType;
  81204. count: number;
  81205. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81206. }
  81207. declare class GPUQuerySet implements GPUObjectBase {
  81208. private __brand: void;
  81209. label: string | undefined;
  81210. destroy(): void;
  81211. }
  81212. interface GPURenderEncoderBase {
  81213. setPipeline(pipeline: GPURenderPipeline): void;
  81214. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81215. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81216. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81217. draw(
  81218. vertexCount: number,
  81219. instanceCount?: number,
  81220. firstVertex?: number,
  81221. firstInstance?: number
  81222. ): void;
  81223. drawIndexed(
  81224. indexCount: number,
  81225. instanceCount?: number,
  81226. firstIndex?: number,
  81227. baseVertex?: number,
  81228. firstInstance?: number
  81229. ): void;
  81230. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81231. drawIndexedIndirect(
  81232. indirectBuffer: GPUBuffer,
  81233. indirectOffset: number
  81234. ): void;
  81235. }
  81236. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81237. private __brand: void;
  81238. label: string | undefined;
  81239. setBindGroup(
  81240. index: number,
  81241. bindGroup: GPUBindGroup,
  81242. dynamicOffsets?: Iterable<number>
  81243. ): void;
  81244. popDebugGroup(): void;
  81245. pushDebugGroup(groupLabel: string): void;
  81246. insertDebugMarker(markerLabel: string): void;
  81247. setPipeline(pipeline: GPURenderPipeline): void;
  81248. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81249. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81250. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81251. draw(
  81252. vertexCount: number,
  81253. instanceCount?: number,
  81254. firstVertex?: number,
  81255. firstInstance?: number
  81256. ): void;
  81257. drawIndexed(
  81258. indexCount: number,
  81259. instanceCount?: number,
  81260. firstIndex?: number,
  81261. baseVertex?: number,
  81262. firstInstance?: number
  81263. ): void;
  81264. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81265. drawIndexedIndirect(
  81266. indirectBuffer: GPUBuffer,
  81267. indirectOffset: number
  81268. ): void;
  81269. setViewport(
  81270. x: number,
  81271. y: number,
  81272. width: number,
  81273. height: number,
  81274. minDepth: number,
  81275. maxDepth: number
  81276. ): void;
  81277. setScissorRect(x: number, y: number, width: number, height: number): void;
  81278. setBlendColor(color: GPUColor): void;
  81279. setStencilReference(reference: number): void;
  81280. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81281. beginOcclusionQuery(queryIndex: number): void;
  81282. endOcclusionQuery(): void;
  81283. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81284. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81285. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81286. endPass(): void;
  81287. }
  81288. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81289. declare class GPURenderBundle implements GPUObjectBase {
  81290. private __brand: void;
  81291. label: string | undefined;
  81292. }
  81293. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81294. private __brand: void;
  81295. label: string | undefined;
  81296. setBindGroup(
  81297. index: number,
  81298. bindGroup: GPUBindGroup,
  81299. dynamicOffsets?: Iterable<number>
  81300. ): void;
  81301. popDebugGroup(): void;
  81302. pushDebugGroup(groupLabel: string): void;
  81303. insertDebugMarker(markerLabel: string): void;
  81304. setPipeline(pipeline: GPURenderPipeline): void;
  81305. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81306. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81307. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81308. draw(
  81309. vertexCount: number,
  81310. instanceCount?: number,
  81311. firstVertex?: number,
  81312. firstInstance?: number
  81313. ): void;
  81314. drawIndexed(
  81315. indexCount: number,
  81316. instanceCount?: number,
  81317. firstIndex?: number,
  81318. baseVertex?: number,
  81319. firstInstance?: number
  81320. ): void;
  81321. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81322. drawIndexedIndirect(
  81323. indirectBuffer: GPUBuffer,
  81324. indirectOffset: number
  81325. ): void;
  81326. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81327. }
  81328. interface GPURenderBundleEncoderDescriptor
  81329. extends GPUObjectDescriptorBase {
  81330. colorFormats: Iterable<GPUTextureFormat>;
  81331. depthStencilFormat?: GPUTextureFormat;
  81332. sampleCount?: number;
  81333. }
  81334. declare class GPURenderPipeline implements GPUPipelineBase {
  81335. private __brand: void;
  81336. label: string | undefined;
  81337. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81338. }
  81339. declare class GPUSampler implements GPUObjectBase {
  81340. private __brand: void;
  81341. label: string | undefined;
  81342. }
  81343. type GPUCompilationMessageType =
  81344. | "error"
  81345. | "warning"
  81346. | "info";
  81347. interface GPUCompilationMessage {
  81348. readonly message: string;
  81349. readonly type: GPUCompilationMessageType;
  81350. readonly lineNum: number;
  81351. readonly linePos: number;
  81352. }
  81353. interface GPUCompilationInfo {
  81354. readonly messages: readonly GPUCompilationMessage[];
  81355. }
  81356. declare class GPUShaderModule implements GPUObjectBase {
  81357. private __brand: void;
  81358. label: string | undefined;
  81359. compilationInfo(): Promise<GPUCompilationInfo>;
  81360. }
  81361. declare class GPUSwapChain implements GPUObjectBase {
  81362. private __brand: void;
  81363. label: string | undefined;
  81364. getCurrentTexture(): GPUTexture;
  81365. }
  81366. declare class GPUTexture implements GPUObjectBase {
  81367. private __brand: void;
  81368. label: string | undefined;
  81369. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81370. destroy(): void;
  81371. }
  81372. declare class GPUTextureView implements GPUObjectBase {
  81373. private __brand: void;
  81374. label: string | undefined;
  81375. }
  81376. type GPUPowerPreference = "low-power" | "high-performance";
  81377. interface GPURequestAdapterOptions {
  81378. powerPreference?: GPUPowerPreference;
  81379. }
  81380. declare class GPU {
  81381. private __brand: void;
  81382. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81383. }
  81384. // ****************************************************************************
  81385. // ERROR SCOPES
  81386. // ****************************************************************************
  81387. type GPUErrorFilter = "out-of-memory" | "validation";
  81388. declare class GPUOutOfMemoryError {
  81389. private __brand: void;
  81390. constructor();
  81391. }
  81392. declare class GPUValidationError {
  81393. private __brand: void;
  81394. constructor(message: string);
  81395. readonly message: string;
  81396. }
  81397. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81398. // ****************************************************************************
  81399. // TELEMETRY
  81400. // ****************************************************************************
  81401. declare class GPUUncapturedErrorEvent extends Event {
  81402. private __brand: void;
  81403. constructor(
  81404. type: string,
  81405. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81406. );
  81407. readonly error: GPUError;
  81408. }
  81409. interface GPUUncapturedErrorEventInit extends EventInit {
  81410. error: GPUError;
  81411. }
  81412. declare class GPUDeviceLostInfo {
  81413. private __brand: void;
  81414. readonly message: string;
  81415. }
  81416. // Type definitions for WebVR API
  81417. // Project: https://w3c.github.io/webvr/
  81418. // Definitions by: six a <https://github.com/lostfictions>
  81419. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81420. interface VRDisplay extends EventTarget {
  81421. /**
  81422. * Dictionary of capabilities describing the VRDisplay.
  81423. */
  81424. readonly capabilities: VRDisplayCapabilities;
  81425. /**
  81426. * z-depth defining the far plane of the eye view frustum
  81427. * enables mapping of values in the render target depth
  81428. * attachment to scene coordinates. Initially set to 10000.0.
  81429. */
  81430. depthFar: number;
  81431. /**
  81432. * z-depth defining the near plane of the eye view frustum
  81433. * enables mapping of values in the render target depth
  81434. * attachment to scene coordinates. Initially set to 0.01.
  81435. */
  81436. depthNear: number;
  81437. /**
  81438. * An identifier for this distinct VRDisplay. Used as an
  81439. * association point in the Gamepad API.
  81440. */
  81441. readonly displayId: number;
  81442. /**
  81443. * A display name, a user-readable name identifying it.
  81444. */
  81445. readonly displayName: string;
  81446. readonly isConnected: boolean;
  81447. readonly isPresenting: boolean;
  81448. /**
  81449. * If this VRDisplay supports room-scale experiences, the optional
  81450. * stage attribute contains details on the room-scale parameters.
  81451. */
  81452. readonly stageParameters: VRStageParameters | null;
  81453. /**
  81454. * Passing the value returned by `requestAnimationFrame` to
  81455. * `cancelAnimationFrame` will unregister the callback.
  81456. * @param handle Define the hanle of the request to cancel
  81457. */
  81458. cancelAnimationFrame(handle: number): void;
  81459. /**
  81460. * Stops presenting to the VRDisplay.
  81461. * @returns a promise to know when it stopped
  81462. */
  81463. exitPresent(): Promise<void>;
  81464. /**
  81465. * Return the current VREyeParameters for the given eye.
  81466. * @param whichEye Define the eye we want the parameter for
  81467. * @returns the eye parameters
  81468. */
  81469. getEyeParameters(whichEye: string): VREyeParameters;
  81470. /**
  81471. * Populates the passed VRFrameData with the information required to render
  81472. * the current frame.
  81473. * @param frameData Define the data structure to populate
  81474. * @returns true if ok otherwise false
  81475. */
  81476. getFrameData(frameData: VRFrameData): boolean;
  81477. /**
  81478. * Get the layers currently being presented.
  81479. * @returns the list of VR layers
  81480. */
  81481. getLayers(): VRLayer[];
  81482. /**
  81483. * Return a VRPose containing the future predicted pose of the VRDisplay
  81484. * when the current frame will be presented. The value returned will not
  81485. * change until JavaScript has returned control to the browser.
  81486. *
  81487. * The VRPose will contain the position, orientation, velocity,
  81488. * and acceleration of each of these properties.
  81489. * @returns the pose object
  81490. */
  81491. getPose(): VRPose;
  81492. /**
  81493. * Return the current instantaneous pose of the VRDisplay, with no
  81494. * prediction applied.
  81495. * @returns the current instantaneous pose
  81496. */
  81497. getImmediatePose(): VRPose;
  81498. /**
  81499. * The callback passed to `requestAnimationFrame` will be called
  81500. * any time a new frame should be rendered. When the VRDisplay is
  81501. * presenting the callback will be called at the native refresh
  81502. * rate of the HMD. When not presenting this function acts
  81503. * identically to how window.requestAnimationFrame acts. Content should
  81504. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81505. * asynchronously from other displays and at differing refresh rates.
  81506. * @param callback Define the eaction to run next frame
  81507. * @returns the request handle it
  81508. */
  81509. requestAnimationFrame(callback: FrameRequestCallback): number;
  81510. /**
  81511. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81512. * Repeat calls while already presenting will update the VRLayers being displayed.
  81513. * @param layers Define the list of layer to present
  81514. * @returns a promise to know when the request has been fulfilled
  81515. */
  81516. requestPresent(layers: VRLayer[]): Promise<void>;
  81517. /**
  81518. * Reset the pose for this display, treating its current position and
  81519. * orientation as the "origin/zero" values. VRPose.position,
  81520. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81521. * updated when calling resetPose(). This should be called in only
  81522. * sitting-space experiences.
  81523. */
  81524. resetPose(): void;
  81525. /**
  81526. * The VRLayer provided to the VRDisplay will be captured and presented
  81527. * in the HMD. Calling this function has the same effect on the source
  81528. * canvas as any other operation that uses its source image, and canvases
  81529. * created without preserveDrawingBuffer set to true will be cleared.
  81530. * @param pose Define the pose to submit
  81531. */
  81532. submitFrame(pose?: VRPose): void;
  81533. }
  81534. declare var VRDisplay: {
  81535. prototype: VRDisplay;
  81536. new(): VRDisplay;
  81537. };
  81538. interface VRLayer {
  81539. leftBounds?: number[] | Float32Array | null;
  81540. rightBounds?: number[] | Float32Array | null;
  81541. source?: HTMLCanvasElement | null;
  81542. }
  81543. interface VRDisplayCapabilities {
  81544. readonly canPresent: boolean;
  81545. readonly hasExternalDisplay: boolean;
  81546. readonly hasOrientation: boolean;
  81547. readonly hasPosition: boolean;
  81548. readonly maxLayers: number;
  81549. }
  81550. interface VREyeParameters {
  81551. /** @deprecated */
  81552. readonly fieldOfView: VRFieldOfView;
  81553. readonly offset: Float32Array;
  81554. readonly renderHeight: number;
  81555. readonly renderWidth: number;
  81556. }
  81557. interface VRFieldOfView {
  81558. readonly downDegrees: number;
  81559. readonly leftDegrees: number;
  81560. readonly rightDegrees: number;
  81561. readonly upDegrees: number;
  81562. }
  81563. interface VRFrameData {
  81564. readonly leftProjectionMatrix: Float32Array;
  81565. readonly leftViewMatrix: Float32Array;
  81566. readonly pose: VRPose;
  81567. readonly rightProjectionMatrix: Float32Array;
  81568. readonly rightViewMatrix: Float32Array;
  81569. readonly timestamp: number;
  81570. }
  81571. interface VRPose {
  81572. readonly angularAcceleration: Float32Array | null;
  81573. readonly angularVelocity: Float32Array | null;
  81574. readonly linearAcceleration: Float32Array | null;
  81575. readonly linearVelocity: Float32Array | null;
  81576. readonly orientation: Float32Array | null;
  81577. readonly position: Float32Array | null;
  81578. readonly timestamp: number;
  81579. }
  81580. interface VRStageParameters {
  81581. sittingToStandingTransform?: Float32Array;
  81582. sizeX?: number;
  81583. sizeY?: number;
  81584. }
  81585. interface Navigator {
  81586. getVRDisplays(): Promise<VRDisplay[]>;
  81587. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81588. }
  81589. interface Window {
  81590. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81591. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81592. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81593. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81594. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81595. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81596. }
  81597. interface Gamepad {
  81598. readonly displayId: number;
  81599. }
  81600. /**
  81601. * Available session modes
  81602. */
  81603. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81604. /**
  81605. * Reference space types
  81606. */
  81607. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81608. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81609. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81610. /**
  81611. * Handedness types
  81612. */
  81613. type XRHandedness = "none" | "left" | "right";
  81614. /**
  81615. * InputSource target ray modes
  81616. */
  81617. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81618. /**
  81619. * Eye types
  81620. */
  81621. type XREye = "none" | "left" | "right";
  81622. /**
  81623. * Type of XR events available
  81624. */
  81625. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81626. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81627. type XRPlaneSet = Set<XRPlane>;
  81628. type XRAnchorSet = Set<XRAnchor>;
  81629. type XREventHandler = (callback: any) => void;
  81630. interface XRLayer extends EventTarget {}
  81631. interface XRSessionInit {
  81632. optionalFeatures?: string[];
  81633. requiredFeatures?: string[];
  81634. trackedImages?: XRTrackedImageInit[];
  81635. }
  81636. interface XRSessionEvent extends Event {
  81637. readonly session: XRSession;
  81638. }
  81639. interface XRSystem {
  81640. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81641. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81642. }
  81643. interface XRViewport {
  81644. readonly x: number;
  81645. readonly y: number;
  81646. readonly width: number;
  81647. readonly height: number;
  81648. }
  81649. interface XRWebGLLayerInit {
  81650. antialias?: boolean;
  81651. depth?: boolean;
  81652. stencil?: boolean;
  81653. alpha?: boolean;
  81654. multiview?: boolean;
  81655. framebufferScaleFactor?: number;
  81656. }
  81657. declare class XRWebGLLayer {
  81658. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81659. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81660. readonly antialias: boolean;
  81661. readonly framebuffer: WebGLFramebuffer;
  81662. readonly framebufferWidth: number;
  81663. readonly framebufferHeight: number;
  81664. readonly ignoreDepthValues: boolean;
  81665. getViewport: (view: XRView) => XRViewport;
  81666. }
  81667. // tslint:disable-next-line no-empty-interface
  81668. interface XRSpace extends EventTarget {}
  81669. interface XRRenderState {
  81670. readonly baseLayer?: XRWebGLLayer;
  81671. readonly depthFar: number;
  81672. readonly depthNear: number;
  81673. readonly inlineVerticalFieldOfView?: number;
  81674. }
  81675. interface XRRenderStateInit extends XRRenderState {
  81676. baseLayer: XRWebGLLayer;
  81677. depthFar: number;
  81678. depthNear: number;
  81679. inlineVerticalFieldOfView?: number;
  81680. layers?: XRLayer[];
  81681. }
  81682. interface XRReferenceSpace extends XRSpace {
  81683. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81684. onreset: XREventHandler;
  81685. }
  81686. interface XRBoundedReferenceSpace extends XRSpace {
  81687. readonly boundsGeometry: DOMPointReadOnly[];
  81688. }
  81689. interface XRInputSource {
  81690. readonly handedness: XRHandedness;
  81691. readonly targetRayMode: XRTargetRayMode;
  81692. readonly targetRaySpace: XRSpace;
  81693. readonly gripSpace?: XRSpace;
  81694. readonly gamepad?: Gamepad;
  81695. readonly profiles: Array<string>;
  81696. readonly hand?: XRHand;
  81697. }
  81698. interface XRPose {
  81699. readonly transform: XRRigidTransform;
  81700. readonly emulatedPosition: boolean;
  81701. }
  81702. interface XRWorldInformation {
  81703. detectedPlanes?: XRPlaneSet;
  81704. }
  81705. interface XRFrame {
  81706. readonly session: XRSession;
  81707. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81708. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81709. // AR
  81710. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81711. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81712. // Anchors
  81713. trackedAnchors?: XRAnchorSet;
  81714. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81715. // World geometries
  81716. worldInformation?: XRWorldInformation;
  81717. // Hand tracking
  81718. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81719. // Image tracking
  81720. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  81721. }
  81722. interface XRInputSourceEvent extends Event {
  81723. readonly frame: XRFrame;
  81724. readonly inputSource: XRInputSource;
  81725. }
  81726. type XRInputSourceArray = XRInputSource[];
  81727. interface XRSession {
  81728. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81729. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81730. /**
  81731. * Returns a list of this session's XRInputSources, each representing an input device
  81732. * used to control the camera and/or scene.
  81733. */
  81734. readonly inputSources: Array<XRInputSource>;
  81735. /**
  81736. * object which contains options affecting how the imagery is rendered.
  81737. * This includes things such as the near and far clipping planes
  81738. */
  81739. readonly renderState: XRRenderState;
  81740. readonly visibilityState: XRVisibilityState;
  81741. /**
  81742. * Removes a callback from the animation frame painting callback from
  81743. * XRSession's set of animation frame rendering callbacks, given the
  81744. * identifying handle returned by a previous call to requestAnimationFrame().
  81745. */
  81746. cancelAnimationFrame: (handle: number) => void;
  81747. /**
  81748. * Ends the WebXR session. Returns a promise which resolves when the
  81749. * session has been shut down.
  81750. */
  81751. end(): Promise<void>;
  81752. /**
  81753. * Schedules the specified method to be called the next time the user agent
  81754. * is working on rendering an animation frame for the WebXR device. Returns an
  81755. * integer value which can be used to identify the request for the purposes of
  81756. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81757. * to the Window.requestAnimationFrame() method.
  81758. */
  81759. requestAnimationFrame: XRFrameRequestCallback;
  81760. /**
  81761. * Requests that a new XRReferenceSpace of the specified type be created.
  81762. * Returns a promise which resolves with the XRReferenceSpace or
  81763. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81764. * the requested space type isn't supported by the device.
  81765. */
  81766. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81767. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81768. onend: XREventHandler;
  81769. oninputsourceschange: XREventHandler;
  81770. onselect: XREventHandler;
  81771. onselectstart: XREventHandler;
  81772. onselectend: XREventHandler;
  81773. onsqueeze: XREventHandler;
  81774. onsqueezestart: XREventHandler;
  81775. onsqueezeend: XREventHandler;
  81776. onvisibilitychange: XREventHandler;
  81777. // hit test
  81778. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81779. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81780. // legacy AR hit test
  81781. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81782. // legacy plane detection
  81783. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81784. // image tracking
  81785. getTrackedImageScores?(): XRImageTrackingScore[];
  81786. }
  81787. interface XRViewerPose extends XRPose {
  81788. readonly views: Array<XRView>;
  81789. }
  81790. declare class XRRigidTransform {
  81791. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81792. position: DOMPointReadOnly;
  81793. orientation: DOMPointReadOnly;
  81794. matrix: Float32Array;
  81795. inverse: XRRigidTransform;
  81796. }
  81797. interface XRView {
  81798. readonly eye: XREye;
  81799. readonly projectionMatrix: Float32Array;
  81800. readonly transform: XRRigidTransform;
  81801. readonly recommendedViewportScale?: number;
  81802. requestViewportScale(scale: number): void;
  81803. }
  81804. interface XRInputSourceChangeEvent extends Event {
  81805. session: XRSession;
  81806. removed: Array<XRInputSource>;
  81807. added: Array<XRInputSource>;
  81808. }
  81809. // Experimental/Draft features
  81810. declare class XRRay {
  81811. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81812. origin: DOMPointReadOnly;
  81813. direction: DOMPointReadOnly;
  81814. matrix: Float32Array;
  81815. }
  81816. declare enum XRHitTestTrackableType {
  81817. "point",
  81818. "plane",
  81819. "mesh",
  81820. }
  81821. interface XRHitResult {
  81822. hitMatrix: Float32Array;
  81823. }
  81824. interface XRTransientInputHitTestResult {
  81825. readonly inputSource: XRInputSource;
  81826. readonly results: Array<XRHitTestResult>;
  81827. }
  81828. interface XRHitTestResult {
  81829. getPose(baseSpace: XRSpace): XRPose | undefined;
  81830. // When anchor system is enabled
  81831. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81832. }
  81833. interface XRHitTestSource {
  81834. cancel(): void;
  81835. }
  81836. interface XRTransientInputHitTestSource {
  81837. cancel(): void;
  81838. }
  81839. interface XRHitTestOptionsInit {
  81840. space: XRSpace;
  81841. entityTypes?: Array<XRHitTestTrackableType>;
  81842. offsetRay?: XRRay;
  81843. }
  81844. interface XRTransientInputHitTestOptionsInit {
  81845. profile: string;
  81846. entityTypes?: Array<XRHitTestTrackableType>;
  81847. offsetRay?: XRRay;
  81848. }
  81849. interface XRAnchor {
  81850. anchorSpace: XRSpace;
  81851. delete(): void;
  81852. }
  81853. interface XRPlane {
  81854. orientation: "Horizontal" | "Vertical";
  81855. planeSpace: XRSpace;
  81856. polygon: Array<DOMPointReadOnly>;
  81857. lastChangedTime: number;
  81858. }
  81859. interface XRJointSpace extends XRSpace {}
  81860. interface XRJointPose extends XRPose {
  81861. radius: number | undefined;
  81862. }
  81863. interface XRHand extends Iterable<XRJointSpace> {
  81864. readonly length: number;
  81865. [index: number]: XRJointSpace;
  81866. readonly WRIST: number;
  81867. readonly THUMB_METACARPAL: number;
  81868. readonly THUMB_PHALANX_PROXIMAL: number;
  81869. readonly THUMB_PHALANX_DISTAL: number;
  81870. readonly THUMB_PHALANX_TIP: number;
  81871. readonly INDEX_METACARPAL: number;
  81872. readonly INDEX_PHALANX_PROXIMAL: number;
  81873. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81874. readonly INDEX_PHALANX_DISTAL: number;
  81875. readonly INDEX_PHALANX_TIP: number;
  81876. readonly MIDDLE_METACARPAL: number;
  81877. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81878. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81879. readonly MIDDLE_PHALANX_DISTAL: number;
  81880. readonly MIDDLE_PHALANX_TIP: number;
  81881. readonly RING_METACARPAL: number;
  81882. readonly RING_PHALANX_PROXIMAL: number;
  81883. readonly RING_PHALANX_INTERMEDIATE: number;
  81884. readonly RING_PHALANX_DISTAL: number;
  81885. readonly RING_PHALANX_TIP: number;
  81886. readonly LITTLE_METACARPAL: number;
  81887. readonly LITTLE_PHALANX_PROXIMAL: number;
  81888. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81889. readonly LITTLE_PHALANX_DISTAL: number;
  81890. readonly LITTLE_PHALANX_TIP: number;
  81891. }
  81892. type XRImageTrackingState = "tracked" | "emulated";
  81893. type XRImageTrackingScore = "untrackable" | "trackable";
  81894. interface XRTrackedImageInit {
  81895. image: ImageBitmap;
  81896. widthInMeters: number;
  81897. }
  81898. interface XRImageTrackingResult {
  81899. readonly imageSpace: XRSpace;
  81900. readonly index: number;
  81901. readonly trackingState: XRImageTrackingState;
  81902. readonly measuredWidthInMeters: number;
  81903. }
  81904. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  81905. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  81906. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  81907. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  81908. interface XRSceneObject {
  81909. type: XRSceneObjectType;
  81910. }
  81911. interface XRFieldOfView {
  81912. angleLeft: number;
  81913. angleRight: number;
  81914. angleUp: number;
  81915. angleDown: number;
  81916. }
  81917. interface XRFrustum {
  81918. position: DOMPointReadOnly;
  81919. orientation: DOMPointReadOnly;
  81920. fieldOfView: XRFieldOfView;
  81921. farDistance: number;
  81922. }
  81923. interface XRPlane {
  81924. parentSceneObject?: XRSceneObject;
  81925. }
  81926. interface XRMesh {
  81927. meshSpace: XRSpace;
  81928. positions: Float32Array;
  81929. indices: Uint32Array;
  81930. normals?: Float32Array;
  81931. lastChangedTime: number;
  81932. parentSceneObject?: XRSceneObject;
  81933. }
  81934. interface XRFrustumDetectionBoundary {
  81935. type: "frustum";
  81936. frustum: XRFrustum;
  81937. }
  81938. interface XRSphereDetectionBoundary {
  81939. type: "sphere";
  81940. radius: number;
  81941. }
  81942. interface XRBoxDetectionBoundary {
  81943. type: "box";
  81944. extent: DOMPointReadOnly;
  81945. }
  81946. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  81947. interface XRGeometryDetectorOptions {
  81948. detectionBoundary?: XRDetectionBoundary;
  81949. updateInterval?: number;
  81950. }
  81951. interface XRSession {
  81952. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  81953. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81954. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  81955. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81956. }
  81957. interface XRFrame {
  81958. featurePointCloud?: Array<number>;
  81959. }
  81960. type XRMeshSet = Set<XRMesh>;
  81961. interface XRWorldInformation {
  81962. detectedMeshes?: XRMeshSet;
  81963. }
  81964. /**
  81965. * @ignore
  81966. */
  81967. declare module BABYLON.GLTF2.Exporter {
  81968. }
  81969. /**
  81970. * @ignore
  81971. */
  81972. declare module BABYLON.GLTF1 {
  81973. }
  81974. declare module BABYLON.GUI {
  81975. /**
  81976. * Interface used to define a control that can receive focus
  81977. */
  81978. export interface IFocusableControl {
  81979. /**
  81980. * Function called when the control receives the focus
  81981. */
  81982. onFocus(): void;
  81983. /**
  81984. * Function called when the control loses the focus
  81985. */
  81986. onBlur(): void;
  81987. /**
  81988. * Function called to let the control handle keyboard events
  81989. * @param evt defines the current keyboard event
  81990. */
  81991. processKeyboard(evt: KeyboardEvent): void;
  81992. /**
  81993. * Function called to get the list of controls that should not steal the focus from this control
  81994. * @returns an array of controls
  81995. */
  81996. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  81997. /**
  81998. * Function to focus the control programmatically
  81999. */
  82000. focus(): void;
  82001. /**
  82002. * Function to unfocus the control programmatically
  82003. */
  82004. blur(): void;
  82005. }
  82006. }
  82007. declare module BABYLON.GUI {
  82008. /**
  82009. * Class used to specific a value and its associated unit
  82010. */
  82011. export class ValueAndUnit {
  82012. /** defines the unit to store */
  82013. unit: number;
  82014. /** defines a boolean indicating if the value can be negative */
  82015. negativeValueAllowed: boolean;
  82016. private _value;
  82017. private _originalUnit;
  82018. /**
  82019. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82020. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82021. */
  82022. ignoreAdaptiveScaling: boolean;
  82023. /**
  82024. * Creates a new ValueAndUnit
  82025. * @param value defines the value to store
  82026. * @param unit defines the unit to store
  82027. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82028. */
  82029. constructor(value: number,
  82030. /** defines the unit to store */
  82031. unit?: number,
  82032. /** defines a boolean indicating if the value can be negative */
  82033. negativeValueAllowed?: boolean);
  82034. /** Gets a boolean indicating if the value is a percentage */
  82035. get isPercentage(): boolean;
  82036. /** Gets a boolean indicating if the value is store as pixel */
  82037. get isPixel(): boolean;
  82038. /** Gets direct internal value */
  82039. get internalValue(): number;
  82040. /**
  82041. * Gets value as pixel
  82042. * @param host defines the root host
  82043. * @param refValue defines the reference value for percentages
  82044. * @returns the value as pixel
  82045. */
  82046. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82047. /**
  82048. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82049. * @param value defines the value to store
  82050. * @param unit defines the unit to store
  82051. * @returns the current ValueAndUnit
  82052. */
  82053. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82054. /**
  82055. * Gets the value accordingly to its unit
  82056. * @param host defines the root host
  82057. * @returns the value
  82058. */
  82059. getValue(host: AdvancedDynamicTexture): number;
  82060. /**
  82061. * Gets a string representation of the value
  82062. * @param host defines the root host
  82063. * @param decimals defines an optional number of decimals to display
  82064. * @returns a string
  82065. */
  82066. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82067. /**
  82068. * Store a value parsed from a string
  82069. * @param source defines the source string
  82070. * @returns true if the value was successfully parsed
  82071. */
  82072. fromString(source: string | number): boolean;
  82073. private static _Regex;
  82074. private static _UNITMODE_PERCENTAGE;
  82075. private static _UNITMODE_PIXEL;
  82076. /** UNITMODE_PERCENTAGE */
  82077. static get UNITMODE_PERCENTAGE(): number;
  82078. /** UNITMODE_PIXEL */
  82079. static get UNITMODE_PIXEL(): number;
  82080. }
  82081. }
  82082. declare module BABYLON.GUI {
  82083. /**
  82084. * Define a style used by control to automatically setup properties based on a template.
  82085. * Only support font related properties so far
  82086. */
  82087. export class Style implements BABYLON.IDisposable {
  82088. private _fontFamily;
  82089. private _fontStyle;
  82090. private _fontWeight;
  82091. /** @hidden */
  82092. _host: AdvancedDynamicTexture;
  82093. /** @hidden */
  82094. _fontSize: ValueAndUnit;
  82095. /**
  82096. * BABYLON.Observable raised when the style values are changed
  82097. */
  82098. onChangedObservable: BABYLON.Observable<Style>;
  82099. /**
  82100. * Creates a new style object
  82101. * @param host defines the AdvancedDynamicTexture which hosts this style
  82102. */
  82103. constructor(host: AdvancedDynamicTexture);
  82104. /**
  82105. * Gets or sets the font size
  82106. */
  82107. get fontSize(): string | number;
  82108. set fontSize(value: string | number);
  82109. /**
  82110. * Gets or sets the font family
  82111. */
  82112. get fontFamily(): string;
  82113. set fontFamily(value: string);
  82114. /**
  82115. * Gets or sets the font style
  82116. */
  82117. get fontStyle(): string;
  82118. set fontStyle(value: string);
  82119. /** Gets or sets font weight */
  82120. get fontWeight(): string;
  82121. set fontWeight(value: string);
  82122. /** Dispose all associated resources */
  82123. dispose(): void;
  82124. }
  82125. }
  82126. declare module BABYLON.GUI {
  82127. /**
  82128. * Class used to transport BABYLON.Vector2 information for pointer events
  82129. */
  82130. export class Vector2WithInfo extends BABYLON.Vector2 {
  82131. /** defines the current mouse button index */
  82132. buttonIndex: number;
  82133. /**
  82134. * Creates a new Vector2WithInfo
  82135. * @param source defines the vector2 data to transport
  82136. * @param buttonIndex defines the current mouse button index
  82137. */
  82138. constructor(source: BABYLON.Vector2,
  82139. /** defines the current mouse button index */
  82140. buttonIndex?: number);
  82141. }
  82142. /** Class used to provide 2D matrix features */
  82143. export class Matrix2D {
  82144. /** Gets the internal array of 6 floats used to store matrix data */
  82145. m: Float32Array;
  82146. /**
  82147. * Creates a new matrix
  82148. * @param m00 defines value for (0, 0)
  82149. * @param m01 defines value for (0, 1)
  82150. * @param m10 defines value for (1, 0)
  82151. * @param m11 defines value for (1, 1)
  82152. * @param m20 defines value for (2, 0)
  82153. * @param m21 defines value for (2, 1)
  82154. */
  82155. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82156. /**
  82157. * Fills the matrix from direct values
  82158. * @param m00 defines value for (0, 0)
  82159. * @param m01 defines value for (0, 1)
  82160. * @param m10 defines value for (1, 0)
  82161. * @param m11 defines value for (1, 1)
  82162. * @param m20 defines value for (2, 0)
  82163. * @param m21 defines value for (2, 1)
  82164. * @returns the current modified matrix
  82165. */
  82166. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82167. /**
  82168. * Gets matrix determinant
  82169. * @returns the determinant
  82170. */
  82171. determinant(): number;
  82172. /**
  82173. * Inverses the matrix and stores it in a target matrix
  82174. * @param result defines the target matrix
  82175. * @returns the current matrix
  82176. */
  82177. invertToRef(result: Matrix2D): Matrix2D;
  82178. /**
  82179. * Multiplies the current matrix with another one
  82180. * @param other defines the second operand
  82181. * @param result defines the target matrix
  82182. * @returns the current matrix
  82183. */
  82184. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82185. /**
  82186. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82187. * @param x defines the x coordinate to transform
  82188. * @param y defines the x coordinate to transform
  82189. * @param result defines the target vector2
  82190. * @returns the current matrix
  82191. */
  82192. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82193. /**
  82194. * Creates an identity matrix
  82195. * @returns a new matrix
  82196. */
  82197. static Identity(): Matrix2D;
  82198. /**
  82199. * Creates a translation matrix and stores it in a target matrix
  82200. * @param x defines the x coordinate of the translation
  82201. * @param y defines the y coordinate of the translation
  82202. * @param result defines the target matrix
  82203. */
  82204. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82205. /**
  82206. * Creates a scaling matrix and stores it in a target matrix
  82207. * @param x defines the x coordinate of the scaling
  82208. * @param y defines the y coordinate of the scaling
  82209. * @param result defines the target matrix
  82210. */
  82211. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82212. /**
  82213. * Creates a rotation matrix and stores it in a target matrix
  82214. * @param angle defines the rotation angle
  82215. * @param result defines the target matrix
  82216. */
  82217. static RotationToRef(angle: number, result: Matrix2D): void;
  82218. private static _TempPreTranslationMatrix;
  82219. private static _TempPostTranslationMatrix;
  82220. private static _TempRotationMatrix;
  82221. private static _TempScalingMatrix;
  82222. private static _TempCompose0;
  82223. private static _TempCompose1;
  82224. private static _TempCompose2;
  82225. /**
  82226. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82227. * @param tx defines the x coordinate of the translation
  82228. * @param ty defines the y coordinate of the translation
  82229. * @param angle defines the rotation angle
  82230. * @param scaleX defines the x coordinate of the scaling
  82231. * @param scaleY defines the y coordinate of the scaling
  82232. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82233. * @param result defines the target matrix
  82234. */
  82235. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82236. }
  82237. }
  82238. declare module BABYLON.GUI {
  82239. /**
  82240. * Class used to store 2D control sizes
  82241. */
  82242. export class Measure {
  82243. /** defines left coordinate */
  82244. left: number;
  82245. /** defines top coordinate */
  82246. top: number;
  82247. /** defines width dimension */
  82248. width: number;
  82249. /** defines height dimension */
  82250. height: number;
  82251. /**
  82252. * Creates a new measure
  82253. * @param left defines left coordinate
  82254. * @param top defines top coordinate
  82255. * @param width defines width dimension
  82256. * @param height defines height dimension
  82257. */
  82258. constructor(
  82259. /** defines left coordinate */
  82260. left: number,
  82261. /** defines top coordinate */
  82262. top: number,
  82263. /** defines width dimension */
  82264. width: number,
  82265. /** defines height dimension */
  82266. height: number);
  82267. /**
  82268. * Copy from another measure
  82269. * @param other defines the other measure to copy from
  82270. */
  82271. copyFrom(other: Measure): void;
  82272. /**
  82273. * Copy from a group of 4 floats
  82274. * @param left defines left coordinate
  82275. * @param top defines top coordinate
  82276. * @param width defines width dimension
  82277. * @param height defines height dimension
  82278. */
  82279. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82280. /**
  82281. * Computes the axis aligned bounding box measure for two given measures
  82282. * @param a Input measure
  82283. * @param b Input measure
  82284. * @param result the resulting bounding measure
  82285. */
  82286. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82287. /**
  82288. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82289. * @param transform the matrix to transform the measure before computing the AABB
  82290. * @param addX number to add to left
  82291. * @param addY number to add to top
  82292. * @param addWidth number to add to width
  82293. * @param addHeight number to add to height
  82294. * @param result the resulting AABB
  82295. */
  82296. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82297. /**
  82298. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82299. * @param transform the matrix to transform the measure before computing the AABB
  82300. * @param result the resulting AABB
  82301. */
  82302. transformToRef(transform: Matrix2D, result: Measure): void;
  82303. /**
  82304. * Check equality between this measure and another one
  82305. * @param other defines the other measures
  82306. * @returns true if both measures are equals
  82307. */
  82308. isEqualsTo(other: Measure): boolean;
  82309. /**
  82310. * Creates an empty measure
  82311. * @returns a new measure
  82312. */
  82313. static Empty(): Measure;
  82314. }
  82315. }
  82316. declare module BABYLON.GUI {
  82317. /**
  82318. * Class used to create texture to support 2D GUI elements
  82319. * @see https://doc.babylonjs.com/how_to/gui
  82320. */
  82321. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82322. /** Define the Uurl to load snippets */
  82323. static SnippetUrl: string;
  82324. /** Snippet ID if the content was created from the snippet server */
  82325. snippetId: string;
  82326. private _isDirty;
  82327. private _renderObserver;
  82328. private _resizeObserver;
  82329. private _preKeyboardObserver;
  82330. private _pointerMoveObserver;
  82331. private _pointerObserver;
  82332. private _canvasPointerOutObserver;
  82333. private _canvasBlurObserver;
  82334. private _background;
  82335. /** @hidden */
  82336. _rootContainer: Container;
  82337. /** @hidden */
  82338. _lastPickedControl: Control;
  82339. /** @hidden */
  82340. _lastControlOver: {
  82341. [pointerId: number]: Control;
  82342. };
  82343. /** @hidden */
  82344. _lastControlDown: {
  82345. [pointerId: number]: Control;
  82346. };
  82347. /** @hidden */
  82348. _capturingControl: {
  82349. [pointerId: number]: Control;
  82350. };
  82351. /** @hidden */
  82352. _shouldBlockPointer: boolean;
  82353. /** @hidden */
  82354. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82355. /** @hidden */
  82356. _linkedControls: Control[];
  82357. private _isFullscreen;
  82358. private _fullscreenViewport;
  82359. private _idealWidth;
  82360. private _idealHeight;
  82361. private _useSmallestIdeal;
  82362. private _renderAtIdealSize;
  82363. private _focusedControl;
  82364. private _blockNextFocusCheck;
  82365. private _renderScale;
  82366. private _rootElement;
  82367. private _cursorChanged;
  82368. private _defaultMousePointerId;
  82369. /** @hidden */
  82370. _numLayoutCalls: number;
  82371. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82372. get numLayoutCalls(): number;
  82373. /** @hidden */
  82374. _numRenderCalls: number;
  82375. /** Gets the number of render calls made the last time the ADT has been rendered */
  82376. get numRenderCalls(): number;
  82377. /**
  82378. * Define type to string to ensure compatibility across browsers
  82379. * Safari doesn't support DataTransfer constructor
  82380. */
  82381. private _clipboardData;
  82382. /**
  82383. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82384. */
  82385. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82386. /**
  82387. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82388. */
  82389. onControlPickedObservable: BABYLON.Observable<Control>;
  82390. /**
  82391. * BABYLON.Observable event triggered before layout is evaluated
  82392. */
  82393. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82394. /**
  82395. * BABYLON.Observable event triggered after the layout was evaluated
  82396. */
  82397. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82398. /**
  82399. * BABYLON.Observable event triggered before the texture is rendered
  82400. */
  82401. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82402. /**
  82403. * BABYLON.Observable event triggered after the texture was rendered
  82404. */
  82405. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82406. /**
  82407. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82408. */
  82409. premulAlpha: boolean;
  82410. /**
  82411. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82412. */
  82413. applyYInversionOnUpdate: boolean;
  82414. /**
  82415. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82416. * Useful when you want more antialiasing
  82417. */
  82418. get renderScale(): number;
  82419. set renderScale(value: number);
  82420. /** Gets or sets the background color */
  82421. get background(): string;
  82422. set background(value: string);
  82423. /**
  82424. * Gets or sets the ideal width used to design controls.
  82425. * The GUI will then rescale everything accordingly
  82426. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82427. */
  82428. get idealWidth(): number;
  82429. set idealWidth(value: number);
  82430. /**
  82431. * Gets or sets the ideal height used to design controls.
  82432. * The GUI will then rescale everything accordingly
  82433. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82434. */
  82435. get idealHeight(): number;
  82436. set idealHeight(value: number);
  82437. /**
  82438. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82439. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82440. */
  82441. get useSmallestIdeal(): boolean;
  82442. set useSmallestIdeal(value: boolean);
  82443. /**
  82444. * Gets or sets a boolean indicating if adaptive scaling must be used
  82445. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82446. */
  82447. get renderAtIdealSize(): boolean;
  82448. set renderAtIdealSize(value: boolean);
  82449. /**
  82450. * Gets the ratio used when in "ideal mode"
  82451. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82452. * */
  82453. get idealRatio(): number;
  82454. /**
  82455. * Gets the underlying layer used to render the texture when in fullscreen mode
  82456. */
  82457. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82458. /**
  82459. * Gets the root container control
  82460. */
  82461. get rootContainer(): Container;
  82462. /**
  82463. * Returns an array containing the root container.
  82464. * This is mostly used to let the Inspector introspects the ADT
  82465. * @returns an array containing the rootContainer
  82466. */
  82467. getChildren(): Array<Container>;
  82468. /**
  82469. * Will return all controls that are inside this texture
  82470. * @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
  82471. * @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
  82472. * @return all child controls
  82473. */
  82474. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82475. /**
  82476. * Gets or sets the current focused control
  82477. */
  82478. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82479. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82480. /**
  82481. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82482. */
  82483. get isForeground(): boolean;
  82484. set isForeground(value: boolean);
  82485. /**
  82486. * Gets or set information about clipboardData
  82487. */
  82488. get clipboardData(): string;
  82489. set clipboardData(value: string);
  82490. /**
  82491. * Creates a new AdvancedDynamicTexture
  82492. * @param name defines the name of the texture
  82493. * @param width defines the width of the texture
  82494. * @param height defines the height of the texture
  82495. * @param scene defines the hosting scene
  82496. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82497. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82498. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82499. */
  82500. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82501. /**
  82502. * Get the current class name of the texture useful for serialization or dynamic coding.
  82503. * @returns "AdvancedDynamicTexture"
  82504. */
  82505. getClassName(): string;
  82506. /**
  82507. * Function used to execute a function on all controls
  82508. * @param func defines the function to execute
  82509. * @param container defines the container where controls belong. If null the root container will be used
  82510. */
  82511. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82512. private _useInvalidateRectOptimization;
  82513. /**
  82514. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82515. */
  82516. get useInvalidateRectOptimization(): boolean;
  82517. set useInvalidateRectOptimization(value: boolean);
  82518. private _invalidatedRectangle;
  82519. /**
  82520. * Invalidates a rectangle area on the gui texture
  82521. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82522. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82523. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82524. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82525. */
  82526. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82527. /**
  82528. * Marks the texture as dirty forcing a complete update
  82529. */
  82530. markAsDirty(): void;
  82531. /**
  82532. * Helper function used to create a new style
  82533. * @returns a new style
  82534. * @see https://doc.babylonjs.com/how_to/gui#styles
  82535. */
  82536. createStyle(): Style;
  82537. /**
  82538. * Adds a new control to the root container
  82539. * @param control defines the control to add
  82540. * @returns the current texture
  82541. */
  82542. addControl(control: Control): AdvancedDynamicTexture;
  82543. /**
  82544. * Removes a control from the root container
  82545. * @param control defines the control to remove
  82546. * @returns the current texture
  82547. */
  82548. removeControl(control: Control): AdvancedDynamicTexture;
  82549. /**
  82550. * Release all resources
  82551. */
  82552. dispose(): void;
  82553. private _onResize;
  82554. /** @hidden */
  82555. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82556. /**
  82557. * Get screen coordinates for a vector3
  82558. * @param position defines the position to project
  82559. * @param worldMatrix defines the world matrix to use
  82560. * @returns the projected position
  82561. */
  82562. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82563. /**
  82564. * Get screen coordinates for a vector3
  82565. * @param position defines the position to project
  82566. * @param worldMatrix defines the world matrix to use
  82567. * @returns the projected position with Z
  82568. */
  82569. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82570. private _checkUpdate;
  82571. private _clearMeasure;
  82572. private _render;
  82573. /** @hidden */
  82574. _changeCursor(cursor: string): void;
  82575. /** @hidden */
  82576. _registerLastControlDown(control: Control, pointerId: number): void;
  82577. private _doPicking;
  82578. /** @hidden */
  82579. _cleanControlAfterRemovalFromList(list: {
  82580. [pointerId: number]: Control;
  82581. }, control: Control): void;
  82582. /** @hidden */
  82583. _cleanControlAfterRemoval(control: Control): void;
  82584. /** Attach to all scene events required to support pointer events */
  82585. attach(): void;
  82586. /** @hidden */
  82587. private onClipboardCopy;
  82588. /** @hidden */
  82589. private onClipboardCut;
  82590. /** @hidden */
  82591. private onClipboardPaste;
  82592. /**
  82593. * Register the clipboard Events onto the canvas
  82594. */
  82595. registerClipboardEvents(): void;
  82596. /**
  82597. * Unregister the clipboard Events from the canvas
  82598. */
  82599. unRegisterClipboardEvents(): void;
  82600. /**
  82601. * Connect the texture to a hosting mesh to enable interactions
  82602. * @param mesh defines the mesh to attach to
  82603. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82604. */
  82605. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82606. /**
  82607. * Move the focus to a specific control
  82608. * @param control defines the control which will receive the focus
  82609. */
  82610. moveFocusToControl(control: IFocusableControl): void;
  82611. private _manageFocus;
  82612. private _attachToOnPointerOut;
  82613. private _attachToOnBlur;
  82614. /**
  82615. * Serializes the entire GUI system
  82616. * @returns an object with the JSON serialized data
  82617. */
  82618. serializeContent(): any;
  82619. /**
  82620. * Recreate the content of the ADT from a JSON object
  82621. * @param serializedObject define the JSON serialized object to restore from
  82622. */
  82623. parseContent(serializedObject: any): void;
  82624. /**
  82625. * Recreate the content of the ADT from a snippet saved by the GUI editor
  82626. * @param snippetId defines the snippet to load
  82627. * @returns a promise that will resolve on success
  82628. */
  82629. parseFromSnippetAsync(snippetId: string): Promise<void>;
  82630. /**
  82631. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82632. * @param mesh defines the mesh which will receive the texture
  82633. * @param width defines the texture width (1024 by default)
  82634. * @param height defines the texture height (1024 by default)
  82635. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82636. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82637. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82638. * @returns a new AdvancedDynamicTexture
  82639. */
  82640. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82641. /**
  82642. * 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
  82643. * @param mesh defines the mesh which will receive the texture
  82644. * @param width defines the texture width (1024 by default)
  82645. * @param height defines the texture height (1024 by default)
  82646. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82647. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82648. * @returns a new AdvancedDynamicTexture
  82649. */
  82650. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82651. /**
  82652. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82653. * In this mode the texture will rely on a layer for its rendering.
  82654. * This allows it to be treated like any other layer.
  82655. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82656. * LayerMask is set through advancedTexture.layer.layerMask
  82657. * @param name defines name for the texture
  82658. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82659. * @param scene defines the hsoting scene
  82660. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82661. * @returns a new AdvancedDynamicTexture
  82662. */
  82663. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82664. }
  82665. }
  82666. declare module BABYLON.GUI {
  82667. /**
  82668. * Root class used for all 2D controls
  82669. * @see https://doc.babylonjs.com/how_to/gui#controls
  82670. */
  82671. export class Control {
  82672. /** defines the name of the control */
  82673. name?: string | undefined;
  82674. /**
  82675. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82676. */
  82677. static AllowAlphaInheritance: boolean;
  82678. private _alpha;
  82679. private _alphaSet;
  82680. private _zIndex;
  82681. /** @hidden */
  82682. _host: AdvancedDynamicTexture;
  82683. /** Gets or sets the control parent */
  82684. parent: BABYLON.Nullable<Container>;
  82685. /** @hidden */
  82686. _currentMeasure: Measure;
  82687. private _fontFamily;
  82688. private _fontStyle;
  82689. private _fontWeight;
  82690. private _fontSize;
  82691. private _font;
  82692. /** @hidden */
  82693. _width: ValueAndUnit;
  82694. /** @hidden */
  82695. _height: ValueAndUnit;
  82696. /** @hidden */
  82697. protected _fontOffset: {
  82698. ascent: number;
  82699. height: number;
  82700. descent: number;
  82701. };
  82702. private _color;
  82703. private _style;
  82704. private _styleObserver;
  82705. /** @hidden */
  82706. protected _horizontalAlignment: number;
  82707. /** @hidden */
  82708. protected _verticalAlignment: number;
  82709. /** @hidden */
  82710. protected _isDirty: boolean;
  82711. /** @hidden */
  82712. protected _wasDirty: boolean;
  82713. /** @hidden */
  82714. _tempParentMeasure: Measure;
  82715. /** @hidden */
  82716. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82717. /** @hidden */
  82718. protected _cachedParentMeasure: Measure;
  82719. private _paddingLeft;
  82720. private _paddingRight;
  82721. private _paddingTop;
  82722. private _paddingBottom;
  82723. /** @hidden */
  82724. _left: ValueAndUnit;
  82725. /** @hidden */
  82726. _top: ValueAndUnit;
  82727. private _scaleX;
  82728. private _scaleY;
  82729. private _rotation;
  82730. private _transformCenterX;
  82731. private _transformCenterY;
  82732. /** @hidden */
  82733. _transformMatrix: Matrix2D;
  82734. /** @hidden */
  82735. protected _invertTransformMatrix: Matrix2D;
  82736. /** @hidden */
  82737. protected _transformedPosition: BABYLON.Vector2;
  82738. private _isMatrixDirty;
  82739. private _cachedOffsetX;
  82740. private _cachedOffsetY;
  82741. private _isVisible;
  82742. private _isHighlighted;
  82743. /** @hidden */
  82744. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82745. private _fontSet;
  82746. private _dummyVector2;
  82747. private _downCount;
  82748. private _enterCount;
  82749. private _doNotRender;
  82750. private _downPointerIds;
  82751. protected _isEnabled: boolean;
  82752. protected _disabledColor: string;
  82753. protected _disabledColorItem: string;
  82754. /** @hidden */
  82755. protected _rebuildLayout: boolean;
  82756. /** @hidden */
  82757. _customData: any;
  82758. /** @hidden */
  82759. _isClipped: boolean;
  82760. /** @hidden */
  82761. _automaticSize: boolean;
  82762. /** @hidden */
  82763. _tag: any;
  82764. /**
  82765. * 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
  82766. */
  82767. uniqueId: number;
  82768. /**
  82769. * Gets or sets an object used to store user defined information for the node
  82770. */
  82771. metadata: any;
  82772. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82773. isHitTestVisible: boolean;
  82774. /** Gets or sets a boolean indicating if the control can block pointer events */
  82775. isPointerBlocker: boolean;
  82776. /** Gets or sets a boolean indicating if the control can be focusable */
  82777. isFocusInvisible: boolean;
  82778. /**
  82779. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82780. * 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
  82781. */
  82782. clipChildren: boolean;
  82783. /**
  82784. * Gets or sets a boolean indicating that control content must be clipped
  82785. * 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
  82786. */
  82787. clipContent: boolean;
  82788. /**
  82789. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82790. */
  82791. useBitmapCache: boolean;
  82792. private _cacheData;
  82793. private _shadowOffsetX;
  82794. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82795. get shadowOffsetX(): number;
  82796. set shadowOffsetX(value: number);
  82797. private _shadowOffsetY;
  82798. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82799. get shadowOffsetY(): number;
  82800. set shadowOffsetY(value: number);
  82801. private _shadowBlur;
  82802. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82803. get shadowBlur(): number;
  82804. set shadowBlur(value: number);
  82805. private _shadowColor;
  82806. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82807. get shadowColor(): string;
  82808. set shadowColor(value: string);
  82809. /** Gets or sets the cursor to use when the control is hovered */
  82810. hoverCursor: string;
  82811. /** @hidden */
  82812. protected _linkOffsetX: ValueAndUnit;
  82813. /** @hidden */
  82814. protected _linkOffsetY: ValueAndUnit;
  82815. /** Gets the control type name */
  82816. get typeName(): string;
  82817. /**
  82818. * Get the current class name of the control.
  82819. * @returns current class name
  82820. */
  82821. getClassName(): string;
  82822. /**
  82823. * An event triggered when pointer wheel is scrolled
  82824. */
  82825. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82826. /**
  82827. * An event triggered when the pointer move over the control.
  82828. */
  82829. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82830. /**
  82831. * An event triggered when the pointer move out of the control.
  82832. */
  82833. onPointerOutObservable: BABYLON.Observable<Control>;
  82834. /**
  82835. * An event triggered when the pointer taps the control
  82836. */
  82837. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82838. /**
  82839. * An event triggered when pointer up
  82840. */
  82841. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82842. /**
  82843. * An event triggered when a control is clicked on
  82844. */
  82845. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82846. /**
  82847. * An event triggered when pointer enters the control
  82848. */
  82849. onPointerEnterObservable: BABYLON.Observable<Control>;
  82850. /**
  82851. * An event triggered when the control is marked as dirty
  82852. */
  82853. onDirtyObservable: BABYLON.Observable<Control>;
  82854. /**
  82855. * An event triggered before drawing the control
  82856. */
  82857. onBeforeDrawObservable: BABYLON.Observable<Control>;
  82858. /**
  82859. * An event triggered after the control was drawn
  82860. */
  82861. onAfterDrawObservable: BABYLON.Observable<Control>;
  82862. /**
  82863. * An event triggered when the control has been disposed
  82864. */
  82865. onDisposeObservable: BABYLON.Observable<Control>;
  82866. /**
  82867. * Get the hosting AdvancedDynamicTexture
  82868. */
  82869. get host(): AdvancedDynamicTexture;
  82870. /** Gets or set information about font offsets (used to render and align text) */
  82871. get fontOffset(): {
  82872. ascent: number;
  82873. height: number;
  82874. descent: number;
  82875. };
  82876. set fontOffset(offset: {
  82877. ascent: number;
  82878. height: number;
  82879. descent: number;
  82880. });
  82881. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  82882. get alpha(): number;
  82883. set alpha(value: number);
  82884. /**
  82885. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  82886. */
  82887. get isHighlighted(): boolean;
  82888. set isHighlighted(value: boolean);
  82889. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  82890. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82891. */
  82892. get scaleX(): number;
  82893. set scaleX(value: number);
  82894. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  82895. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82896. */
  82897. get scaleY(): number;
  82898. set scaleY(value: number);
  82899. /** Gets or sets the rotation angle (0 by default)
  82900. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82901. */
  82902. get rotation(): number;
  82903. set rotation(value: number);
  82904. /** Gets or sets the transformation center on Y axis (0 by default)
  82905. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82906. */
  82907. get transformCenterY(): number;
  82908. set transformCenterY(value: number);
  82909. /** Gets or sets the transformation center on X axis (0 by default)
  82910. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82911. */
  82912. get transformCenterX(): number;
  82913. set transformCenterX(value: number);
  82914. /**
  82915. * Gets or sets the horizontal alignment
  82916. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82917. */
  82918. get horizontalAlignment(): number;
  82919. set horizontalAlignment(value: number);
  82920. /**
  82921. * Gets or sets the vertical alignment
  82922. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82923. */
  82924. get verticalAlignment(): number;
  82925. set verticalAlignment(value: number);
  82926. /**
  82927. * Gets or sets a fixed ratio for this control.
  82928. * When different from 0, the ratio is used to compute the "second" dimension.
  82929. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  82930. * second dimension is computed as first dimension * fixedRatio
  82931. */
  82932. fixedRatio: number;
  82933. private _fixedRatioMasterIsWidth;
  82934. /**
  82935. * Gets or sets control width
  82936. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82937. */
  82938. get width(): string | number;
  82939. set width(value: string | number);
  82940. /**
  82941. * Gets or sets the control width in pixel
  82942. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82943. */
  82944. get widthInPixels(): number;
  82945. set widthInPixels(value: number);
  82946. /**
  82947. * Gets or sets control height
  82948. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82949. */
  82950. get height(): string | number;
  82951. set height(value: string | number);
  82952. /**
  82953. * Gets or sets control height in pixel
  82954. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82955. */
  82956. get heightInPixels(): number;
  82957. set heightInPixels(value: number);
  82958. /** Gets or set font family */
  82959. get fontFamily(): string;
  82960. set fontFamily(value: string);
  82961. /** Gets or sets font style */
  82962. get fontStyle(): string;
  82963. set fontStyle(value: string);
  82964. /** Gets or sets font weight */
  82965. get fontWeight(): string;
  82966. set fontWeight(value: string);
  82967. /**
  82968. * Gets or sets style
  82969. * @see https://doc.babylonjs.com/how_to/gui#styles
  82970. */
  82971. get style(): BABYLON.Nullable<Style>;
  82972. set style(value: BABYLON.Nullable<Style>);
  82973. /** @hidden */
  82974. get _isFontSizeInPercentage(): boolean;
  82975. /** Gets or sets font size in pixels */
  82976. get fontSizeInPixels(): number;
  82977. set fontSizeInPixels(value: number);
  82978. /** Gets or sets font size */
  82979. get fontSize(): string | number;
  82980. set fontSize(value: string | number);
  82981. /** Gets or sets foreground color */
  82982. get color(): string;
  82983. set color(value: string);
  82984. /** Gets or sets z index which is used to reorder controls on the z axis */
  82985. get zIndex(): number;
  82986. set zIndex(value: number);
  82987. /** Gets or sets a boolean indicating if the control can be rendered */
  82988. get notRenderable(): boolean;
  82989. set notRenderable(value: boolean);
  82990. /** Gets or sets a boolean indicating if the control is visible */
  82991. get isVisible(): boolean;
  82992. set isVisible(value: boolean);
  82993. /** Gets a boolean indicating that the control needs to update its rendering */
  82994. get isDirty(): boolean;
  82995. /**
  82996. * Gets the current linked mesh (or null if none)
  82997. */
  82998. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  82999. /**
  83000. * Gets or sets a value indicating the padding to use on the left of the control
  83001. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83002. */
  83003. get paddingLeft(): string | number;
  83004. set paddingLeft(value: string | number);
  83005. /**
  83006. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83007. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83008. */
  83009. get paddingLeftInPixels(): number;
  83010. set paddingLeftInPixels(value: number);
  83011. /**
  83012. * Gets or sets a value indicating the padding to use on the right of the control
  83013. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83014. */
  83015. get paddingRight(): string | number;
  83016. set paddingRight(value: string | number);
  83017. /**
  83018. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83019. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83020. */
  83021. get paddingRightInPixels(): number;
  83022. set paddingRightInPixels(value: number);
  83023. /**
  83024. * Gets or sets a value indicating the padding to use on the top of the control
  83025. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83026. */
  83027. get paddingTop(): string | number;
  83028. set paddingTop(value: string | number);
  83029. /**
  83030. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83031. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83032. */
  83033. get paddingTopInPixels(): number;
  83034. set paddingTopInPixels(value: number);
  83035. /**
  83036. * Gets or sets a value indicating the padding to use on the bottom of the control
  83037. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83038. */
  83039. get paddingBottom(): string | number;
  83040. set paddingBottom(value: string | number);
  83041. /**
  83042. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83043. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83044. */
  83045. get paddingBottomInPixels(): number;
  83046. set paddingBottomInPixels(value: number);
  83047. /**
  83048. * Gets or sets a value indicating the left coordinate of the control
  83049. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83050. */
  83051. get left(): string | number;
  83052. set left(value: string | number);
  83053. /**
  83054. * Gets or sets a value indicating the left coordinate in pixels of the control
  83055. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83056. */
  83057. get leftInPixels(): number;
  83058. set leftInPixels(value: number);
  83059. /**
  83060. * Gets or sets a value indicating the top coordinate of the control
  83061. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83062. */
  83063. get top(): string | number;
  83064. set top(value: string | number);
  83065. /**
  83066. * Gets or sets a value indicating the top coordinate in pixels of the control
  83067. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83068. */
  83069. get topInPixels(): number;
  83070. set topInPixels(value: number);
  83071. /**
  83072. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83073. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83074. */
  83075. get linkOffsetX(): string | number;
  83076. set linkOffsetX(value: string | number);
  83077. /**
  83078. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83079. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83080. */
  83081. get linkOffsetXInPixels(): number;
  83082. set linkOffsetXInPixels(value: number);
  83083. /**
  83084. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83085. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83086. */
  83087. get linkOffsetY(): string | number;
  83088. set linkOffsetY(value: string | number);
  83089. /**
  83090. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83091. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83092. */
  83093. get linkOffsetYInPixels(): number;
  83094. set linkOffsetYInPixels(value: number);
  83095. /** Gets the center coordinate on X axis */
  83096. get centerX(): number;
  83097. /** Gets the center coordinate on Y axis */
  83098. get centerY(): number;
  83099. /** Gets or sets if control is Enabled */
  83100. get isEnabled(): boolean;
  83101. set isEnabled(value: boolean);
  83102. /** Gets or sets background color of control if it's disabled */
  83103. get disabledColor(): string;
  83104. set disabledColor(value: string);
  83105. /** Gets or sets front color of control if it's disabled */
  83106. get disabledColorItem(): string;
  83107. set disabledColorItem(value: string);
  83108. /**
  83109. * Creates a new control
  83110. * @param name defines the name of the control
  83111. */
  83112. constructor(
  83113. /** defines the name of the control */
  83114. name?: string | undefined);
  83115. /** @hidden */
  83116. protected _getTypeName(): string;
  83117. /**
  83118. * Gets the first ascendant in the hierarchy of the given type
  83119. * @param className defines the required type
  83120. * @returns the ascendant or null if not found
  83121. */
  83122. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83123. /** @hidden */
  83124. _resetFontCache(): void;
  83125. /**
  83126. * Determines if a container is an ascendant of the current control
  83127. * @param container defines the container to look for
  83128. * @returns true if the container is one of the ascendant of the control
  83129. */
  83130. isAscendant(container: Control): boolean;
  83131. /**
  83132. * Gets coordinates in local control space
  83133. * @param globalCoordinates defines the coordinates to transform
  83134. * @returns the new coordinates in local space
  83135. */
  83136. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83137. /**
  83138. * Gets coordinates in local control space
  83139. * @param globalCoordinates defines the coordinates to transform
  83140. * @param result defines the target vector2 where to store the result
  83141. * @returns the current control
  83142. */
  83143. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83144. /**
  83145. * Gets coordinates in parent local control space
  83146. * @param globalCoordinates defines the coordinates to transform
  83147. * @returns the new coordinates in parent local space
  83148. */
  83149. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83150. /**
  83151. * Move the current control to a vector3 position projected onto the screen.
  83152. * @param position defines the target position
  83153. * @param scene defines the hosting scene
  83154. */
  83155. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83156. /**
  83157. * Will store all controls that have this control as ascendant in a given array
  83158. * @param results defines the array where to store the descendants
  83159. * @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
  83160. * @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
  83161. */
  83162. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83163. /**
  83164. * Will return all controls that have this control as ascendant
  83165. * @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
  83166. * @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
  83167. * @return all child controls
  83168. */
  83169. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83170. /**
  83171. * Link current control with a target mesh
  83172. * @param mesh defines the mesh to link with
  83173. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83174. */
  83175. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83176. /**
  83177. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83178. * @param { string | number} paddingTop - The value of the top padding.
  83179. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83180. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83181. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83182. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83183. */
  83184. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83185. /**
  83186. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83187. * @param { number} paddingTop - The value in pixels of the top padding.
  83188. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83189. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83190. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83191. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83192. */
  83193. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83194. /** @hidden */
  83195. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83196. /** @hidden */
  83197. _offsetLeft(offset: number): void;
  83198. /** @hidden */
  83199. _offsetTop(offset: number): void;
  83200. /** @hidden */
  83201. _markMatrixAsDirty(): void;
  83202. /** @hidden */
  83203. _flagDescendantsAsMatrixDirty(): void;
  83204. /** @hidden */
  83205. _intersectsRect(rect: Measure): boolean;
  83206. /** @hidden */
  83207. protected invalidateRect(): void;
  83208. /** @hidden */
  83209. _markAsDirty(force?: boolean): void;
  83210. /** @hidden */
  83211. _markAllAsDirty(): void;
  83212. /** @hidden */
  83213. _link(host: AdvancedDynamicTexture): void;
  83214. /** @hidden */
  83215. protected _transform(context?: CanvasRenderingContext2D): void;
  83216. /** @hidden */
  83217. _renderHighlight(context: CanvasRenderingContext2D): void;
  83218. /** @hidden */
  83219. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83220. /** @hidden */
  83221. protected _applyStates(context: CanvasRenderingContext2D): void;
  83222. /** @hidden */
  83223. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83224. /** @hidden */
  83225. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83226. protected _evaluateClippingState(parentMeasure: Measure): void;
  83227. /** @hidden */
  83228. _measure(): void;
  83229. /** @hidden */
  83230. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83231. /** @hidden */
  83232. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83233. /** @hidden */
  83234. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83235. /** @hidden */
  83236. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83237. private static _ClipMeasure;
  83238. private _tmpMeasureA;
  83239. private _clip;
  83240. /** @hidden */
  83241. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83242. /** @hidden */
  83243. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83244. /**
  83245. * Tests if a given coordinates belong to the current control
  83246. * @param x defines x coordinate to test
  83247. * @param y defines y coordinate to test
  83248. * @returns true if the coordinates are inside the control
  83249. */
  83250. contains(x: number, y: number): boolean;
  83251. /** @hidden */
  83252. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83253. /** @hidden */
  83254. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83255. /** @hidden */
  83256. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83257. /** @hidden */
  83258. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83259. /** @hidden */
  83260. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83261. /** @hidden */
  83262. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83263. /** @hidden */
  83264. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83265. /** @hidden */
  83266. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83267. /** @hidden */
  83268. _onCanvasBlur(): void;
  83269. /** @hidden */
  83270. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83271. private _prepareFont;
  83272. /**
  83273. * Serializes the current control
  83274. * @param serializationObject defined the JSON serialized object
  83275. */
  83276. serialize(serializationObject: any): void;
  83277. /** @hidden */
  83278. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83279. /** Releases associated resources */
  83280. dispose(): void;
  83281. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83282. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83283. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83284. private static _VERTICAL_ALIGNMENT_TOP;
  83285. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83286. private static _VERTICAL_ALIGNMENT_CENTER;
  83287. /** HORIZONTAL_ALIGNMENT_LEFT */
  83288. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83289. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83290. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83291. /** HORIZONTAL_ALIGNMENT_CENTER */
  83292. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83293. /** VERTICAL_ALIGNMENT_TOP */
  83294. static get VERTICAL_ALIGNMENT_TOP(): number;
  83295. /** VERTICAL_ALIGNMENT_BOTTOM */
  83296. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83297. /** VERTICAL_ALIGNMENT_CENTER */
  83298. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83299. private static _FontHeightSizes;
  83300. /** @hidden */
  83301. static _GetFontOffset(font: string): {
  83302. ascent: number;
  83303. height: number;
  83304. descent: number;
  83305. };
  83306. /**
  83307. * Creates a Control from parsed data
  83308. * @param serializedObject defines parsed data
  83309. * @param host defines the hosting AdvancedDynamicTexture
  83310. * @returns a new Control
  83311. */
  83312. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83313. /**
  83314. * Creates a stack panel that can be used to render headers
  83315. * @param control defines the control to associate with the header
  83316. * @param text defines the text of the header
  83317. * @param size defines the size of the header
  83318. * @param options defines options used to configure the header
  83319. * @returns a new StackPanel
  83320. * @ignore
  83321. * @hidden
  83322. */
  83323. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83324. isHorizontal: boolean;
  83325. controlFirst: boolean;
  83326. }) => any;
  83327. /** @hidden */
  83328. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83329. }
  83330. }
  83331. declare module BABYLON.GUI {
  83332. /**
  83333. * Root class for 2D containers
  83334. * @see https://doc.babylonjs.com/how_to/gui#containers
  83335. */
  83336. export class Container extends Control {
  83337. name?: string | undefined;
  83338. /** @hidden */
  83339. _children: Control[];
  83340. /** @hidden */
  83341. protected _measureForChildren: Measure;
  83342. /** @hidden */
  83343. protected _background: string;
  83344. /** @hidden */
  83345. protected _adaptWidthToChildren: boolean;
  83346. /** @hidden */
  83347. protected _adaptHeightToChildren: boolean;
  83348. /**
  83349. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83350. */
  83351. logLayoutCycleErrors: boolean;
  83352. /**
  83353. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83354. */
  83355. maxLayoutCycle: number;
  83356. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83357. get adaptHeightToChildren(): boolean;
  83358. set adaptHeightToChildren(value: boolean);
  83359. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83360. get adaptWidthToChildren(): boolean;
  83361. set adaptWidthToChildren(value: boolean);
  83362. /** Gets or sets background color */
  83363. get background(): string;
  83364. set background(value: string);
  83365. /** Gets the list of children */
  83366. get children(): Control[];
  83367. /**
  83368. * Creates a new Container
  83369. * @param name defines the name of the container
  83370. */
  83371. constructor(name?: string | undefined);
  83372. protected _getTypeName(): string;
  83373. _flagDescendantsAsMatrixDirty(): void;
  83374. /**
  83375. * Gets a child using its name
  83376. * @param name defines the child name to look for
  83377. * @returns the child control if found
  83378. */
  83379. getChildByName(name: string): BABYLON.Nullable<Control>;
  83380. /**
  83381. * Gets a child using its type and its name
  83382. * @param name defines the child name to look for
  83383. * @param type defines the child type to look for
  83384. * @returns the child control if found
  83385. */
  83386. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83387. /**
  83388. * Search for a specific control in children
  83389. * @param control defines the control to look for
  83390. * @returns true if the control is in child list
  83391. */
  83392. containsControl(control: Control): boolean;
  83393. /**
  83394. * Adds a new control to the current container
  83395. * @param control defines the control to add
  83396. * @returns the current container
  83397. */
  83398. addControl(control: BABYLON.Nullable<Control>): Container;
  83399. /**
  83400. * Removes all controls from the current container
  83401. * @returns the current container
  83402. */
  83403. clearControls(): Container;
  83404. /**
  83405. * Removes a control from the current container
  83406. * @param control defines the control to remove
  83407. * @returns the current container
  83408. */
  83409. removeControl(control: Control): Container;
  83410. /** @hidden */
  83411. _reOrderControl(control: Control): void;
  83412. /** @hidden */
  83413. _offsetLeft(offset: number): void;
  83414. /** @hidden */
  83415. _offsetTop(offset: number): void;
  83416. /** @hidden */
  83417. _markAllAsDirty(): void;
  83418. /** @hidden */
  83419. protected _localDraw(context: CanvasRenderingContext2D): void;
  83420. /** @hidden */
  83421. _link(host: AdvancedDynamicTexture): void;
  83422. /** @hidden */
  83423. protected _beforeLayout(): void;
  83424. /** @hidden */
  83425. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83426. /** @hidden */
  83427. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83428. protected _postMeasure(): void;
  83429. /** @hidden */
  83430. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83431. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83432. /** @hidden */
  83433. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83434. /** @hidden */
  83435. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83436. /**
  83437. * Serializes the current control
  83438. * @param serializationObject defined the JSON serialized object
  83439. */
  83440. serialize(serializationObject: any): void;
  83441. /** Releases associated resources */
  83442. dispose(): void;
  83443. /** @hidden */
  83444. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83445. }
  83446. }
  83447. declare module BABYLON.GUI {
  83448. /** Class used to create rectangle container */
  83449. export class Rectangle extends Container {
  83450. name?: string | undefined;
  83451. private _thickness;
  83452. private _cornerRadius;
  83453. /** Gets or sets border thickness */
  83454. get thickness(): number;
  83455. set thickness(value: number);
  83456. /** Gets or sets the corner radius angle */
  83457. get cornerRadius(): number;
  83458. set cornerRadius(value: number);
  83459. /**
  83460. * Creates a new Rectangle
  83461. * @param name defines the control name
  83462. */
  83463. constructor(name?: string | undefined);
  83464. protected _getTypeName(): string;
  83465. protected _localDraw(context: CanvasRenderingContext2D): void;
  83466. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83467. private _drawRoundedRect;
  83468. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83469. }
  83470. }
  83471. declare module BABYLON.GUI {
  83472. /**
  83473. * Enum that determines the text-wrapping mode to use.
  83474. */
  83475. export enum TextWrapping {
  83476. /**
  83477. * Clip the text when it's larger than Control.width; this is the default mode.
  83478. */
  83479. Clip = 0,
  83480. /**
  83481. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83482. */
  83483. WordWrap = 1,
  83484. /**
  83485. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83486. */
  83487. Ellipsis = 2
  83488. }
  83489. /**
  83490. * Class used to create text block control
  83491. */
  83492. export class TextBlock extends Control {
  83493. /**
  83494. * Defines the name of the control
  83495. */
  83496. name?: string | undefined;
  83497. private _text;
  83498. private _textWrapping;
  83499. private _textHorizontalAlignment;
  83500. private _textVerticalAlignment;
  83501. private _lines;
  83502. private _resizeToFit;
  83503. private _lineSpacing;
  83504. private _outlineWidth;
  83505. private _outlineColor;
  83506. private _underline;
  83507. private _lineThrough;
  83508. /**
  83509. * An event triggered after the text is changed
  83510. */
  83511. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83512. /**
  83513. * An event triggered after the text was broken up into lines
  83514. */
  83515. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83516. /**
  83517. * Function used to split a string into words. By default, a string is split at each space character found
  83518. */
  83519. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83520. /**
  83521. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83522. */
  83523. get lines(): any[];
  83524. /**
  83525. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83526. */
  83527. get resizeToFit(): boolean;
  83528. /**
  83529. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83530. */
  83531. set resizeToFit(value: boolean);
  83532. /**
  83533. * Gets or sets a boolean indicating if text must be wrapped
  83534. */
  83535. get textWrapping(): TextWrapping | boolean;
  83536. /**
  83537. * Gets or sets a boolean indicating if text must be wrapped
  83538. */
  83539. set textWrapping(value: TextWrapping | boolean);
  83540. /**
  83541. * Gets or sets text to display
  83542. */
  83543. get text(): string;
  83544. /**
  83545. * Gets or sets text to display
  83546. */
  83547. set text(value: string);
  83548. /**
  83549. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83550. */
  83551. get textHorizontalAlignment(): number;
  83552. /**
  83553. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83554. */
  83555. set textHorizontalAlignment(value: number);
  83556. /**
  83557. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83558. */
  83559. get textVerticalAlignment(): number;
  83560. /**
  83561. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83562. */
  83563. set textVerticalAlignment(value: number);
  83564. /**
  83565. * Gets or sets line spacing value
  83566. */
  83567. set lineSpacing(value: string | number);
  83568. /**
  83569. * Gets or sets line spacing value
  83570. */
  83571. get lineSpacing(): string | number;
  83572. /**
  83573. * Gets or sets outlineWidth of the text to display
  83574. */
  83575. get outlineWidth(): number;
  83576. /**
  83577. * Gets or sets outlineWidth of the text to display
  83578. */
  83579. set outlineWidth(value: number);
  83580. /**
  83581. * Gets or sets a boolean indicating that text must have underline
  83582. */
  83583. get underline(): boolean;
  83584. /**
  83585. * Gets or sets a boolean indicating that text must have underline
  83586. */
  83587. set underline(value: boolean);
  83588. /**
  83589. * Gets or sets an boolean indicating that text must be crossed out
  83590. */
  83591. get lineThrough(): boolean;
  83592. /**
  83593. * Gets or sets an boolean indicating that text must be crossed out
  83594. */
  83595. set lineThrough(value: boolean);
  83596. /**
  83597. * Gets or sets outlineColor of the text to display
  83598. */
  83599. get outlineColor(): string;
  83600. /**
  83601. * Gets or sets outlineColor of the text to display
  83602. */
  83603. set outlineColor(value: string);
  83604. /**
  83605. * Creates a new TextBlock object
  83606. * @param name defines the name of the control
  83607. * @param text defines the text to display (emptry string by default)
  83608. */
  83609. constructor(
  83610. /**
  83611. * Defines the name of the control
  83612. */
  83613. name?: string | undefined, text?: string);
  83614. protected _getTypeName(): string;
  83615. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83616. private _drawText;
  83617. /** @hidden */
  83618. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83619. protected _applyStates(context: CanvasRenderingContext2D): void;
  83620. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83621. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83622. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83623. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83624. protected _renderLines(context: CanvasRenderingContext2D): void;
  83625. /**
  83626. * Given a width constraint applied on the text block, find the expected height
  83627. * @returns expected height
  83628. */
  83629. computeExpectedHeight(): number;
  83630. dispose(): void;
  83631. }
  83632. }
  83633. declare module BABYLON.GUI {
  83634. /**
  83635. * Class used to create 2D images
  83636. */
  83637. export class Image extends Control {
  83638. name?: string | undefined;
  83639. private _workingCanvas;
  83640. private _domImage;
  83641. private _imageWidth;
  83642. private _imageHeight;
  83643. private _loaded;
  83644. private _stretch;
  83645. private _source;
  83646. private _autoScale;
  83647. private _sourceLeft;
  83648. private _sourceTop;
  83649. private _sourceWidth;
  83650. private _sourceHeight;
  83651. private _svgAttributesComputationCompleted;
  83652. private _isSVG;
  83653. private _cellWidth;
  83654. private _cellHeight;
  83655. private _cellId;
  83656. private _populateNinePatchSlicesFromImage;
  83657. private _sliceLeft;
  83658. private _sliceRight;
  83659. private _sliceTop;
  83660. private _sliceBottom;
  83661. private _detectPointerOnOpaqueOnly;
  83662. private _imageDataCache;
  83663. /**
  83664. * BABYLON.Observable notified when the content is loaded
  83665. */
  83666. onImageLoadedObservable: BABYLON.Observable<Image>;
  83667. /**
  83668. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83669. */
  83670. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83671. /**
  83672. * Gets a boolean indicating that the content is loaded
  83673. */
  83674. get isLoaded(): boolean;
  83675. /**
  83676. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83677. */
  83678. get populateNinePatchSlicesFromImage(): boolean;
  83679. set populateNinePatchSlicesFromImage(value: boolean);
  83680. /**
  83681. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83682. * Beware using this as this will comsume more memory as the image has to be stored twice
  83683. */
  83684. get detectPointerOnOpaqueOnly(): boolean;
  83685. set detectPointerOnOpaqueOnly(value: boolean);
  83686. /**
  83687. * Gets or sets the left value for slicing (9-patch)
  83688. */
  83689. get sliceLeft(): number;
  83690. set sliceLeft(value: number);
  83691. /**
  83692. * Gets or sets the right value for slicing (9-patch)
  83693. */
  83694. get sliceRight(): number;
  83695. set sliceRight(value: number);
  83696. /**
  83697. * Gets or sets the top value for slicing (9-patch)
  83698. */
  83699. get sliceTop(): number;
  83700. set sliceTop(value: number);
  83701. /**
  83702. * Gets or sets the bottom value for slicing (9-patch)
  83703. */
  83704. get sliceBottom(): number;
  83705. set sliceBottom(value: number);
  83706. /**
  83707. * Gets or sets the left coordinate in the source image
  83708. */
  83709. get sourceLeft(): number;
  83710. set sourceLeft(value: number);
  83711. /**
  83712. * Gets or sets the top coordinate in the source image
  83713. */
  83714. get sourceTop(): number;
  83715. set sourceTop(value: number);
  83716. /**
  83717. * Gets or sets the width to capture in the source image
  83718. */
  83719. get sourceWidth(): number;
  83720. set sourceWidth(value: number);
  83721. /**
  83722. * Gets or sets the height to capture in the source image
  83723. */
  83724. get sourceHeight(): number;
  83725. set sourceHeight(value: number);
  83726. /** Indicates if the format of the image is SVG */
  83727. get isSVG(): boolean;
  83728. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83729. get svgAttributesComputationCompleted(): boolean;
  83730. /**
  83731. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83732. * @see https://doc.babylonjs.com/how_to/gui#image
  83733. */
  83734. get autoScale(): boolean;
  83735. set autoScale(value: boolean);
  83736. /** Gets or sets the streching mode used by the image */
  83737. get stretch(): number;
  83738. set stretch(value: number);
  83739. /** @hidden */
  83740. _rotate90(n: number, preserveProperties?: boolean): Image;
  83741. private _handleRotationForSVGImage;
  83742. private _rotate90SourceProperties;
  83743. /**
  83744. * Gets or sets the internal DOM image used to render the control
  83745. */
  83746. set domImage(value: HTMLImageElement);
  83747. get domImage(): HTMLImageElement;
  83748. private _onImageLoaded;
  83749. private _extractNinePatchSliceDataFromImage;
  83750. /**
  83751. * Gets the image source url
  83752. */
  83753. get source(): BABYLON.Nullable<string>;
  83754. /**
  83755. * Gets or sets image source url
  83756. */
  83757. set source(value: BABYLON.Nullable<string>);
  83758. /**
  83759. * Checks for svg document with icon id present
  83760. */
  83761. private _svgCheck;
  83762. /**
  83763. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83764. * given external svg file and icon id
  83765. */
  83766. private _getSVGAttribs;
  83767. /**
  83768. * Gets or sets the cell width to use when animation sheet is enabled
  83769. * @see https://doc.babylonjs.com/how_to/gui#image
  83770. */
  83771. get cellWidth(): number;
  83772. set cellWidth(value: number);
  83773. /**
  83774. * Gets or sets the cell height to use when animation sheet is enabled
  83775. * @see https://doc.babylonjs.com/how_to/gui#image
  83776. */
  83777. get cellHeight(): number;
  83778. set cellHeight(value: number);
  83779. /**
  83780. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83781. * @see https://doc.babylonjs.com/how_to/gui#image
  83782. */
  83783. get cellId(): number;
  83784. set cellId(value: number);
  83785. /**
  83786. * Creates a new Image
  83787. * @param name defines the control name
  83788. * @param url defines the image url
  83789. */
  83790. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83791. /**
  83792. * Tests if a given coordinates belong to the current control
  83793. * @param x defines x coordinate to test
  83794. * @param y defines y coordinate to test
  83795. * @returns true if the coordinates are inside the control
  83796. */
  83797. contains(x: number, y: number): boolean;
  83798. protected _getTypeName(): string;
  83799. /** Force the control to synchronize with its content */
  83800. synchronizeSizeWithContent(): void;
  83801. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83802. private _prepareWorkingCanvasForOpaqueDetection;
  83803. private _drawImage;
  83804. _draw(context: CanvasRenderingContext2D): void;
  83805. private _renderCornerPatch;
  83806. private _renderNinePatch;
  83807. dispose(): void;
  83808. /** STRETCH_NONE */
  83809. static readonly STRETCH_NONE: number;
  83810. /** STRETCH_FILL */
  83811. static readonly STRETCH_FILL: number;
  83812. /** STRETCH_UNIFORM */
  83813. static readonly STRETCH_UNIFORM: number;
  83814. /** STRETCH_EXTEND */
  83815. static readonly STRETCH_EXTEND: number;
  83816. /** NINE_PATCH */
  83817. static readonly STRETCH_NINE_PATCH: number;
  83818. }
  83819. }
  83820. declare module BABYLON.GUI {
  83821. /**
  83822. * Class used to create 2D buttons
  83823. */
  83824. export class Button extends Rectangle {
  83825. name?: string | undefined;
  83826. /**
  83827. * Function called to generate a pointer enter animation
  83828. */
  83829. pointerEnterAnimation: () => void;
  83830. /**
  83831. * Function called to generate a pointer out animation
  83832. */
  83833. pointerOutAnimation: () => void;
  83834. /**
  83835. * Function called to generate a pointer down animation
  83836. */
  83837. pointerDownAnimation: () => void;
  83838. /**
  83839. * Function called to generate a pointer up animation
  83840. */
  83841. pointerUpAnimation: () => void;
  83842. /**
  83843. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83844. */
  83845. delegatePickingToChildren: boolean;
  83846. private _image;
  83847. /**
  83848. * Returns the image part of the button (if any)
  83849. */
  83850. get image(): BABYLON.Nullable<Image>;
  83851. private _textBlock;
  83852. /**
  83853. * Returns the image part of the button (if any)
  83854. */
  83855. get textBlock(): BABYLON.Nullable<TextBlock>;
  83856. /**
  83857. * Creates a new Button
  83858. * @param name defines the name of the button
  83859. */
  83860. constructor(name?: string | undefined);
  83861. protected _getTypeName(): string;
  83862. /** @hidden */
  83863. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83864. /** @hidden */
  83865. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83866. /** @hidden */
  83867. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  83868. /** @hidden */
  83869. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83870. /** @hidden */
  83871. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  83872. /**
  83873. * Creates a new button made with an image and a text
  83874. * @param name defines the name of the button
  83875. * @param text defines the text of the button
  83876. * @param imageUrl defines the url of the image
  83877. * @returns a new Button
  83878. */
  83879. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  83880. /**
  83881. * Creates a new button made with an image
  83882. * @param name defines the name of the button
  83883. * @param imageUrl defines the url of the image
  83884. * @returns a new Button
  83885. */
  83886. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  83887. /**
  83888. * Creates a new button made with a text
  83889. * @param name defines the name of the button
  83890. * @param text defines the text of the button
  83891. * @returns a new Button
  83892. */
  83893. static CreateSimpleButton(name: string, text: string): Button;
  83894. /**
  83895. * Creates a new button made with an image and a centered text
  83896. * @param name defines the name of the button
  83897. * @param text defines the text of the button
  83898. * @param imageUrl defines the url of the image
  83899. * @returns a new Button
  83900. */
  83901. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  83902. }
  83903. }
  83904. declare module BABYLON.GUI {
  83905. /**
  83906. * Class used to create a 2D stack panel container
  83907. */
  83908. export class StackPanel extends Container {
  83909. name?: string | undefined;
  83910. private _isVertical;
  83911. private _manualWidth;
  83912. private _manualHeight;
  83913. private _doNotTrackManualChanges;
  83914. /**
  83915. * Gets or sets a boolean indicating that layou warnings should be ignored
  83916. */
  83917. ignoreLayoutWarnings: boolean;
  83918. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  83919. get isVertical(): boolean;
  83920. set isVertical(value: boolean);
  83921. /**
  83922. * Gets or sets panel width.
  83923. * This value should not be set when in horizontal mode as it will be computed automatically
  83924. */
  83925. set width(value: string | number);
  83926. get width(): string | number;
  83927. /**
  83928. * Gets or sets panel height.
  83929. * This value should not be set when in vertical mode as it will be computed automatically
  83930. */
  83931. set height(value: string | number);
  83932. get height(): string | number;
  83933. /**
  83934. * Creates a new StackPanel
  83935. * @param name defines control name
  83936. */
  83937. constructor(name?: string | undefined);
  83938. protected _getTypeName(): string;
  83939. /** @hidden */
  83940. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83941. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83942. protected _postMeasure(): void;
  83943. /**
  83944. * Serializes the current control
  83945. * @param serializationObject defined the JSON serialized object
  83946. */
  83947. serialize(serializationObject: any): void;
  83948. /** @hidden */
  83949. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83950. }
  83951. }
  83952. declare module BABYLON.GUI {
  83953. /**
  83954. * Class used to represent a 2D checkbox
  83955. */
  83956. export class Checkbox extends Control {
  83957. name?: string | undefined;
  83958. private _isChecked;
  83959. private _background;
  83960. private _checkSizeRatio;
  83961. private _thickness;
  83962. /** Gets or sets border thickness */
  83963. get thickness(): number;
  83964. set thickness(value: number);
  83965. /**
  83966. * BABYLON.Observable raised when isChecked property changes
  83967. */
  83968. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  83969. /** Gets or sets a value indicating the ratio between overall size and check size */
  83970. get checkSizeRatio(): number;
  83971. set checkSizeRatio(value: number);
  83972. /** Gets or sets background color */
  83973. get background(): string;
  83974. set background(value: string);
  83975. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  83976. get isChecked(): boolean;
  83977. set isChecked(value: boolean);
  83978. /**
  83979. * Creates a new CheckBox
  83980. * @param name defines the control name
  83981. */
  83982. constructor(name?: string | undefined);
  83983. protected _getTypeName(): string;
  83984. /** @hidden */
  83985. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83986. /** @hidden */
  83987. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83988. /**
  83989. * Utility function to easily create a checkbox with a header
  83990. * @param title defines the label to use for the header
  83991. * @param onValueChanged defines the callback to call when value changes
  83992. * @returns a StackPanel containing the checkbox and a textBlock
  83993. */
  83994. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  83995. }
  83996. }
  83997. declare module BABYLON.GUI {
  83998. /**
  83999. * Class used to store key control properties
  84000. */
  84001. export class KeyPropertySet {
  84002. /** Width */
  84003. width?: string;
  84004. /** Height */
  84005. height?: string;
  84006. /** Left padding */
  84007. paddingLeft?: string;
  84008. /** Right padding */
  84009. paddingRight?: string;
  84010. /** Top padding */
  84011. paddingTop?: string;
  84012. /** Bottom padding */
  84013. paddingBottom?: string;
  84014. /** Foreground color */
  84015. color?: string;
  84016. /** Background color */
  84017. background?: string;
  84018. }
  84019. /**
  84020. * Class used to create virtual keyboard
  84021. */
  84022. export class VirtualKeyboard extends StackPanel {
  84023. /** BABYLON.Observable raised when a key is pressed */
  84024. onKeyPressObservable: BABYLON.Observable<string>;
  84025. /** Gets or sets default key button width */
  84026. defaultButtonWidth: string;
  84027. /** Gets or sets default key button height */
  84028. defaultButtonHeight: string;
  84029. /** Gets or sets default key button left padding */
  84030. defaultButtonPaddingLeft: string;
  84031. /** Gets or sets default key button right padding */
  84032. defaultButtonPaddingRight: string;
  84033. /** Gets or sets default key button top padding */
  84034. defaultButtonPaddingTop: string;
  84035. /** Gets or sets default key button bottom padding */
  84036. defaultButtonPaddingBottom: string;
  84037. /** Gets or sets default key button foreground color */
  84038. defaultButtonColor: string;
  84039. /** Gets or sets default key button background color */
  84040. defaultButtonBackground: string;
  84041. /** Gets or sets shift button foreground color */
  84042. shiftButtonColor: string;
  84043. /** Gets or sets shift button thickness*/
  84044. selectedShiftThickness: number;
  84045. /** Gets shift key state */
  84046. shiftState: number;
  84047. protected _getTypeName(): string;
  84048. private _createKey;
  84049. /**
  84050. * Adds a new row of keys
  84051. * @param keys defines the list of keys to add
  84052. * @param propertySets defines the associated property sets
  84053. */
  84054. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84055. /**
  84056. * Set the shift key to a specific state
  84057. * @param shiftState defines the new shift state
  84058. */
  84059. applyShiftState(shiftState: number): void;
  84060. private _currentlyConnectedInputText;
  84061. private _connectedInputTexts;
  84062. private _onKeyPressObserver;
  84063. /** Gets the input text control currently attached to the keyboard */
  84064. get connectedInputText(): BABYLON.Nullable<InputText>;
  84065. /**
  84066. * Connects the keyboard with an input text control
  84067. *
  84068. * @param input defines the target control
  84069. */
  84070. connect(input: InputText): void;
  84071. /**
  84072. * Disconnects the keyboard from connected InputText controls
  84073. *
  84074. * @param input optionally defines a target control, otherwise all are disconnected
  84075. */
  84076. disconnect(input?: InputText): void;
  84077. private _removeConnectedInputObservables;
  84078. /**
  84079. * Release all resources
  84080. */
  84081. dispose(): void;
  84082. /**
  84083. * Creates a new keyboard using a default layout
  84084. *
  84085. * @param name defines control name
  84086. * @returns a new VirtualKeyboard
  84087. */
  84088. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84089. }
  84090. }
  84091. declare module BABYLON.GUI {
  84092. /** @hidden */
  84093. export class TextWrapper {
  84094. private _text;
  84095. private _characters;
  84096. get text(): string;
  84097. set text(txt: string);
  84098. get length(): number;
  84099. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84100. charAt(idx: number): string;
  84101. substr(from: number, length?: number): string;
  84102. substring(from: number, to?: number): string;
  84103. isWord(index: number): boolean;
  84104. }
  84105. }
  84106. declare module BABYLON.GUI {
  84107. /**
  84108. * Class used to create input text control
  84109. */
  84110. export class InputText extends Control implements IFocusableControl {
  84111. name?: string | undefined;
  84112. private _textWrapper;
  84113. private _placeholderText;
  84114. private _background;
  84115. private _focusedBackground;
  84116. private _focusedColor;
  84117. private _placeholderColor;
  84118. private _thickness;
  84119. private _margin;
  84120. private _autoStretchWidth;
  84121. private _maxWidth;
  84122. private _isFocused;
  84123. private _blinkTimeout;
  84124. private _blinkIsEven;
  84125. private _cursorOffset;
  84126. private _scrollLeft;
  84127. private _textWidth;
  84128. private _clickedCoordinate;
  84129. private _deadKey;
  84130. private _addKey;
  84131. private _currentKey;
  84132. private _isTextHighlightOn;
  84133. private _textHighlightColor;
  84134. private _highligherOpacity;
  84135. private _highlightedText;
  84136. private _startHighlightIndex;
  84137. private _endHighlightIndex;
  84138. private _cursorIndex;
  84139. private _onFocusSelectAll;
  84140. private _isPointerDown;
  84141. private _onClipboardObserver;
  84142. private _onPointerDblTapObserver;
  84143. /** @hidden */
  84144. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84145. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84146. promptMessage: string;
  84147. /** Force disable prompt on mobile device */
  84148. disableMobilePrompt: boolean;
  84149. /** BABYLON.Observable raised when the text changes */
  84150. onTextChangedObservable: BABYLON.Observable<InputText>;
  84151. /** BABYLON.Observable raised just before an entered character is to be added */
  84152. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84153. /** BABYLON.Observable raised when the control gets the focus */
  84154. onFocusObservable: BABYLON.Observable<InputText>;
  84155. /** BABYLON.Observable raised when the control loses the focus */
  84156. onBlurObservable: BABYLON.Observable<InputText>;
  84157. /**Observable raised when the text is highlighted */
  84158. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84159. /**Observable raised when copy event is triggered */
  84160. onTextCopyObservable: BABYLON.Observable<InputText>;
  84161. /** BABYLON.Observable raised when cut event is triggered */
  84162. onTextCutObservable: BABYLON.Observable<InputText>;
  84163. /** BABYLON.Observable raised when paste event is triggered */
  84164. onTextPasteObservable: BABYLON.Observable<InputText>;
  84165. /** BABYLON.Observable raised when a key event was processed */
  84166. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84167. /** Gets or sets the maximum width allowed by the control */
  84168. get maxWidth(): string | number;
  84169. /** Gets the maximum width allowed by the control in pixels */
  84170. get maxWidthInPixels(): number;
  84171. set maxWidth(value: string | number);
  84172. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84173. get highligherOpacity(): number;
  84174. set highligherOpacity(value: number);
  84175. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84176. get onFocusSelectAll(): boolean;
  84177. set onFocusSelectAll(value: boolean);
  84178. /** Gets or sets the text hightlight color */
  84179. get textHighlightColor(): string;
  84180. set textHighlightColor(value: string);
  84181. /** Gets or sets control margin */
  84182. get margin(): string;
  84183. /** Gets control margin in pixels */
  84184. get marginInPixels(): number;
  84185. set margin(value: string);
  84186. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84187. get autoStretchWidth(): boolean;
  84188. set autoStretchWidth(value: boolean);
  84189. /** Gets or sets border thickness */
  84190. get thickness(): number;
  84191. set thickness(value: number);
  84192. /** Gets or sets the background color when focused */
  84193. get focusedBackground(): string;
  84194. set focusedBackground(value: string);
  84195. /** Gets or sets the background color when focused */
  84196. get focusedColor(): string;
  84197. set focusedColor(value: string);
  84198. /** Gets or sets the background color */
  84199. get background(): string;
  84200. set background(value: string);
  84201. /** Gets or sets the placeholder color */
  84202. get placeholderColor(): string;
  84203. set placeholderColor(value: string);
  84204. /** Gets or sets the text displayed when the control is empty */
  84205. get placeholderText(): string;
  84206. set placeholderText(value: string);
  84207. /** Gets or sets the dead key flag */
  84208. get deadKey(): boolean;
  84209. set deadKey(flag: boolean);
  84210. /** Gets or sets the highlight text */
  84211. get highlightedText(): string;
  84212. set highlightedText(text: string);
  84213. /** Gets or sets if the current key should be added */
  84214. get addKey(): boolean;
  84215. set addKey(flag: boolean);
  84216. /** Gets or sets the value of the current key being entered */
  84217. get currentKey(): string;
  84218. set currentKey(key: string);
  84219. /** Gets or sets the text displayed in the control */
  84220. get text(): string;
  84221. set text(value: string);
  84222. private _textHasChanged;
  84223. /** Gets or sets control width */
  84224. get width(): string | number;
  84225. set width(value: string | number);
  84226. /**
  84227. * Creates a new InputText
  84228. * @param name defines the control name
  84229. * @param text defines the text of the control
  84230. */
  84231. constructor(name?: string | undefined, text?: string);
  84232. /** @hidden */
  84233. onBlur(): void;
  84234. /** @hidden */
  84235. onFocus(): void;
  84236. /**
  84237. * Function to focus an inputText programmatically
  84238. */
  84239. focus(): void;
  84240. /**
  84241. * Function to unfocus an inputText programmatically
  84242. */
  84243. blur(): void;
  84244. protected _getTypeName(): string;
  84245. /**
  84246. * Function called to get the list of controls that should not steal the focus from this control
  84247. * @returns an array of controls
  84248. */
  84249. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84250. /** @hidden */
  84251. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84252. /** @hidden */
  84253. private _updateValueFromCursorIndex;
  84254. /** @hidden */
  84255. private _processDblClick;
  84256. /** @hidden */
  84257. private _selectAllText;
  84258. /**
  84259. * Handles the keyboard event
  84260. * @param evt Defines the KeyboardEvent
  84261. */
  84262. processKeyboard(evt: KeyboardEvent): void;
  84263. /** @hidden */
  84264. private _onCopyText;
  84265. /** @hidden */
  84266. private _onCutText;
  84267. /** @hidden */
  84268. private _onPasteText;
  84269. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84270. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84271. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84272. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84273. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84274. dispose(): void;
  84275. }
  84276. }
  84277. declare module BABYLON.GUI {
  84278. /**
  84279. * Class used to create a 2D grid container
  84280. */
  84281. export class Grid extends Container {
  84282. name?: string | undefined;
  84283. private _rowDefinitions;
  84284. private _columnDefinitions;
  84285. private _cells;
  84286. private _childControls;
  84287. /**
  84288. * Gets the number of columns
  84289. */
  84290. get columnCount(): number;
  84291. /**
  84292. * Gets the number of rows
  84293. */
  84294. get rowCount(): number;
  84295. /** Gets the list of children */
  84296. get children(): Control[];
  84297. /** Gets the list of cells (e.g. the containers) */
  84298. get cells(): {
  84299. [key: string]: Container;
  84300. };
  84301. /**
  84302. * Gets the definition of a specific row
  84303. * @param index defines the index of the row
  84304. * @returns the row definition
  84305. */
  84306. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84307. /**
  84308. * Gets the definition of a specific column
  84309. * @param index defines the index of the column
  84310. * @returns the column definition
  84311. */
  84312. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84313. /**
  84314. * Adds a new row to the grid
  84315. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84316. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84317. * @returns the current grid
  84318. */
  84319. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84320. /**
  84321. * Adds a new column to the grid
  84322. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84323. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84324. * @returns the current grid
  84325. */
  84326. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84327. /**
  84328. * Update a row definition
  84329. * @param index defines the index of the row to update
  84330. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84331. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84332. * @returns the current grid
  84333. */
  84334. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84335. /**
  84336. * Update a column definition
  84337. * @param index defines the index of the column to update
  84338. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84339. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84340. * @returns the current grid
  84341. */
  84342. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84343. /**
  84344. * Gets the list of children stored in a specific cell
  84345. * @param row defines the row to check
  84346. * @param column defines the column to check
  84347. * @returns the list of controls
  84348. */
  84349. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84350. /**
  84351. * Gets a string representing the child cell info (row x column)
  84352. * @param child defines the control to get info from
  84353. * @returns a string containing the child cell info (row x column)
  84354. */
  84355. getChildCellInfo(child: Control): string;
  84356. private _removeCell;
  84357. private _offsetCell;
  84358. /**
  84359. * Remove a column definition at specified index
  84360. * @param index defines the index of the column to remove
  84361. * @returns the current grid
  84362. */
  84363. removeColumnDefinition(index: number): Grid;
  84364. /**
  84365. * Remove a row definition at specified index
  84366. * @param index defines the index of the row to remove
  84367. * @returns the current grid
  84368. */
  84369. removeRowDefinition(index: number): Grid;
  84370. /**
  84371. * Adds a new control to the current grid
  84372. * @param control defines the control to add
  84373. * @param row defines the row where to add the control (0 by default)
  84374. * @param column defines the column where to add the control (0 by default)
  84375. * @returns the current grid
  84376. */
  84377. addControl(control: Control, row?: number, column?: number): Grid;
  84378. /**
  84379. * Removes a control from the current container
  84380. * @param control defines the control to remove
  84381. * @returns the current container
  84382. */
  84383. removeControl(control: Control): Container;
  84384. /**
  84385. * Creates a new Grid
  84386. * @param name defines control name
  84387. */
  84388. constructor(name?: string | undefined);
  84389. protected _getTypeName(): string;
  84390. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84391. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84392. _flagDescendantsAsMatrixDirty(): void;
  84393. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84394. /** Releases associated resources */
  84395. dispose(): void;
  84396. }
  84397. }
  84398. declare module BABYLON.GUI {
  84399. /** Class used to create color pickers */
  84400. export class ColorPicker extends Control {
  84401. name?: string | undefined;
  84402. private static _Epsilon;
  84403. private _colorWheelCanvas;
  84404. private _value;
  84405. private _tmpColor;
  84406. private _pointerStartedOnSquare;
  84407. private _pointerStartedOnWheel;
  84408. private _squareLeft;
  84409. private _squareTop;
  84410. private _squareSize;
  84411. private _h;
  84412. private _s;
  84413. private _v;
  84414. private _lastPointerDownID;
  84415. /**
  84416. * BABYLON.Observable raised when the value changes
  84417. */
  84418. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84419. /** Gets or sets the color of the color picker */
  84420. get value(): BABYLON.Color3;
  84421. set value(value: BABYLON.Color3);
  84422. /**
  84423. * Gets or sets control width
  84424. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84425. */
  84426. get width(): string | number;
  84427. set width(value: string | number);
  84428. /**
  84429. * Gets or sets control height
  84430. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84431. */
  84432. get height(): string | number;
  84433. /** Gets or sets control height */
  84434. set height(value: string | number);
  84435. /** Gets or sets control size */
  84436. get size(): string | number;
  84437. set size(value: string | number);
  84438. /**
  84439. * Creates a new ColorPicker
  84440. * @param name defines the control name
  84441. */
  84442. constructor(name?: string | undefined);
  84443. protected _getTypeName(): string;
  84444. /** @hidden */
  84445. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84446. private _updateSquareProps;
  84447. private _drawGradientSquare;
  84448. private _drawCircle;
  84449. private _createColorWheelCanvas;
  84450. /** @hidden */
  84451. _draw(context: CanvasRenderingContext2D): void;
  84452. private _pointerIsDown;
  84453. private _updateValueFromPointer;
  84454. private _isPointOnSquare;
  84455. private _isPointOnWheel;
  84456. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84457. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84458. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84459. _onCanvasBlur(): void;
  84460. /**
  84461. * This function expands the color picker by creating a color picker dialog with manual
  84462. * color value input and the ability to save colors into an array to be used later in
  84463. * subsequent launches of the dialogue.
  84464. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84465. * @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.
  84466. * @returns picked color as a hex string and the saved colors array as hex strings.
  84467. */
  84468. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84469. pickerWidth?: string;
  84470. pickerHeight?: string;
  84471. headerHeight?: string;
  84472. lastColor?: string;
  84473. swatchLimit?: number;
  84474. numSwatchesPerLine?: number;
  84475. savedColors?: Array<string>;
  84476. }): Promise<{
  84477. savedColors?: string[];
  84478. pickedColor: string;
  84479. }>;
  84480. }
  84481. }
  84482. declare module BABYLON.GUI {
  84483. /** Class used to create 2D ellipse containers */
  84484. export class Ellipse extends Container {
  84485. name?: string | undefined;
  84486. private _thickness;
  84487. /** Gets or sets border thickness */
  84488. get thickness(): number;
  84489. set thickness(value: number);
  84490. /**
  84491. * Creates a new Ellipse
  84492. * @param name defines the control name
  84493. */
  84494. constructor(name?: string | undefined);
  84495. protected _getTypeName(): string;
  84496. protected _localDraw(context: CanvasRenderingContext2D): void;
  84497. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84498. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84499. }
  84500. }
  84501. declare module BABYLON.GUI {
  84502. /**
  84503. * Class used to create a focusable button that can easily handle keyboard events
  84504. */
  84505. export class FocusableButton extends Button implements IFocusableControl {
  84506. name?: string | undefined;
  84507. /** Highlight color when button is focused */
  84508. focusedColor: BABYLON.Nullable<string>;
  84509. private _isFocused;
  84510. private _unfocusedColor;
  84511. /** BABYLON.Observable raised when the control gets the focus */
  84512. onFocusObservable: BABYLON.Observable<Button>;
  84513. /** BABYLON.Observable raised when the control loses the focus */
  84514. onBlurObservable: BABYLON.Observable<Button>;
  84515. /** BABYLON.Observable raised when a key event was processed */
  84516. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84517. constructor(name?: string | undefined);
  84518. /** @hidden */
  84519. onBlur(): void;
  84520. /** @hidden */
  84521. onFocus(): void;
  84522. /**
  84523. * Function called to get the list of controls that should not steal the focus from this control
  84524. * @returns an array of controls
  84525. */
  84526. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84527. /**
  84528. * Function to focus a button programmatically
  84529. */
  84530. focus(): void;
  84531. /**
  84532. * Function to unfocus a button programmatically
  84533. */
  84534. blur(): void;
  84535. /**
  84536. * Handles the keyboard event
  84537. * @param evt Defines the KeyboardEvent
  84538. */
  84539. processKeyboard(evt: KeyboardEvent): void;
  84540. /** @hidden */
  84541. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84542. /** @hidden */
  84543. displose(): void;
  84544. }
  84545. }
  84546. declare module BABYLON.GUI {
  84547. /**
  84548. * Class used to create a password control
  84549. */
  84550. export class InputPassword extends InputText {
  84551. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84552. }
  84553. }
  84554. declare module BABYLON.GUI {
  84555. /** Class used to render 2D lines */
  84556. export class Line extends Control {
  84557. name?: string | undefined;
  84558. private _lineWidth;
  84559. private _x1;
  84560. private _y1;
  84561. private _x2;
  84562. private _y2;
  84563. private _dash;
  84564. private _connectedControl;
  84565. private _connectedControlDirtyObserver;
  84566. /** Gets or sets the dash pattern */
  84567. get dash(): Array<number>;
  84568. set dash(value: Array<number>);
  84569. /** Gets or sets the control connected with the line end */
  84570. get connectedControl(): Control;
  84571. set connectedControl(value: Control);
  84572. /** Gets or sets start coordinates on X axis */
  84573. get x1(): string | number;
  84574. set x1(value: string | number);
  84575. /** Gets or sets start coordinates on Y axis */
  84576. get y1(): string | number;
  84577. set y1(value: string | number);
  84578. /** Gets or sets end coordinates on X axis */
  84579. get x2(): string | number;
  84580. set x2(value: string | number);
  84581. /** Gets or sets end coordinates on Y axis */
  84582. get y2(): string | number;
  84583. set y2(value: string | number);
  84584. /** Gets or sets line width */
  84585. get lineWidth(): number;
  84586. set lineWidth(value: number);
  84587. /** Gets or sets horizontal alignment */
  84588. set horizontalAlignment(value: number);
  84589. /** Gets or sets vertical alignment */
  84590. set verticalAlignment(value: number);
  84591. private get _effectiveX2();
  84592. private get _effectiveY2();
  84593. /**
  84594. * Creates a new Line
  84595. * @param name defines the control name
  84596. */
  84597. constructor(name?: string | undefined);
  84598. protected _getTypeName(): string;
  84599. _draw(context: CanvasRenderingContext2D): void;
  84600. _measure(): void;
  84601. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84602. /**
  84603. * Move one end of the line given 3D cartesian coordinates.
  84604. * @param position Targeted world position
  84605. * @param scene BABYLON.Scene
  84606. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84607. */
  84608. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84609. /**
  84610. * Move one end of the line to a position in screen absolute space.
  84611. * @param projectedPosition Position in screen absolute space (X, Y)
  84612. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84613. */
  84614. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84615. }
  84616. }
  84617. declare module BABYLON.GUI {
  84618. /**
  84619. * Class used to store a point for a MultiLine object.
  84620. * The point can be pure 2D coordinates, a mesh or a control
  84621. */
  84622. export class MultiLinePoint {
  84623. private _multiLine;
  84624. private _x;
  84625. private _y;
  84626. private _control;
  84627. private _mesh;
  84628. private _controlObserver;
  84629. private _meshObserver;
  84630. /** @hidden */
  84631. _point: BABYLON.Vector3;
  84632. /**
  84633. * Creates a new MultiLinePoint
  84634. * @param multiLine defines the source MultiLine object
  84635. */
  84636. constructor(multiLine: MultiLine);
  84637. /** Gets or sets x coordinate */
  84638. get x(): string | number;
  84639. set x(value: string | number);
  84640. /** Gets or sets y coordinate */
  84641. get y(): string | number;
  84642. set y(value: string | number);
  84643. /** Gets or sets the control associated with this point */
  84644. get control(): BABYLON.Nullable<Control>;
  84645. set control(value: BABYLON.Nullable<Control>);
  84646. /** Gets or sets the mesh associated with this point */
  84647. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84648. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84649. /** Resets links */
  84650. resetLinks(): void;
  84651. /**
  84652. * Gets a translation vector with Z component
  84653. * @returns the translation vector
  84654. */
  84655. translate(): BABYLON.Vector3;
  84656. private _translatePoint;
  84657. /** Release associated resources */
  84658. dispose(): void;
  84659. }
  84660. }
  84661. declare module BABYLON.GUI {
  84662. /**
  84663. * Class used to create multi line control
  84664. */
  84665. export class MultiLine extends Control {
  84666. name?: string | undefined;
  84667. private _lineWidth;
  84668. private _dash;
  84669. private _points;
  84670. private _minX;
  84671. private _minY;
  84672. private _maxX;
  84673. private _maxY;
  84674. /**
  84675. * Creates a new MultiLine
  84676. * @param name defines the control name
  84677. */
  84678. constructor(name?: string | undefined);
  84679. /** Gets or sets dash pattern */
  84680. get dash(): Array<number>;
  84681. set dash(value: Array<number>);
  84682. /**
  84683. * Gets point stored at specified index
  84684. * @param index defines the index to look for
  84685. * @returns the requested point if found
  84686. */
  84687. getAt(index: number): MultiLinePoint;
  84688. /** Function called when a point is updated */
  84689. onPointUpdate: () => void;
  84690. /**
  84691. * Adds new points to the point collection
  84692. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84693. * @returns the list of created MultiLinePoint
  84694. */
  84695. add(...items: (AbstractMesh | Control | {
  84696. x: string | number;
  84697. y: string | number;
  84698. })[]): MultiLinePoint[];
  84699. /**
  84700. * Adds a new point to the point collection
  84701. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84702. * @returns the created MultiLinePoint
  84703. */
  84704. push(item?: (AbstractMesh | Control | {
  84705. x: string | number;
  84706. y: string | number;
  84707. })): MultiLinePoint;
  84708. /**
  84709. * Remove a specific value or point from the active point collection
  84710. * @param value defines the value or point to remove
  84711. */
  84712. remove(value: number | MultiLinePoint): void;
  84713. /**
  84714. * Resets this object to initial state (no point)
  84715. */
  84716. reset(): void;
  84717. /**
  84718. * Resets all links
  84719. */
  84720. resetLinks(): void;
  84721. /** Gets or sets line width */
  84722. get lineWidth(): number;
  84723. set lineWidth(value: number);
  84724. set horizontalAlignment(value: number);
  84725. set verticalAlignment(value: number);
  84726. protected _getTypeName(): string;
  84727. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84728. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84729. _measure(): void;
  84730. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84731. dispose(): void;
  84732. }
  84733. }
  84734. declare module BABYLON.GUI {
  84735. /**
  84736. * Class used to create radio button controls
  84737. */
  84738. export class RadioButton extends Control {
  84739. name?: string | undefined;
  84740. private _isChecked;
  84741. private _background;
  84742. private _checkSizeRatio;
  84743. private _thickness;
  84744. /** Gets or sets border thickness */
  84745. get thickness(): number;
  84746. set thickness(value: number);
  84747. /** Gets or sets group name */
  84748. group: string;
  84749. /** BABYLON.Observable raised when isChecked is changed */
  84750. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84751. /** Gets or sets a value indicating the ratio between overall size and check size */
  84752. get checkSizeRatio(): number;
  84753. set checkSizeRatio(value: number);
  84754. /** Gets or sets background color */
  84755. get background(): string;
  84756. set background(value: string);
  84757. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84758. get isChecked(): boolean;
  84759. set isChecked(value: boolean);
  84760. /**
  84761. * Creates a new RadioButton
  84762. * @param name defines the control name
  84763. */
  84764. constructor(name?: string | undefined);
  84765. protected _getTypeName(): string;
  84766. _draw(context: CanvasRenderingContext2D): void;
  84767. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84768. /**
  84769. * Utility function to easily create a radio button with a header
  84770. * @param title defines the label to use for the header
  84771. * @param group defines the group to use for the radio button
  84772. * @param isChecked defines the initial state of the radio button
  84773. * @param onValueChanged defines the callback to call when value changes
  84774. * @returns a StackPanel containing the radio button and a textBlock
  84775. */
  84776. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84777. }
  84778. }
  84779. declare module BABYLON.GUI {
  84780. /**
  84781. * Class used to create slider controls
  84782. */
  84783. export class BaseSlider extends Control {
  84784. name?: string | undefined;
  84785. protected _thumbWidth: ValueAndUnit;
  84786. private _minimum;
  84787. private _maximum;
  84788. private _value;
  84789. private _isVertical;
  84790. protected _barOffset: ValueAndUnit;
  84791. private _isThumbClamped;
  84792. protected _displayThumb: boolean;
  84793. private _step;
  84794. private _lastPointerDownID;
  84795. protected _effectiveBarOffset: number;
  84796. protected _renderLeft: number;
  84797. protected _renderTop: number;
  84798. protected _renderWidth: number;
  84799. protected _renderHeight: number;
  84800. protected _backgroundBoxLength: number;
  84801. protected _backgroundBoxThickness: number;
  84802. protected _effectiveThumbThickness: number;
  84803. /** BABYLON.Observable raised when the sldier value changes */
  84804. onValueChangedObservable: BABYLON.Observable<number>;
  84805. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84806. get displayThumb(): boolean;
  84807. set displayThumb(value: boolean);
  84808. /** Gets or sets a step to apply to values (0 by default) */
  84809. get step(): number;
  84810. set step(value: number);
  84811. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84812. get barOffset(): string | number;
  84813. /** Gets main bar offset in pixels*/
  84814. get barOffsetInPixels(): number;
  84815. set barOffset(value: string | number);
  84816. /** Gets or sets thumb width */
  84817. get thumbWidth(): string | number;
  84818. /** Gets thumb width in pixels */
  84819. get thumbWidthInPixels(): number;
  84820. set thumbWidth(value: string | number);
  84821. /** Gets or sets minimum value */
  84822. get minimum(): number;
  84823. set minimum(value: number);
  84824. /** Gets or sets maximum value */
  84825. get maximum(): number;
  84826. set maximum(value: number);
  84827. /** Gets or sets current value */
  84828. get value(): number;
  84829. set value(value: number);
  84830. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84831. get isVertical(): boolean;
  84832. set isVertical(value: boolean);
  84833. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84834. get isThumbClamped(): boolean;
  84835. set isThumbClamped(value: boolean);
  84836. /**
  84837. * Creates a new BaseSlider
  84838. * @param name defines the control name
  84839. */
  84840. constructor(name?: string | undefined);
  84841. protected _getTypeName(): string;
  84842. protected _getThumbPosition(): number;
  84843. protected _getThumbThickness(type: string): number;
  84844. protected _prepareRenderingData(type: string): void;
  84845. private _pointerIsDown;
  84846. /** @hidden */
  84847. protected _updateValueFromPointer(x: number, y: number): void;
  84848. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84849. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84850. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84851. _onCanvasBlur(): void;
  84852. }
  84853. }
  84854. declare module BABYLON.GUI {
  84855. /**
  84856. * Class used to create slider controls
  84857. */
  84858. export class Slider extends BaseSlider {
  84859. name?: string | undefined;
  84860. private _background;
  84861. private _borderColor;
  84862. private _thumbColor;
  84863. private _isThumbCircle;
  84864. protected _displayValueBar: boolean;
  84865. /** Gets or sets a boolean indicating if the value bar must be rendered */
  84866. get displayValueBar(): boolean;
  84867. set displayValueBar(value: boolean);
  84868. /** Gets or sets border color */
  84869. get borderColor(): string;
  84870. set borderColor(value: string);
  84871. /** Gets or sets background color */
  84872. get background(): string;
  84873. set background(value: string);
  84874. /** Gets or sets thumb's color */
  84875. get thumbColor(): string;
  84876. set thumbColor(value: string);
  84877. /** Gets or sets a boolean indicating if the thumb should be round or square */
  84878. get isThumbCircle(): boolean;
  84879. set isThumbCircle(value: boolean);
  84880. /**
  84881. * Creates a new Slider
  84882. * @param name defines the control name
  84883. */
  84884. constructor(name?: string | undefined);
  84885. protected _getTypeName(): string;
  84886. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84887. }
  84888. }
  84889. declare module BABYLON.GUI {
  84890. /** Class used to create a RadioGroup
  84891. * which contains groups of radio buttons
  84892. */
  84893. export class SelectorGroup {
  84894. /** name of SelectorGroup */
  84895. name: string;
  84896. private _groupPanel;
  84897. private _selectors;
  84898. private _groupHeader;
  84899. /**
  84900. * Creates a new SelectorGroup
  84901. * @param name of group, used as a group heading
  84902. */
  84903. constructor(
  84904. /** name of SelectorGroup */
  84905. name: string);
  84906. /** Gets the groupPanel of the SelectorGroup */
  84907. get groupPanel(): StackPanel;
  84908. /** Gets the selectors array */
  84909. get selectors(): StackPanel[];
  84910. /** Gets and sets the group header */
  84911. get header(): string;
  84912. set header(label: string);
  84913. /** @hidden */
  84914. private _addGroupHeader;
  84915. /** @hidden*/
  84916. _getSelector(selectorNb: number): StackPanel | undefined;
  84917. /** Removes the selector at the given position
  84918. * @param selectorNb the position of the selector within the group
  84919. */
  84920. removeSelector(selectorNb: number): void;
  84921. }
  84922. /** Class used to create a CheckboxGroup
  84923. * which contains groups of checkbox buttons
  84924. */
  84925. export class CheckboxGroup extends SelectorGroup {
  84926. /** Adds a checkbox as a control
  84927. * @param text is the label for the selector
  84928. * @param func is the function called when the Selector is checked
  84929. * @param checked is true when Selector is checked
  84930. */
  84931. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  84932. /** @hidden */
  84933. _setSelectorLabel(selectorNb: number, label: string): void;
  84934. /** @hidden */
  84935. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84936. /** @hidden */
  84937. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84938. /** @hidden */
  84939. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84940. }
  84941. /** Class used to create a RadioGroup
  84942. * which contains groups of radio buttons
  84943. */
  84944. export class RadioGroup extends SelectorGroup {
  84945. private _selectNb;
  84946. /** Adds a radio button as a control
  84947. * @param label is the label for the selector
  84948. * @param func is the function called when the Selector is checked
  84949. * @param checked is true when Selector is checked
  84950. */
  84951. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  84952. /** @hidden */
  84953. _setSelectorLabel(selectorNb: number, label: string): void;
  84954. /** @hidden */
  84955. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84956. /** @hidden */
  84957. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84958. /** @hidden */
  84959. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84960. }
  84961. /** Class used to create a SliderGroup
  84962. * which contains groups of slider buttons
  84963. */
  84964. export class SliderGroup extends SelectorGroup {
  84965. /**
  84966. * Adds a slider to the SelectorGroup
  84967. * @param label is the label for the SliderBar
  84968. * @param func is the function called when the Slider moves
  84969. * @param unit is a string describing the units used, eg degrees or metres
  84970. * @param min is the minimum value for the Slider
  84971. * @param max is the maximum value for the Slider
  84972. * @param value is the start value for the Slider between min and max
  84973. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  84974. */
  84975. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  84976. /** @hidden */
  84977. _setSelectorLabel(selectorNb: number, label: string): void;
  84978. /** @hidden */
  84979. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84980. /** @hidden */
  84981. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84982. /** @hidden */
  84983. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84984. }
  84985. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  84986. * @see https://doc.babylonjs.com/how_to/selector
  84987. */
  84988. export class SelectionPanel extends Rectangle {
  84989. /** name of SelectionPanel */
  84990. name: string;
  84991. /** an array of SelectionGroups */
  84992. groups: SelectorGroup[];
  84993. private _panel;
  84994. private _buttonColor;
  84995. private _buttonBackground;
  84996. private _headerColor;
  84997. private _barColor;
  84998. private _barHeight;
  84999. private _spacerHeight;
  85000. private _labelColor;
  85001. private _groups;
  85002. private _bars;
  85003. /**
  85004. * Creates a new SelectionPanel
  85005. * @param name of SelectionPanel
  85006. * @param groups is an array of SelectionGroups
  85007. */
  85008. constructor(
  85009. /** name of SelectionPanel */
  85010. name: string,
  85011. /** an array of SelectionGroups */
  85012. groups?: SelectorGroup[]);
  85013. protected _getTypeName(): string;
  85014. /** Gets the (stack) panel of the SelectionPanel */
  85015. get panel(): StackPanel;
  85016. /** Gets or sets the headerColor */
  85017. get headerColor(): string;
  85018. set headerColor(color: string);
  85019. private _setHeaderColor;
  85020. /** Gets or sets the button color */
  85021. get buttonColor(): string;
  85022. set buttonColor(color: string);
  85023. private _setbuttonColor;
  85024. /** Gets or sets the label color */
  85025. get labelColor(): string;
  85026. set labelColor(color: string);
  85027. private _setLabelColor;
  85028. /** Gets or sets the button background */
  85029. get buttonBackground(): string;
  85030. set buttonBackground(color: string);
  85031. private _setButtonBackground;
  85032. /** Gets or sets the color of separator bar */
  85033. get barColor(): string;
  85034. set barColor(color: string);
  85035. private _setBarColor;
  85036. /** Gets or sets the height of separator bar */
  85037. get barHeight(): string;
  85038. set barHeight(value: string);
  85039. private _setBarHeight;
  85040. /** Gets or sets the height of spacers*/
  85041. get spacerHeight(): string;
  85042. set spacerHeight(value: string);
  85043. private _setSpacerHeight;
  85044. /** Adds a bar between groups */
  85045. private _addSpacer;
  85046. /** Add a group to the selection panel
  85047. * @param group is the selector group to add
  85048. */
  85049. addGroup(group: SelectorGroup): void;
  85050. /** Remove the group from the given position
  85051. * @param groupNb is the position of the group in the list
  85052. */
  85053. removeGroup(groupNb: number): void;
  85054. /** Change a group header label
  85055. * @param label is the new group header label
  85056. * @param groupNb is the number of the group to relabel
  85057. * */
  85058. setHeaderName(label: string, groupNb: number): void;
  85059. /** Change selector label to the one given
  85060. * @param label is the new selector label
  85061. * @param groupNb is the number of the groupcontaining the selector
  85062. * @param selectorNb is the number of the selector within a group to relabel
  85063. * */
  85064. relabel(label: string, groupNb: number, selectorNb: number): void;
  85065. /** For a given group position remove the selector at the given position
  85066. * @param groupNb is the number of the group to remove the selector from
  85067. * @param selectorNb is the number of the selector within the group
  85068. */
  85069. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85070. /** For a given group position of correct type add a checkbox button
  85071. * @param groupNb is the number of the group to remove the selector from
  85072. * @param label is the label for the selector
  85073. * @param func is the function called when the Selector is checked
  85074. * @param checked is true when Selector is checked
  85075. */
  85076. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85077. /** For a given group position of correct type add a radio button
  85078. * @param groupNb is the number of the group to remove the selector from
  85079. * @param label is the label for the selector
  85080. * @param func is the function called when the Selector is checked
  85081. * @param checked is true when Selector is checked
  85082. */
  85083. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85084. /**
  85085. * For a given slider group add a slider
  85086. * @param groupNb is the number of the group to add the slider to
  85087. * @param label is the label for the Slider
  85088. * @param func is the function called when the Slider moves
  85089. * @param unit is a string describing the units used, eg degrees or metres
  85090. * @param min is the minimum value for the Slider
  85091. * @param max is the maximum value for the Slider
  85092. * @param value is the start value for the Slider between min and max
  85093. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85094. */
  85095. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85096. }
  85097. }
  85098. declare module BABYLON.GUI {
  85099. /**
  85100. * Class used to hold a the container for ScrollViewer
  85101. * @hidden
  85102. */
  85103. export class _ScrollViewerWindow extends Container {
  85104. parentClientWidth: number;
  85105. parentClientHeight: number;
  85106. private _freezeControls;
  85107. private _parentMeasure;
  85108. private _oldLeft;
  85109. private _oldTop;
  85110. get freezeControls(): boolean;
  85111. set freezeControls(value: boolean);
  85112. private _bucketWidth;
  85113. private _bucketHeight;
  85114. private _buckets;
  85115. private _bucketLen;
  85116. get bucketWidth(): number;
  85117. get bucketHeight(): number;
  85118. setBucketSizes(width: number, height: number): void;
  85119. private _useBuckets;
  85120. private _makeBuckets;
  85121. private _dispatchInBuckets;
  85122. private _updateMeasures;
  85123. private _updateChildrenMeasures;
  85124. private _restoreMeasures;
  85125. /**
  85126. * Creates a new ScrollViewerWindow
  85127. * @param name of ScrollViewerWindow
  85128. */
  85129. constructor(name?: string);
  85130. protected _getTypeName(): string;
  85131. /** @hidden */
  85132. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85133. /** @hidden */
  85134. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85135. private _scrollChildren;
  85136. private _scrollChildrenWithBuckets;
  85137. /** @hidden */
  85138. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85139. protected _postMeasure(): void;
  85140. }
  85141. }
  85142. declare module BABYLON.GUI {
  85143. /**
  85144. * Class used to create slider controls
  85145. */
  85146. export class ScrollBar extends BaseSlider {
  85147. name?: string | undefined;
  85148. private _background;
  85149. private _borderColor;
  85150. private _tempMeasure;
  85151. /** Gets or sets border color */
  85152. get borderColor(): string;
  85153. set borderColor(value: string);
  85154. /** Gets or sets background color */
  85155. get background(): string;
  85156. set background(value: string);
  85157. /**
  85158. * Creates a new Slider
  85159. * @param name defines the control name
  85160. */
  85161. constructor(name?: string | undefined);
  85162. protected _getTypeName(): string;
  85163. protected _getThumbThickness(): number;
  85164. _draw(context: CanvasRenderingContext2D): void;
  85165. private _first;
  85166. private _originX;
  85167. private _originY;
  85168. /** @hidden */
  85169. protected _updateValueFromPointer(x: number, y: number): void;
  85170. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85171. }
  85172. }
  85173. declare module BABYLON.GUI {
  85174. /**
  85175. * Class used to create slider controls
  85176. */
  85177. export class ImageScrollBar extends BaseSlider {
  85178. name?: string | undefined;
  85179. private _backgroundBaseImage;
  85180. private _backgroundImage;
  85181. private _thumbImage;
  85182. private _thumbBaseImage;
  85183. private _thumbLength;
  85184. private _thumbHeight;
  85185. private _barImageHeight;
  85186. private _tempMeasure;
  85187. /** Number of 90° rotation to apply on the images when in vertical mode */
  85188. num90RotationInVerticalMode: number;
  85189. /**
  85190. * Gets or sets the image used to render the background for horizontal bar
  85191. */
  85192. get backgroundImage(): Image;
  85193. set backgroundImage(value: Image);
  85194. /**
  85195. * Gets or sets the image used to render the thumb
  85196. */
  85197. get thumbImage(): Image;
  85198. set thumbImage(value: Image);
  85199. /**
  85200. * Gets or sets the length of the thumb
  85201. */
  85202. get thumbLength(): number;
  85203. set thumbLength(value: number);
  85204. /**
  85205. * Gets or sets the height of the thumb
  85206. */
  85207. get thumbHeight(): number;
  85208. set thumbHeight(value: number);
  85209. /**
  85210. * Gets or sets the height of the bar image
  85211. */
  85212. get barImageHeight(): number;
  85213. set barImageHeight(value: number);
  85214. /**
  85215. * Creates a new ImageScrollBar
  85216. * @param name defines the control name
  85217. */
  85218. constructor(name?: string | undefined);
  85219. protected _getTypeName(): string;
  85220. protected _getThumbThickness(): number;
  85221. _draw(context: CanvasRenderingContext2D): void;
  85222. private _first;
  85223. private _originX;
  85224. private _originY;
  85225. /** @hidden */
  85226. protected _updateValueFromPointer(x: number, y: number): void;
  85227. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85228. }
  85229. }
  85230. declare module BABYLON.GUI {
  85231. /**
  85232. * Class used to hold a viewer window and sliders in a grid
  85233. */
  85234. export class ScrollViewer extends Rectangle {
  85235. private _grid;
  85236. private _horizontalBarSpace;
  85237. private _verticalBarSpace;
  85238. private _dragSpace;
  85239. private _horizontalBar;
  85240. private _verticalBar;
  85241. private _barColor;
  85242. private _barBackground;
  85243. private _barImage;
  85244. private _horizontalBarImage;
  85245. private _verticalBarImage;
  85246. private _barBackgroundImage;
  85247. private _horizontalBarBackgroundImage;
  85248. private _verticalBarBackgroundImage;
  85249. private _barSize;
  85250. private _window;
  85251. private _pointerIsOver;
  85252. private _wheelPrecision;
  85253. private _onWheelObserver;
  85254. private _clientWidth;
  85255. private _clientHeight;
  85256. private _useImageBar;
  85257. private _thumbLength;
  85258. private _thumbHeight;
  85259. private _barImageHeight;
  85260. private _horizontalBarImageHeight;
  85261. private _verticalBarImageHeight;
  85262. private _oldWindowContentsWidth;
  85263. private _oldWindowContentsHeight;
  85264. /**
  85265. * Gets the horizontal scrollbar
  85266. */
  85267. get horizontalBar(): ScrollBar | ImageScrollBar;
  85268. /**
  85269. * Gets the vertical scrollbar
  85270. */
  85271. get verticalBar(): ScrollBar | ImageScrollBar;
  85272. /**
  85273. * Adds a new control to the current container
  85274. * @param control defines the control to add
  85275. * @returns the current container
  85276. */
  85277. addControl(control: BABYLON.Nullable<Control>): Container;
  85278. /**
  85279. * Removes a control from the current container
  85280. * @param control defines the control to remove
  85281. * @returns the current container
  85282. */
  85283. removeControl(control: Control): Container;
  85284. /** Gets the list of children */
  85285. get children(): Control[];
  85286. _flagDescendantsAsMatrixDirty(): void;
  85287. /**
  85288. * Freezes or unfreezes the controls in the window.
  85289. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85290. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85291. */
  85292. get freezeControls(): boolean;
  85293. set freezeControls(value: boolean);
  85294. /** Gets the bucket width */
  85295. get bucketWidth(): number;
  85296. /** Gets the bucket height */
  85297. get bucketHeight(): number;
  85298. /**
  85299. * Sets the bucket sizes.
  85300. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85301. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85302. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85303. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85304. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85305. * used), that's why it is not enabled by default.
  85306. * @param width width of the bucket
  85307. * @param height height of the bucket
  85308. */
  85309. setBucketSizes(width: number, height: number): void;
  85310. private _forceHorizontalBar;
  85311. private _forceVerticalBar;
  85312. /**
  85313. * Forces the horizontal scroll bar to be displayed
  85314. */
  85315. get forceHorizontalBar(): boolean;
  85316. set forceHorizontalBar(value: boolean);
  85317. /**
  85318. * Forces the vertical scroll bar to be displayed
  85319. */
  85320. get forceVerticalBar(): boolean;
  85321. set forceVerticalBar(value: boolean);
  85322. /**
  85323. * Creates a new ScrollViewer
  85324. * @param name of ScrollViewer
  85325. */
  85326. constructor(name?: string, isImageBased?: boolean);
  85327. /** Reset the scroll viewer window to initial size */
  85328. resetWindow(): void;
  85329. protected _getTypeName(): string;
  85330. private _buildClientSizes;
  85331. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85332. protected _postMeasure(): void;
  85333. /**
  85334. * Gets or sets the mouse wheel precision
  85335. * from 0 to 1 with a default value of 0.05
  85336. * */
  85337. get wheelPrecision(): number;
  85338. set wheelPrecision(value: number);
  85339. /** Gets or sets the scroll bar container background color */
  85340. get scrollBackground(): string;
  85341. set scrollBackground(color: string);
  85342. /** Gets or sets the bar color */
  85343. get barColor(): string;
  85344. set barColor(color: string);
  85345. /** Gets or sets the bar image */
  85346. get thumbImage(): Image;
  85347. set thumbImage(value: Image);
  85348. /** Gets or sets the horizontal bar image */
  85349. get horizontalThumbImage(): Image;
  85350. set horizontalThumbImage(value: Image);
  85351. /** Gets or sets the vertical bar image */
  85352. get verticalThumbImage(): Image;
  85353. set verticalThumbImage(value: Image);
  85354. /** Gets or sets the size of the bar */
  85355. get barSize(): number;
  85356. set barSize(value: number);
  85357. /** Gets or sets the length of the thumb */
  85358. get thumbLength(): number;
  85359. set thumbLength(value: number);
  85360. /** Gets or sets the height of the thumb */
  85361. get thumbHeight(): number;
  85362. set thumbHeight(value: number);
  85363. /** Gets or sets the height of the bar image */
  85364. get barImageHeight(): number;
  85365. set barImageHeight(value: number);
  85366. /** Gets or sets the height of the horizontal bar image */
  85367. get horizontalBarImageHeight(): number;
  85368. set horizontalBarImageHeight(value: number);
  85369. /** Gets or sets the height of the vertical bar image */
  85370. get verticalBarImageHeight(): number;
  85371. set verticalBarImageHeight(value: number);
  85372. /** Gets or sets the bar background */
  85373. get barBackground(): string;
  85374. set barBackground(color: string);
  85375. /** Gets or sets the bar background image */
  85376. get barImage(): Image;
  85377. set barImage(value: Image);
  85378. /** Gets or sets the horizontal bar background image */
  85379. get horizontalBarImage(): Image;
  85380. set horizontalBarImage(value: Image);
  85381. /** Gets or sets the vertical bar background image */
  85382. get verticalBarImage(): Image;
  85383. set verticalBarImage(value: Image);
  85384. private _setWindowPosition;
  85385. /** @hidden */
  85386. private _updateScroller;
  85387. _link(host: AdvancedDynamicTexture): void;
  85388. /** @hidden */
  85389. private _addBar;
  85390. /** @hidden */
  85391. private _attachWheel;
  85392. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85393. /** Releases associated resources */
  85394. dispose(): void;
  85395. }
  85396. }
  85397. declare module BABYLON.GUI {
  85398. /**
  85399. * Class used to create toggle buttons
  85400. */
  85401. export class ToggleButton extends Rectangle {
  85402. name?: string | undefined;
  85403. /**
  85404. * Function called to generate the toActive animation
  85405. */
  85406. toActiveAnimation: () => void;
  85407. /**
  85408. * Function called to generate the toInactive animation
  85409. */
  85410. toInactiveAnimation: () => void;
  85411. /**
  85412. * Function called to generate a pointer enter animation when the toggle button is active.
  85413. */
  85414. pointerEnterActiveAnimation: () => void;
  85415. /**
  85416. * Function called to generate a pointer out animation when the toggle button is active.
  85417. */
  85418. pointerOutActiveAnimation: () => void;
  85419. /**
  85420. * Function called to generate a pointer down animation when the toggle button is active.
  85421. */
  85422. pointerDownActiveAnimation: () => void;
  85423. /**
  85424. * Function called to generate a pointer up animation when the toggle button is active.
  85425. */
  85426. pointerUpActiveAnimation: () => void;
  85427. /**
  85428. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85429. */
  85430. pointerEnterInactiveAnimation: () => void;
  85431. /**
  85432. * Function called to generate a pointer out animation when the toggle button is inactive.
  85433. */
  85434. pointerOutInactiveAnimation: () => void;
  85435. /**
  85436. * Function called to generate a pointer down animation when the toggle button is inactive.
  85437. */
  85438. pointerDownInactiveAnimation: () => void;
  85439. /**
  85440. * Function called to generate a pointer up animation when the toggle button is inactive.
  85441. */
  85442. pointerUpInactiveAnimation: () => void;
  85443. /** BABYLON.Observable raised when isActive is changed */
  85444. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85445. /**
  85446. * 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
  85447. */
  85448. delegatePickingToChildren: boolean;
  85449. private _image;
  85450. /**
  85451. * Returns the ToggleButton's image control if it exists
  85452. */
  85453. get image(): BABYLON.Nullable<Image>;
  85454. private _textBlock;
  85455. /**
  85456. * Returns the ToggleButton's child TextBlock control if it exists
  85457. */
  85458. get textBlock(): BABYLON.Nullable<TextBlock>;
  85459. private _group;
  85460. /** Gets or sets group name this toggle button belongs to */
  85461. get group(): string;
  85462. set group(value: string);
  85463. private _isActive;
  85464. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85465. get isActive(): boolean;
  85466. set isActive(value: boolean);
  85467. /**
  85468. * Creates a new ToggleButton
  85469. * @param name defines the control name
  85470. * @param group defines the toggle group this toggle belongs to
  85471. */
  85472. constructor(name?: string | undefined, group?: string);
  85473. protected _getTypeName(): string;
  85474. /** @hidden */
  85475. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85476. /** @hidden */
  85477. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85478. /** @hidden */
  85479. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85480. /** @hidden */
  85481. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85482. /** @hidden */
  85483. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85484. }
  85485. }
  85486. declare module BABYLON.GUI {
  85487. /** Class used to render a grid */
  85488. export class DisplayGrid extends Control {
  85489. name?: string | undefined;
  85490. private _cellWidth;
  85491. private _cellHeight;
  85492. private _minorLineTickness;
  85493. private _minorLineColor;
  85494. private _majorLineTickness;
  85495. private _majorLineColor;
  85496. private _majorLineFrequency;
  85497. private _background;
  85498. private _displayMajorLines;
  85499. private _displayMinorLines;
  85500. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85501. get displayMinorLines(): boolean;
  85502. set displayMinorLines(value: boolean);
  85503. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85504. get displayMajorLines(): boolean;
  85505. set displayMajorLines(value: boolean);
  85506. /** Gets or sets background color (Black by default) */
  85507. get background(): string;
  85508. set background(value: string);
  85509. /** Gets or sets the width of each cell (20 by default) */
  85510. get cellWidth(): number;
  85511. set cellWidth(value: number);
  85512. /** Gets or sets the height of each cell (20 by default) */
  85513. get cellHeight(): number;
  85514. set cellHeight(value: number);
  85515. /** Gets or sets the tickness of minor lines (1 by default) */
  85516. get minorLineTickness(): number;
  85517. set minorLineTickness(value: number);
  85518. /** Gets or sets the color of minor lines (DarkGray by default) */
  85519. get minorLineColor(): string;
  85520. set minorLineColor(value: string);
  85521. /** Gets or sets the tickness of major lines (2 by default) */
  85522. get majorLineTickness(): number;
  85523. set majorLineTickness(value: number);
  85524. /** Gets or sets the color of major lines (White by default) */
  85525. get majorLineColor(): string;
  85526. set majorLineColor(value: string);
  85527. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85528. get majorLineFrequency(): number;
  85529. set majorLineFrequency(value: number);
  85530. /**
  85531. * Creates a new GridDisplayRectangle
  85532. * @param name defines the control name
  85533. */
  85534. constructor(name?: string | undefined);
  85535. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85536. protected _getTypeName(): string;
  85537. }
  85538. }
  85539. declare module BABYLON.GUI {
  85540. /**
  85541. * Class used to create slider controls based on images
  85542. */
  85543. export class ImageBasedSlider extends BaseSlider {
  85544. name?: string | undefined;
  85545. private _backgroundImage;
  85546. private _thumbImage;
  85547. private _valueBarImage;
  85548. private _tempMeasure;
  85549. get displayThumb(): boolean;
  85550. set displayThumb(value: boolean);
  85551. /**
  85552. * Gets or sets the image used to render the background
  85553. */
  85554. get backgroundImage(): Image;
  85555. set backgroundImage(value: Image);
  85556. /**
  85557. * Gets or sets the image used to render the value bar
  85558. */
  85559. get valueBarImage(): Image;
  85560. set valueBarImage(value: Image);
  85561. /**
  85562. * Gets or sets the image used to render the thumb
  85563. */
  85564. get thumbImage(): Image;
  85565. set thumbImage(value: Image);
  85566. /**
  85567. * Creates a new ImageBasedSlider
  85568. * @param name defines the control name
  85569. */
  85570. constructor(name?: string | undefined);
  85571. protected _getTypeName(): string;
  85572. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85573. }
  85574. }
  85575. declare module BABYLON.GUI {
  85576. /**
  85577. * Forcing an export so that this code will execute
  85578. * @hidden
  85579. */
  85580. const name = "Statics";
  85581. }
  85582. declare module BABYLON.GUI {
  85583. /**
  85584. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85585. */
  85586. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85587. /**
  85588. * Define the instrumented AdvancedDynamicTexture.
  85589. */
  85590. texture: AdvancedDynamicTexture;
  85591. private _captureRenderTime;
  85592. private _renderTime;
  85593. private _captureLayoutTime;
  85594. private _layoutTime;
  85595. private _onBeginRenderObserver;
  85596. private _onEndRenderObserver;
  85597. private _onBeginLayoutObserver;
  85598. private _onEndLayoutObserver;
  85599. /**
  85600. * Gets the perf counter used to capture render time
  85601. */
  85602. get renderTimeCounter(): BABYLON.PerfCounter;
  85603. /**
  85604. * Gets the perf counter used to capture layout time
  85605. */
  85606. get layoutTimeCounter(): BABYLON.PerfCounter;
  85607. /**
  85608. * Enable or disable the render time capture
  85609. */
  85610. get captureRenderTime(): boolean;
  85611. set captureRenderTime(value: boolean);
  85612. /**
  85613. * Enable or disable the layout time capture
  85614. */
  85615. get captureLayoutTime(): boolean;
  85616. set captureLayoutTime(value: boolean);
  85617. /**
  85618. * Instantiates a new advanced dynamic texture instrumentation.
  85619. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85620. * @param texture Defines the AdvancedDynamicTexture to instrument
  85621. */
  85622. constructor(
  85623. /**
  85624. * Define the instrumented AdvancedDynamicTexture.
  85625. */
  85626. texture: AdvancedDynamicTexture);
  85627. /**
  85628. * Dispose and release associated resources.
  85629. */
  85630. dispose(): void;
  85631. }
  85632. }
  85633. declare module BABYLON.GUI {
  85634. /**
  85635. * Class used to load GUI via XML.
  85636. */
  85637. export class XmlLoader {
  85638. private _nodes;
  85639. private _nodeTypes;
  85640. private _isLoaded;
  85641. private _objectAttributes;
  85642. private _parentClass;
  85643. /**
  85644. * Create a new xml loader
  85645. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85646. */
  85647. constructor(parentClass?: null);
  85648. private _getChainElement;
  85649. private _getClassAttribute;
  85650. private _createGuiElement;
  85651. private _parseGrid;
  85652. private _parseElement;
  85653. private _prepareSourceElement;
  85654. private _parseElementsFromSource;
  85655. private _parseXml;
  85656. /**
  85657. * Gets if the loading has finished.
  85658. * @returns whether the loading has finished or not
  85659. */
  85660. isLoaded(): boolean;
  85661. /**
  85662. * Gets a loaded node / control by id.
  85663. * @param id the Controls id set in the xml
  85664. * @returns element of type Control
  85665. */
  85666. getNodeById(id: string): any;
  85667. /**
  85668. * Gets all loaded nodes / controls
  85669. * @returns Array of controls
  85670. */
  85671. getNodes(): any;
  85672. /**
  85673. * Initiates the xml layout loading
  85674. * @param xmlFile defines the xml layout to load
  85675. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85676. * @param callback defines the callback called on layout load.
  85677. */
  85678. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85679. }
  85680. }
  85681. declare module BABYLON.GUI {
  85682. /**
  85683. * Class used to create containers for controls
  85684. */
  85685. export class Container3D extends Control3D {
  85686. private _blockLayout;
  85687. /**
  85688. * Gets the list of child controls
  85689. */
  85690. protected _children: Control3D[];
  85691. /**
  85692. * Gets the list of child controls
  85693. */
  85694. get children(): Array<Control3D>;
  85695. /**
  85696. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85697. * This is helpful to optimize layout operation when adding multiple children in a row
  85698. */
  85699. get blockLayout(): boolean;
  85700. set blockLayout(value: boolean);
  85701. /**
  85702. * Creates a new container
  85703. * @param name defines the container name
  85704. */
  85705. constructor(name?: string);
  85706. /**
  85707. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85708. * @returns the current container
  85709. */
  85710. updateLayout(): Container3D;
  85711. /**
  85712. * Gets a boolean indicating if the given control is in the children of this control
  85713. * @param control defines the control to check
  85714. * @returns true if the control is in the child list
  85715. */
  85716. containsControl(control: Control3D): boolean;
  85717. /**
  85718. * Adds a control to the children of this control
  85719. * @param control defines the control to add
  85720. * @returns the current container
  85721. */
  85722. addControl(control: Control3D): Container3D;
  85723. /**
  85724. * This function will be called everytime a new control is added
  85725. */
  85726. protected _arrangeChildren(): void;
  85727. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85728. /**
  85729. * Removes a control from the children of this control
  85730. * @param control defines the control to remove
  85731. * @returns the current container
  85732. */
  85733. removeControl(control: Control3D): Container3D;
  85734. protected _getTypeName(): string;
  85735. /**
  85736. * Releases all associated resources
  85737. */
  85738. dispose(): void;
  85739. /** Control rotation will remain unchanged */
  85740. static readonly UNSET_ORIENTATION: number;
  85741. /** Control will rotate to make it look at sphere central axis */
  85742. static readonly FACEORIGIN_ORIENTATION: number;
  85743. /** Control will rotate to make it look back at sphere central axis */
  85744. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85745. /** Control will rotate to look at z axis (0, 0, 1) */
  85746. static readonly FACEFORWARD_ORIENTATION: number;
  85747. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85748. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85749. }
  85750. }
  85751. declare module BABYLON.GUI {
  85752. /**
  85753. * Class used to manage 3D user interface
  85754. * @see https://doc.babylonjs.com/how_to/gui3d
  85755. */
  85756. export class GUI3DManager implements BABYLON.IDisposable {
  85757. private _scene;
  85758. private _sceneDisposeObserver;
  85759. private _utilityLayer;
  85760. private _rootContainer;
  85761. private _pointerObserver;
  85762. private _pointerOutObserver;
  85763. /** @hidden */
  85764. _lastPickedControl: Control3D;
  85765. /** @hidden */
  85766. _lastControlOver: {
  85767. [pointerId: number]: Control3D;
  85768. };
  85769. /** @hidden */
  85770. _lastControlDown: {
  85771. [pointerId: number]: Control3D;
  85772. };
  85773. /**
  85774. * BABYLON.Observable raised when the point picked by the pointer events changed
  85775. */
  85776. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85777. /** @hidden */
  85778. _sharedMaterials: {
  85779. [key: string]: BABYLON.Material;
  85780. };
  85781. /** Gets the hosting scene */
  85782. get scene(): BABYLON.Scene;
  85783. /** Gets associated utility layer */
  85784. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85785. /**
  85786. * Creates a new GUI3DManager
  85787. * @param scene
  85788. */
  85789. constructor(scene?: BABYLON.Scene);
  85790. private _handlePointerOut;
  85791. private _doPicking;
  85792. /**
  85793. * Gets the root container
  85794. */
  85795. get rootContainer(): Container3D;
  85796. /**
  85797. * Gets a boolean indicating if the given control is in the root child list
  85798. * @param control defines the control to check
  85799. * @returns true if the control is in the root child list
  85800. */
  85801. containsControl(control: Control3D): boolean;
  85802. /**
  85803. * Adds a control to the root child list
  85804. * @param control defines the control to add
  85805. * @returns the current manager
  85806. */
  85807. addControl(control: Control3D): GUI3DManager;
  85808. /**
  85809. * Removes a control from the root child list
  85810. * @param control defines the control to remove
  85811. * @returns the current container
  85812. */
  85813. removeControl(control: Control3D): GUI3DManager;
  85814. /**
  85815. * Releases all associated resources
  85816. */
  85817. dispose(): void;
  85818. }
  85819. }
  85820. declare module BABYLON.GUI {
  85821. /**
  85822. * Class used to transport BABYLON.Vector3 information for pointer events
  85823. */
  85824. export class Vector3WithInfo extends BABYLON.Vector3 {
  85825. /** defines the current mouse button index */
  85826. buttonIndex: number;
  85827. /**
  85828. * Creates a new Vector3WithInfo
  85829. * @param source defines the vector3 data to transport
  85830. * @param buttonIndex defines the current mouse button index
  85831. */
  85832. constructor(source: BABYLON.Vector3,
  85833. /** defines the current mouse button index */
  85834. buttonIndex?: number);
  85835. }
  85836. }
  85837. declare module BABYLON.GUI {
  85838. /**
  85839. * Class used as base class for controls
  85840. */
  85841. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85842. /** Defines the control name */
  85843. name?: string | undefined;
  85844. /** @hidden */
  85845. _host: GUI3DManager;
  85846. private _node;
  85847. private _downCount;
  85848. private _enterCount;
  85849. private _downPointerIds;
  85850. private _isVisible;
  85851. /** Gets or sets the control position in world space */
  85852. get position(): BABYLON.Vector3;
  85853. set position(value: BABYLON.Vector3);
  85854. /** Gets or sets the control scaling in world space */
  85855. get scaling(): BABYLON.Vector3;
  85856. set scaling(value: BABYLON.Vector3);
  85857. /** Callback used to start pointer enter animation */
  85858. pointerEnterAnimation: () => void;
  85859. /** Callback used to start pointer out animation */
  85860. pointerOutAnimation: () => void;
  85861. /** Callback used to start pointer down animation */
  85862. pointerDownAnimation: () => void;
  85863. /** Callback used to start pointer up animation */
  85864. pointerUpAnimation: () => void;
  85865. /**
  85866. * An event triggered when the pointer move over the control
  85867. */
  85868. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  85869. /**
  85870. * An event triggered when the pointer move out of the control
  85871. */
  85872. onPointerOutObservable: BABYLON.Observable<Control3D>;
  85873. /**
  85874. * An event triggered when the pointer taps the control
  85875. */
  85876. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  85877. /**
  85878. * An event triggered when pointer is up
  85879. */
  85880. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  85881. /**
  85882. * An event triggered when a control is clicked on (with a mouse)
  85883. */
  85884. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  85885. /**
  85886. * An event triggered when pointer enters the control
  85887. */
  85888. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  85889. /**
  85890. * Gets or sets the parent container
  85891. */
  85892. parent: BABYLON.Nullable<Container3D>;
  85893. private _behaviors;
  85894. /**
  85895. * Gets the list of attached behaviors
  85896. * @see https://doc.babylonjs.com/features/behaviour
  85897. */
  85898. get behaviors(): BABYLON.Behavior<Control3D>[];
  85899. /**
  85900. * Attach a behavior to the control
  85901. * @see https://doc.babylonjs.com/features/behaviour
  85902. * @param behavior defines the behavior to attach
  85903. * @returns the current control
  85904. */
  85905. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85906. /**
  85907. * Remove an attached behavior
  85908. * @see https://doc.babylonjs.com/features/behaviour
  85909. * @param behavior defines the behavior to attach
  85910. * @returns the current control
  85911. */
  85912. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85913. /**
  85914. * Gets an attached behavior by name
  85915. * @param name defines the name of the behavior to look for
  85916. * @see https://doc.babylonjs.com/features/behaviour
  85917. * @returns null if behavior was not found else the requested behavior
  85918. */
  85919. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  85920. /** Gets or sets a boolean indicating if the control is visible */
  85921. get isVisible(): boolean;
  85922. set isVisible(value: boolean);
  85923. /**
  85924. * Creates a new control
  85925. * @param name defines the control name
  85926. */
  85927. constructor(
  85928. /** Defines the control name */
  85929. name?: string | undefined);
  85930. /**
  85931. * Gets a string representing the class name
  85932. */
  85933. get typeName(): string;
  85934. /**
  85935. * Get the current class name of the control.
  85936. * @returns current class name
  85937. */
  85938. getClassName(): string;
  85939. protected _getTypeName(): string;
  85940. /**
  85941. * Gets the transform node used by this control
  85942. */
  85943. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  85944. /**
  85945. * Gets the mesh used to render this control
  85946. */
  85947. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85948. /**
  85949. * Link the control as child of the given node
  85950. * @param node defines the node to link to. Use null to unlink the control
  85951. * @returns the current control
  85952. */
  85953. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  85954. /** @hidden **/
  85955. _prepareNode(scene: BABYLON.Scene): void;
  85956. /**
  85957. * Node creation.
  85958. * Can be overriden by children
  85959. * @param scene defines the scene where the node must be attached
  85960. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  85961. */
  85962. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85963. /**
  85964. * Affect a material to the given mesh
  85965. * @param mesh defines the mesh which will represent the control
  85966. */
  85967. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85968. /** @hidden */
  85969. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  85970. /** @hidden */
  85971. _onPointerEnter(target: Control3D): boolean;
  85972. /** @hidden */
  85973. _onPointerOut(target: Control3D): void;
  85974. /** @hidden */
  85975. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85976. /** @hidden */
  85977. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85978. /** @hidden */
  85979. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  85980. /** @hidden */
  85981. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85982. /** @hidden */
  85983. _disposeNode(): void;
  85984. /**
  85985. * Releases all associated resources
  85986. */
  85987. dispose(): void;
  85988. }
  85989. }
  85990. declare module BABYLON.GUI {
  85991. /**
  85992. * Class used as a root to all buttons
  85993. */
  85994. export class AbstractButton3D extends Control3D {
  85995. /**
  85996. * Creates a new button
  85997. * @param name defines the control name
  85998. */
  85999. constructor(name?: string);
  86000. protected _getTypeName(): string;
  86001. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86002. }
  86003. }
  86004. declare module BABYLON.GUI {
  86005. /**
  86006. * Class used to create a button in 3D
  86007. */
  86008. export class Button3D extends AbstractButton3D {
  86009. /** @hidden */
  86010. protected _currentMaterial: BABYLON.Material;
  86011. private _facadeTexture;
  86012. private _content;
  86013. private _contentResolution;
  86014. private _contentScaleRatio;
  86015. /**
  86016. * Gets or sets the texture resolution used to render content (512 by default)
  86017. */
  86018. get contentResolution(): BABYLON.int;
  86019. set contentResolution(value: BABYLON.int);
  86020. /**
  86021. * Gets or sets the texture scale ratio used to render content (2 by default)
  86022. */
  86023. get contentScaleRatio(): number;
  86024. set contentScaleRatio(value: number);
  86025. protected _disposeFacadeTexture(): void;
  86026. protected _resetContent(): void;
  86027. /**
  86028. * Creates a new button
  86029. * @param name defines the control name
  86030. */
  86031. constructor(name?: string);
  86032. /**
  86033. * Gets or sets the GUI 2D content used to display the button's facade
  86034. */
  86035. get content(): Control;
  86036. set content(value: Control);
  86037. /**
  86038. * Apply the facade texture (created from the content property).
  86039. * This function can be overloaded by child classes
  86040. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86041. */
  86042. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86043. protected _getTypeName(): string;
  86044. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86045. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86046. /**
  86047. * Releases all associated resources
  86048. */
  86049. dispose(): void;
  86050. }
  86051. }
  86052. declare module BABYLON.GUI {
  86053. /**
  86054. * Abstract class used to create a container panel deployed on the surface of a volume
  86055. */
  86056. export abstract class VolumeBasedPanel extends Container3D {
  86057. private _columns;
  86058. private _rows;
  86059. private _rowThenColum;
  86060. private _orientation;
  86061. protected _cellWidth: number;
  86062. protected _cellHeight: number;
  86063. /**
  86064. * Gets or sets the distance between elements
  86065. */
  86066. margin: number;
  86067. /**
  86068. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86069. * | Value | Type | Description |
  86070. * | ----- | ----------------------------------- | ----------- |
  86071. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86072. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86073. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86074. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86075. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86076. */
  86077. get orientation(): number;
  86078. set orientation(value: number);
  86079. /**
  86080. * Gets or sets the number of columns requested (10 by default).
  86081. * The panel will automatically compute the number of rows based on number of child controls.
  86082. */
  86083. get columns(): BABYLON.int;
  86084. set columns(value: BABYLON.int);
  86085. /**
  86086. * Gets or sets a the number of rows requested.
  86087. * The panel will automatically compute the number of columns based on number of child controls.
  86088. */
  86089. get rows(): BABYLON.int;
  86090. set rows(value: BABYLON.int);
  86091. /**
  86092. * Creates new VolumeBasedPanel
  86093. */
  86094. constructor();
  86095. protected _arrangeChildren(): void;
  86096. /** Child classes must implement this function to provide correct control positioning */
  86097. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86098. /** Child classes can implement this function to provide additional processing */
  86099. protected _finalProcessing(): void;
  86100. }
  86101. }
  86102. declare module BABYLON.GUI {
  86103. /**
  86104. * Class used to create a container panel deployed on the surface of a cylinder
  86105. */
  86106. export class CylinderPanel extends VolumeBasedPanel {
  86107. private _radius;
  86108. /**
  86109. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86110. */
  86111. get radius(): BABYLON.float;
  86112. set radius(value: BABYLON.float);
  86113. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86114. private _cylindricalMapping;
  86115. }
  86116. }
  86117. declare module BABYLON.GUI {
  86118. /** @hidden */
  86119. export var fluentVertexShader: {
  86120. name: string;
  86121. shader: string;
  86122. };
  86123. }
  86124. declare module BABYLON.GUI {
  86125. /** @hidden */
  86126. export var fluentPixelShader: {
  86127. name: string;
  86128. shader: string;
  86129. };
  86130. }
  86131. declare module BABYLON.GUI {
  86132. /** @hidden */
  86133. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86134. INNERGLOW: boolean;
  86135. BORDER: boolean;
  86136. HOVERLIGHT: boolean;
  86137. TEXTURE: boolean;
  86138. constructor();
  86139. }
  86140. /**
  86141. * Class used to render controls with fluent desgin
  86142. */
  86143. export class FluentMaterial extends BABYLON.PushMaterial {
  86144. /**
  86145. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86146. */
  86147. innerGlowColorIntensity: number;
  86148. /**
  86149. * Gets or sets the inner glow color (white by default)
  86150. */
  86151. innerGlowColor: BABYLON.Color3;
  86152. /**
  86153. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86154. */
  86155. albedoColor: BABYLON.Color3;
  86156. /**
  86157. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86158. */
  86159. renderBorders: boolean;
  86160. /**
  86161. * Gets or sets border width (default is 0.5)
  86162. */
  86163. borderWidth: number;
  86164. /**
  86165. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86166. */
  86167. edgeSmoothingValue: number;
  86168. /**
  86169. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86170. */
  86171. borderMinValue: number;
  86172. /**
  86173. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86174. */
  86175. renderHoverLight: boolean;
  86176. /**
  86177. * Gets or sets the radius used to render the hover light (default is 1.0)
  86178. */
  86179. hoverRadius: number;
  86180. /**
  86181. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86182. */
  86183. hoverColor: BABYLON.Color4;
  86184. /**
  86185. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86186. */
  86187. hoverPosition: BABYLON.Vector3;
  86188. private _albedoTexture;
  86189. /** Gets or sets the texture to use for albedo color */
  86190. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86191. /**
  86192. * Creates a new Fluent material
  86193. * @param name defines the name of the material
  86194. * @param scene defines the hosting scene
  86195. */
  86196. constructor(name: string, scene: BABYLON.Scene);
  86197. needAlphaBlending(): boolean;
  86198. needAlphaTesting(): boolean;
  86199. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86200. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86201. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86202. getActiveTextures(): BABYLON.BaseTexture[];
  86203. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86204. dispose(forceDisposeEffect?: boolean): void;
  86205. clone(name: string): FluentMaterial;
  86206. serialize(): any;
  86207. getClassName(): string;
  86208. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86209. }
  86210. }
  86211. declare module BABYLON.GUI {
  86212. /**
  86213. * Class used to create a holographic button in 3D
  86214. */
  86215. export class HolographicButton extends Button3D {
  86216. private _backPlate;
  86217. private _textPlate;
  86218. private _frontPlate;
  86219. private _text;
  86220. private _imageUrl;
  86221. private _shareMaterials;
  86222. private _frontMaterial;
  86223. private _backMaterial;
  86224. private _plateMaterial;
  86225. private _pickedPointObserver;
  86226. private _tooltipFade;
  86227. private _tooltipTextBlock;
  86228. private _tooltipTexture;
  86229. private _tooltipMesh;
  86230. private _tooltipHoverObserver;
  86231. private _tooltipOutObserver;
  86232. private _disposeTooltip;
  86233. /**
  86234. * Rendering ground id of all the mesh in the button
  86235. */
  86236. set renderingGroupId(id: number);
  86237. get renderingGroupId(): number;
  86238. /**
  86239. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86240. */
  86241. set tooltipText(text: BABYLON.Nullable<string>);
  86242. get tooltipText(): BABYLON.Nullable<string>;
  86243. /**
  86244. * Gets or sets text for the button
  86245. */
  86246. get text(): string;
  86247. set text(value: string);
  86248. /**
  86249. * Gets or sets the image url for the button
  86250. */
  86251. get imageUrl(): string;
  86252. set imageUrl(value: string);
  86253. /**
  86254. * Gets the back material used by this button
  86255. */
  86256. get backMaterial(): FluentMaterial;
  86257. /**
  86258. * Gets the front material used by this button
  86259. */
  86260. get frontMaterial(): FluentMaterial;
  86261. /**
  86262. * Gets the plate material used by this button
  86263. */
  86264. get plateMaterial(): BABYLON.StandardMaterial;
  86265. /**
  86266. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86267. */
  86268. get shareMaterials(): boolean;
  86269. /**
  86270. * Creates a new button
  86271. * @param name defines the control name
  86272. */
  86273. constructor(name?: string, shareMaterials?: boolean);
  86274. protected _getTypeName(): string;
  86275. private _rebuildContent;
  86276. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86277. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86278. private _createBackMaterial;
  86279. private _createFrontMaterial;
  86280. private _createPlateMaterial;
  86281. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86282. /**
  86283. * Releases all associated resources
  86284. */
  86285. dispose(): void;
  86286. }
  86287. }
  86288. declare module BABYLON.GUI {
  86289. /**
  86290. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86291. */
  86292. export class MeshButton3D extends Button3D {
  86293. /** @hidden */
  86294. protected _currentMesh: BABYLON.Mesh;
  86295. /**
  86296. * Creates a new 3D button based on a mesh
  86297. * @param mesh mesh to become a 3D button
  86298. * @param name defines the control name
  86299. */
  86300. constructor(mesh: BABYLON.Mesh, name?: string);
  86301. protected _getTypeName(): string;
  86302. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86303. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86304. }
  86305. }
  86306. declare module BABYLON.GUI {
  86307. /**
  86308. * Class used to create a container panel deployed on the surface of a plane
  86309. */
  86310. export class PlanePanel extends VolumeBasedPanel {
  86311. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86312. }
  86313. }
  86314. declare module BABYLON.GUI {
  86315. /**
  86316. * Class used to create a container panel where items get randomized planar mapping
  86317. */
  86318. export class ScatterPanel extends VolumeBasedPanel {
  86319. private _iteration;
  86320. /**
  86321. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86322. */
  86323. get iteration(): BABYLON.float;
  86324. set iteration(value: BABYLON.float);
  86325. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86326. private _scatterMapping;
  86327. protected _finalProcessing(): void;
  86328. }
  86329. }
  86330. declare module BABYLON.GUI {
  86331. /**
  86332. * Class used to create a container panel deployed on the surface of a sphere
  86333. */
  86334. export class SpherePanel extends VolumeBasedPanel {
  86335. private _radius;
  86336. /**
  86337. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86338. */
  86339. get radius(): BABYLON.float;
  86340. set radius(value: BABYLON.float);
  86341. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86342. private _sphericalMapping;
  86343. }
  86344. }
  86345. declare module BABYLON.GUI {
  86346. /**
  86347. * Class used to create a stack panel in 3D on XY plane
  86348. */
  86349. export class StackPanel3D extends Container3D {
  86350. private _isVertical;
  86351. /**
  86352. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86353. */
  86354. get isVertical(): boolean;
  86355. set isVertical(value: boolean);
  86356. /**
  86357. * Gets or sets the distance between elements
  86358. */
  86359. margin: number;
  86360. /**
  86361. * Creates new StackPanel
  86362. * @param isVertical
  86363. */
  86364. constructor(isVertical?: boolean);
  86365. protected _arrangeChildren(): void;
  86366. }
  86367. }
  86368. declare module BABYLON {
  86369. /**
  86370. * Configuration for glTF validation
  86371. */
  86372. export interface IGLTFValidationConfiguration {
  86373. /**
  86374. * The url of the glTF validator.
  86375. */
  86376. url: string;
  86377. }
  86378. /**
  86379. * glTF validation
  86380. */
  86381. export class GLTFValidation {
  86382. /**
  86383. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86384. */
  86385. static Configuration: IGLTFValidationConfiguration;
  86386. private static _LoadScriptPromise;
  86387. /**
  86388. * Validate a glTF asset using the glTF-Validator.
  86389. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86390. * @param rootUrl The root url for the glTF
  86391. * @param fileName The file name for the glTF
  86392. * @param getExternalResource The callback to get external resources for the glTF validator
  86393. * @returns A promise that resolves with the glTF validation results once complete
  86394. */
  86395. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86396. }
  86397. }
  86398. declare module BABYLON {
  86399. /**
  86400. * Mode that determines the coordinate system to use.
  86401. */
  86402. export enum GLTFLoaderCoordinateSystemMode {
  86403. /**
  86404. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86405. */
  86406. AUTO = 0,
  86407. /**
  86408. * Sets the useRightHandedSystem flag on the scene.
  86409. */
  86410. FORCE_RIGHT_HANDED = 1
  86411. }
  86412. /**
  86413. * Mode that determines what animations will start.
  86414. */
  86415. export enum GLTFLoaderAnimationStartMode {
  86416. /**
  86417. * No animation will start.
  86418. */
  86419. NONE = 0,
  86420. /**
  86421. * The first animation will start.
  86422. */
  86423. FIRST = 1,
  86424. /**
  86425. * All animations will start.
  86426. */
  86427. ALL = 2
  86428. }
  86429. /**
  86430. * Interface that contains the data for the glTF asset.
  86431. */
  86432. export interface IGLTFLoaderData {
  86433. /**
  86434. * The object that represents the glTF JSON.
  86435. */
  86436. json: Object;
  86437. /**
  86438. * The BIN chunk of a binary glTF.
  86439. */
  86440. bin: Nullable<IDataBuffer>;
  86441. }
  86442. /**
  86443. * Interface for extending the loader.
  86444. */
  86445. export interface IGLTFLoaderExtension {
  86446. /**
  86447. * The name of this extension.
  86448. */
  86449. readonly name: string;
  86450. /**
  86451. * Defines whether this extension is enabled.
  86452. */
  86453. enabled: boolean;
  86454. /**
  86455. * Defines the order of this extension.
  86456. * The loader sorts the extensions using these values when loading.
  86457. */
  86458. order?: number;
  86459. }
  86460. /**
  86461. * Loader state.
  86462. */
  86463. export enum GLTFLoaderState {
  86464. /**
  86465. * The asset is loading.
  86466. */
  86467. LOADING = 0,
  86468. /**
  86469. * The asset is ready for rendering.
  86470. */
  86471. READY = 1,
  86472. /**
  86473. * The asset is completely loaded.
  86474. */
  86475. COMPLETE = 2
  86476. }
  86477. /** @hidden */
  86478. export interface IGLTFLoader extends IDisposable {
  86479. readonly state: Nullable<GLTFLoaderState>;
  86480. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86481. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86482. }
  86483. /**
  86484. * File loader for loading glTF files into a scene.
  86485. */
  86486. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86487. /** @hidden */
  86488. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86489. /** @hidden */
  86490. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86491. /**
  86492. * Raised when the asset has been parsed
  86493. */
  86494. onParsedObservable: Observable<IGLTFLoaderData>;
  86495. private _onParsedObserver;
  86496. /**
  86497. * Raised when the asset has been parsed
  86498. */
  86499. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86500. /**
  86501. * 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.
  86502. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86503. * Defaults to true.
  86504. * @hidden
  86505. */
  86506. static IncrementalLoading: boolean;
  86507. /**
  86508. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86509. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86510. * @hidden
  86511. */
  86512. static HomogeneousCoordinates: boolean;
  86513. /**
  86514. * The coordinate system mode. Defaults to AUTO.
  86515. */
  86516. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86517. /**
  86518. * The animation start mode. Defaults to FIRST.
  86519. */
  86520. animationStartMode: GLTFLoaderAnimationStartMode;
  86521. /**
  86522. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86523. */
  86524. compileMaterials: boolean;
  86525. /**
  86526. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86527. */
  86528. useClipPlane: boolean;
  86529. /**
  86530. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86531. */
  86532. compileShadowGenerators: boolean;
  86533. /**
  86534. * Defines if the Alpha blended materials are only applied as coverage.
  86535. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86536. * If true, no extra effects are applied to transparent pixels.
  86537. */
  86538. transparencyAsCoverage: boolean;
  86539. /**
  86540. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86541. * Enabling will disable offline support and glTF validator.
  86542. * Defaults to false.
  86543. */
  86544. useRangeRequests: boolean;
  86545. /**
  86546. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86547. */
  86548. createInstances: boolean;
  86549. /**
  86550. * 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.
  86551. */
  86552. alwaysComputeBoundingBox: boolean;
  86553. /**
  86554. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86555. */
  86556. loadAllMaterials: boolean;
  86557. /**
  86558. * Function called before loading a url referenced by the asset.
  86559. */
  86560. preprocessUrlAsync: (url: string) => Promise<string>;
  86561. /**
  86562. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86563. * 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, ...)
  86564. */
  86565. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86566. private _onMeshLoadedObserver;
  86567. /**
  86568. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86569. * 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, ...)
  86570. */
  86571. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86572. /**
  86573. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86574. */
  86575. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86576. private _onTextureLoadedObserver;
  86577. /**
  86578. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86579. */
  86580. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86581. /**
  86582. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86583. */
  86584. readonly onMaterialLoadedObservable: Observable<Material>;
  86585. private _onMaterialLoadedObserver;
  86586. /**
  86587. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86588. */
  86589. set onMaterialLoaded(callback: (material: Material) => void);
  86590. /**
  86591. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86592. */
  86593. readonly onCameraLoadedObservable: Observable<Camera>;
  86594. private _onCameraLoadedObserver;
  86595. /**
  86596. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86597. */
  86598. set onCameraLoaded(callback: (camera: Camera) => void);
  86599. /**
  86600. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86601. * For assets with LODs, raised when all of the LODs are complete.
  86602. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86603. */
  86604. readonly onCompleteObservable: Observable<void>;
  86605. private _onCompleteObserver;
  86606. /**
  86607. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86608. * For assets with LODs, raised when all of the LODs are complete.
  86609. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86610. */
  86611. set onComplete(callback: () => void);
  86612. /**
  86613. * Observable raised when an error occurs.
  86614. */
  86615. readonly onErrorObservable: Observable<any>;
  86616. private _onErrorObserver;
  86617. /**
  86618. * Callback raised when an error occurs.
  86619. */
  86620. set onError(callback: (reason: any) => void);
  86621. /**
  86622. * Observable raised after the loader is disposed.
  86623. */
  86624. readonly onDisposeObservable: Observable<void>;
  86625. private _onDisposeObserver;
  86626. /**
  86627. * Callback raised after the loader is disposed.
  86628. */
  86629. set onDispose(callback: () => void);
  86630. /**
  86631. * Observable raised after a loader extension is created.
  86632. * Set additional options for a loader extension in this event.
  86633. */
  86634. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86635. private _onExtensionLoadedObserver;
  86636. /**
  86637. * Callback raised after a loader extension is created.
  86638. */
  86639. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86640. /**
  86641. * Defines if the loader logging is enabled.
  86642. */
  86643. get loggingEnabled(): boolean;
  86644. set loggingEnabled(value: boolean);
  86645. /**
  86646. * Defines if the loader should capture performance counters.
  86647. */
  86648. get capturePerformanceCounters(): boolean;
  86649. set capturePerformanceCounters(value: boolean);
  86650. /**
  86651. * Defines if the loader should validate the asset.
  86652. */
  86653. validate: boolean;
  86654. /**
  86655. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86656. */
  86657. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86658. private _onValidatedObserver;
  86659. /**
  86660. * Callback raised after a loader extension is created.
  86661. */
  86662. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86663. private _loader;
  86664. private _progressCallback?;
  86665. private _requests;
  86666. private static magicBase64Encoded;
  86667. /**
  86668. * Name of the loader ("gltf")
  86669. */
  86670. name: string;
  86671. /** @hidden */
  86672. extensions: ISceneLoaderPluginExtensions;
  86673. /**
  86674. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86675. */
  86676. dispose(): void;
  86677. /** @hidden */
  86678. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86679. /** @hidden */
  86680. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86681. /** @hidden */
  86682. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86683. /** @hidden */
  86684. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86685. /** @hidden */
  86686. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86687. /** @hidden */
  86688. canDirectLoad(data: string): boolean;
  86689. /** @hidden */
  86690. directLoad(scene: Scene, data: string): Promise<any>;
  86691. /**
  86692. * The callback that allows custom handling of the root url based on the response url.
  86693. * @param rootUrl the original root url
  86694. * @param responseURL the response url if available
  86695. * @returns the new root url
  86696. */
  86697. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86698. /** @hidden */
  86699. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86700. /**
  86701. * The loader state or null if the loader is not active.
  86702. */
  86703. get loaderState(): Nullable<GLTFLoaderState>;
  86704. /**
  86705. * Returns a promise that resolves when the asset is completely loaded.
  86706. * @returns a promise that resolves when the asset is completely loaded.
  86707. */
  86708. whenCompleteAsync(): Promise<void>;
  86709. /** @hidden */
  86710. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86711. /** @hidden */
  86712. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86713. private _onProgress;
  86714. private _validate;
  86715. private _getLoader;
  86716. private _parseJson;
  86717. private _unpackBinaryAsync;
  86718. private _unpackBinaryV1Async;
  86719. private _unpackBinaryV2Async;
  86720. private static _parseVersion;
  86721. private static _compareVersion;
  86722. private static readonly _logSpaces;
  86723. private _logIndentLevel;
  86724. private _loggingEnabled;
  86725. /** @hidden */
  86726. _log: (message: string) => void;
  86727. /** @hidden */
  86728. _logOpen(message: string): void;
  86729. /** @hidden */
  86730. _logClose(): void;
  86731. private _logEnabled;
  86732. private _logDisabled;
  86733. private _capturePerformanceCounters;
  86734. /** @hidden */
  86735. _startPerformanceCounter: (counterName: string) => void;
  86736. /** @hidden */
  86737. _endPerformanceCounter: (counterName: string) => void;
  86738. private _startPerformanceCounterEnabled;
  86739. private _startPerformanceCounterDisabled;
  86740. private _endPerformanceCounterEnabled;
  86741. private _endPerformanceCounterDisabled;
  86742. }
  86743. }
  86744. declare module BABYLON.GLTF1 {
  86745. /**
  86746. * Enums
  86747. * @hidden
  86748. */
  86749. export enum EComponentType {
  86750. BYTE = 5120,
  86751. UNSIGNED_BYTE = 5121,
  86752. SHORT = 5122,
  86753. UNSIGNED_SHORT = 5123,
  86754. FLOAT = 5126
  86755. }
  86756. /** @hidden */
  86757. export enum EShaderType {
  86758. FRAGMENT = 35632,
  86759. VERTEX = 35633
  86760. }
  86761. /** @hidden */
  86762. export enum EParameterType {
  86763. BYTE = 5120,
  86764. UNSIGNED_BYTE = 5121,
  86765. SHORT = 5122,
  86766. UNSIGNED_SHORT = 5123,
  86767. INT = 5124,
  86768. UNSIGNED_INT = 5125,
  86769. FLOAT = 5126,
  86770. FLOAT_VEC2 = 35664,
  86771. FLOAT_VEC3 = 35665,
  86772. FLOAT_VEC4 = 35666,
  86773. INT_VEC2 = 35667,
  86774. INT_VEC3 = 35668,
  86775. INT_VEC4 = 35669,
  86776. BOOL = 35670,
  86777. BOOL_VEC2 = 35671,
  86778. BOOL_VEC3 = 35672,
  86779. BOOL_VEC4 = 35673,
  86780. FLOAT_MAT2 = 35674,
  86781. FLOAT_MAT3 = 35675,
  86782. FLOAT_MAT4 = 35676,
  86783. SAMPLER_2D = 35678
  86784. }
  86785. /** @hidden */
  86786. export enum ETextureWrapMode {
  86787. CLAMP_TO_EDGE = 33071,
  86788. MIRRORED_REPEAT = 33648,
  86789. REPEAT = 10497
  86790. }
  86791. /** @hidden */
  86792. export enum ETextureFilterType {
  86793. NEAREST = 9728,
  86794. LINEAR = 9728,
  86795. NEAREST_MIPMAP_NEAREST = 9984,
  86796. LINEAR_MIPMAP_NEAREST = 9985,
  86797. NEAREST_MIPMAP_LINEAR = 9986,
  86798. LINEAR_MIPMAP_LINEAR = 9987
  86799. }
  86800. /** @hidden */
  86801. export enum ETextureFormat {
  86802. ALPHA = 6406,
  86803. RGB = 6407,
  86804. RGBA = 6408,
  86805. LUMINANCE = 6409,
  86806. LUMINANCE_ALPHA = 6410
  86807. }
  86808. /** @hidden */
  86809. export enum ECullingType {
  86810. FRONT = 1028,
  86811. BACK = 1029,
  86812. FRONT_AND_BACK = 1032
  86813. }
  86814. /** @hidden */
  86815. export enum EBlendingFunction {
  86816. ZERO = 0,
  86817. ONE = 1,
  86818. SRC_COLOR = 768,
  86819. ONE_MINUS_SRC_COLOR = 769,
  86820. DST_COLOR = 774,
  86821. ONE_MINUS_DST_COLOR = 775,
  86822. SRC_ALPHA = 770,
  86823. ONE_MINUS_SRC_ALPHA = 771,
  86824. DST_ALPHA = 772,
  86825. ONE_MINUS_DST_ALPHA = 773,
  86826. CONSTANT_COLOR = 32769,
  86827. ONE_MINUS_CONSTANT_COLOR = 32770,
  86828. CONSTANT_ALPHA = 32771,
  86829. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86830. SRC_ALPHA_SATURATE = 776
  86831. }
  86832. /** @hidden */
  86833. export interface IGLTFProperty {
  86834. extensions?: {
  86835. [key: string]: any;
  86836. };
  86837. extras?: Object;
  86838. }
  86839. /** @hidden */
  86840. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86841. name?: string;
  86842. }
  86843. /** @hidden */
  86844. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86845. bufferView: string;
  86846. byteOffset: number;
  86847. byteStride: number;
  86848. count: number;
  86849. type: string;
  86850. componentType: EComponentType;
  86851. max?: number[];
  86852. min?: number[];
  86853. name?: string;
  86854. }
  86855. /** @hidden */
  86856. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  86857. buffer: string;
  86858. byteOffset: number;
  86859. byteLength: number;
  86860. byteStride: number;
  86861. target?: number;
  86862. }
  86863. /** @hidden */
  86864. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  86865. uri: string;
  86866. byteLength?: number;
  86867. type?: string;
  86868. }
  86869. /** @hidden */
  86870. export interface IGLTFShader extends IGLTFChildRootProperty {
  86871. uri: string;
  86872. type: EShaderType;
  86873. }
  86874. /** @hidden */
  86875. export interface IGLTFProgram extends IGLTFChildRootProperty {
  86876. attributes: string[];
  86877. fragmentShader: string;
  86878. vertexShader: string;
  86879. }
  86880. /** @hidden */
  86881. export interface IGLTFTechniqueParameter {
  86882. type: number;
  86883. count?: number;
  86884. semantic?: string;
  86885. node?: string;
  86886. value?: number | boolean | string | Array<any>;
  86887. source?: string;
  86888. babylonValue?: any;
  86889. }
  86890. /** @hidden */
  86891. export interface IGLTFTechniqueCommonProfile {
  86892. lightingModel: string;
  86893. texcoordBindings: Object;
  86894. parameters?: Array<any>;
  86895. }
  86896. /** @hidden */
  86897. export interface IGLTFTechniqueStatesFunctions {
  86898. blendColor?: number[];
  86899. blendEquationSeparate?: number[];
  86900. blendFuncSeparate?: number[];
  86901. colorMask: boolean[];
  86902. cullFace: number[];
  86903. }
  86904. /** @hidden */
  86905. export interface IGLTFTechniqueStates {
  86906. enable: number[];
  86907. functions: IGLTFTechniqueStatesFunctions;
  86908. }
  86909. /** @hidden */
  86910. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  86911. parameters: {
  86912. [key: string]: IGLTFTechniqueParameter;
  86913. };
  86914. program: string;
  86915. attributes: {
  86916. [key: string]: string;
  86917. };
  86918. uniforms: {
  86919. [key: string]: string;
  86920. };
  86921. states: IGLTFTechniqueStates;
  86922. }
  86923. /** @hidden */
  86924. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  86925. technique?: string;
  86926. values: string[];
  86927. }
  86928. /** @hidden */
  86929. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  86930. attributes: {
  86931. [key: string]: string;
  86932. };
  86933. indices: string;
  86934. material: string;
  86935. mode?: number;
  86936. }
  86937. /** @hidden */
  86938. export interface IGLTFMesh extends IGLTFChildRootProperty {
  86939. primitives: IGLTFMeshPrimitive[];
  86940. }
  86941. /** @hidden */
  86942. export interface IGLTFImage extends IGLTFChildRootProperty {
  86943. uri: string;
  86944. }
  86945. /** @hidden */
  86946. export interface IGLTFSampler extends IGLTFChildRootProperty {
  86947. magFilter?: number;
  86948. minFilter?: number;
  86949. wrapS?: number;
  86950. wrapT?: number;
  86951. }
  86952. /** @hidden */
  86953. export interface IGLTFTexture extends IGLTFChildRootProperty {
  86954. sampler: string;
  86955. source: string;
  86956. format?: ETextureFormat;
  86957. internalFormat?: ETextureFormat;
  86958. target?: number;
  86959. type?: number;
  86960. babylonTexture?: Texture;
  86961. }
  86962. /** @hidden */
  86963. export interface IGLTFAmbienLight {
  86964. color?: number[];
  86965. }
  86966. /** @hidden */
  86967. export interface IGLTFDirectionalLight {
  86968. color?: number[];
  86969. }
  86970. /** @hidden */
  86971. export interface IGLTFPointLight {
  86972. color?: number[];
  86973. constantAttenuation?: number;
  86974. linearAttenuation?: number;
  86975. quadraticAttenuation?: number;
  86976. }
  86977. /** @hidden */
  86978. export interface IGLTFSpotLight {
  86979. color?: number[];
  86980. constantAttenuation?: number;
  86981. fallOfAngle?: number;
  86982. fallOffExponent?: number;
  86983. linearAttenuation?: number;
  86984. quadraticAttenuation?: number;
  86985. }
  86986. /** @hidden */
  86987. export interface IGLTFLight extends IGLTFChildRootProperty {
  86988. type: string;
  86989. }
  86990. /** @hidden */
  86991. export interface IGLTFCameraOrthographic {
  86992. xmag: number;
  86993. ymag: number;
  86994. zfar: number;
  86995. znear: number;
  86996. }
  86997. /** @hidden */
  86998. export interface IGLTFCameraPerspective {
  86999. aspectRatio: number;
  87000. yfov: number;
  87001. zfar: number;
  87002. znear: number;
  87003. }
  87004. /** @hidden */
  87005. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87006. type: string;
  87007. }
  87008. /** @hidden */
  87009. export interface IGLTFAnimationChannelTarget {
  87010. id: string;
  87011. path: string;
  87012. }
  87013. /** @hidden */
  87014. export interface IGLTFAnimationChannel {
  87015. sampler: string;
  87016. target: IGLTFAnimationChannelTarget;
  87017. }
  87018. /** @hidden */
  87019. export interface IGLTFAnimationSampler {
  87020. input: string;
  87021. output: string;
  87022. interpolation?: string;
  87023. }
  87024. /** @hidden */
  87025. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87026. channels?: IGLTFAnimationChannel[];
  87027. parameters?: {
  87028. [key: string]: string;
  87029. };
  87030. samplers?: {
  87031. [key: string]: IGLTFAnimationSampler;
  87032. };
  87033. }
  87034. /** @hidden */
  87035. export interface IGLTFNodeInstanceSkin {
  87036. skeletons: string[];
  87037. skin: string;
  87038. meshes: string[];
  87039. }
  87040. /** @hidden */
  87041. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87042. bindShapeMatrix: number[];
  87043. inverseBindMatrices: string;
  87044. jointNames: string[];
  87045. babylonSkeleton?: Skeleton;
  87046. }
  87047. /** @hidden */
  87048. export interface IGLTFNode extends IGLTFChildRootProperty {
  87049. camera?: string;
  87050. children: string[];
  87051. skin?: string;
  87052. jointName?: string;
  87053. light?: string;
  87054. matrix: number[];
  87055. mesh?: string;
  87056. meshes?: string[];
  87057. rotation?: number[];
  87058. scale?: number[];
  87059. translation?: number[];
  87060. babylonNode?: Node;
  87061. }
  87062. /** @hidden */
  87063. export interface IGLTFScene extends IGLTFChildRootProperty {
  87064. nodes: string[];
  87065. }
  87066. /** @hidden */
  87067. export interface IGLTFRuntime {
  87068. extensions: {
  87069. [key: string]: any;
  87070. };
  87071. accessors: {
  87072. [key: string]: IGLTFAccessor;
  87073. };
  87074. buffers: {
  87075. [key: string]: IGLTFBuffer;
  87076. };
  87077. bufferViews: {
  87078. [key: string]: IGLTFBufferView;
  87079. };
  87080. meshes: {
  87081. [key: string]: IGLTFMesh;
  87082. };
  87083. lights: {
  87084. [key: string]: IGLTFLight;
  87085. };
  87086. cameras: {
  87087. [key: string]: IGLTFCamera;
  87088. };
  87089. nodes: {
  87090. [key: string]: IGLTFNode;
  87091. };
  87092. images: {
  87093. [key: string]: IGLTFImage;
  87094. };
  87095. textures: {
  87096. [key: string]: IGLTFTexture;
  87097. };
  87098. shaders: {
  87099. [key: string]: IGLTFShader;
  87100. };
  87101. programs: {
  87102. [key: string]: IGLTFProgram;
  87103. };
  87104. samplers: {
  87105. [key: string]: IGLTFSampler;
  87106. };
  87107. techniques: {
  87108. [key: string]: IGLTFTechnique;
  87109. };
  87110. materials: {
  87111. [key: string]: IGLTFMaterial;
  87112. };
  87113. animations: {
  87114. [key: string]: IGLTFAnimation;
  87115. };
  87116. skins: {
  87117. [key: string]: IGLTFSkins;
  87118. };
  87119. currentScene?: Object;
  87120. scenes: {
  87121. [key: string]: IGLTFScene;
  87122. };
  87123. extensionsUsed: string[];
  87124. extensionsRequired?: string[];
  87125. buffersCount: number;
  87126. shaderscount: number;
  87127. scene: Scene;
  87128. rootUrl: string;
  87129. loadedBufferCount: number;
  87130. loadedBufferViews: {
  87131. [name: string]: ArrayBufferView;
  87132. };
  87133. loadedShaderCount: number;
  87134. importOnlyMeshes: boolean;
  87135. importMeshesNames?: string[];
  87136. dummyNodes: Node[];
  87137. forAssetContainer: boolean;
  87138. }
  87139. /** @hidden */
  87140. export interface INodeToRoot {
  87141. bone: Bone;
  87142. node: IGLTFNode;
  87143. id: string;
  87144. }
  87145. /** @hidden */
  87146. export interface IJointNode {
  87147. node: IGLTFNode;
  87148. id: string;
  87149. }
  87150. }
  87151. declare module BABYLON.GLTF1 {
  87152. /**
  87153. * Utils functions for GLTF
  87154. * @hidden
  87155. */
  87156. export class GLTFUtils {
  87157. /**
  87158. * Sets the given "parameter" matrix
  87159. * @param scene: the Scene object
  87160. * @param source: the source node where to pick the matrix
  87161. * @param parameter: the GLTF technique parameter
  87162. * @param uniformName: the name of the shader's uniform
  87163. * @param shaderMaterial: the shader material
  87164. */
  87165. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87166. /**
  87167. * Sets the given "parameter" matrix
  87168. * @param shaderMaterial: the shader material
  87169. * @param uniform: the name of the shader's uniform
  87170. * @param value: the value of the uniform
  87171. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87172. */
  87173. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87174. /**
  87175. * Returns the wrap mode of the texture
  87176. * @param mode: the mode value
  87177. */
  87178. static GetWrapMode(mode: number): number;
  87179. /**
  87180. * Returns the byte stride giving an accessor
  87181. * @param accessor: the GLTF accessor objet
  87182. */
  87183. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87184. /**
  87185. * Returns the texture filter mode giving a mode value
  87186. * @param mode: the filter mode value
  87187. */
  87188. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87189. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87190. /**
  87191. * Returns a buffer from its accessor
  87192. * @param gltfRuntime: the GLTF runtime
  87193. * @param accessor: the GLTF accessor
  87194. */
  87195. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87196. /**
  87197. * Decodes a buffer view into a string
  87198. * @param view: the buffer view
  87199. */
  87200. static DecodeBufferToText(view: ArrayBufferView): string;
  87201. /**
  87202. * Returns the default material of gltf. Related to
  87203. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87204. * @param scene: the Babylon.js scene
  87205. */
  87206. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87207. private static _DefaultMaterial;
  87208. }
  87209. }
  87210. declare module BABYLON.GLTF1 {
  87211. /**
  87212. * Implementation of the base glTF spec
  87213. * @hidden
  87214. */
  87215. export class GLTFLoaderBase {
  87216. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87217. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87218. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87219. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87220. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87221. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87222. }
  87223. /**
  87224. * glTF V1 Loader
  87225. * @hidden
  87226. */
  87227. export class GLTFLoader implements IGLTFLoader {
  87228. static Extensions: {
  87229. [name: string]: GLTFLoaderExtension;
  87230. };
  87231. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87232. state: Nullable<GLTFLoaderState>;
  87233. dispose(): void;
  87234. private _importMeshAsync;
  87235. /**
  87236. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87237. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87238. * @param scene the scene the meshes should be added to
  87239. * @param forAssetContainer defines if the entities must be stored in the scene
  87240. * @param data gltf data containing information of the meshes in a loaded file
  87241. * @param rootUrl root url to load from
  87242. * @param onProgress event that fires when loading progress has occured
  87243. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87244. */
  87245. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87246. private _loadAsync;
  87247. /**
  87248. * Imports all objects from a loaded gltf file and adds them to the scene
  87249. * @param scene the scene the objects should be added to
  87250. * @param data gltf data containing information of the meshes in a loaded file
  87251. * @param rootUrl root url to load from
  87252. * @param onProgress event that fires when loading progress has occured
  87253. * @returns a promise which completes when objects have been loaded to the scene
  87254. */
  87255. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87256. private _loadShadersAsync;
  87257. private _loadBuffersAsync;
  87258. private _createNodes;
  87259. }
  87260. /** @hidden */
  87261. export abstract class GLTFLoaderExtension {
  87262. private _name;
  87263. constructor(name: string);
  87264. get name(): string;
  87265. /**
  87266. * Defines an override for loading the runtime
  87267. * Return true to stop further extensions from loading the runtime
  87268. */
  87269. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87270. /**
  87271. * Defines an onverride for creating gltf runtime
  87272. * Return true to stop further extensions from creating the runtime
  87273. */
  87274. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87275. /**
  87276. * Defines an override for loading buffers
  87277. * Return true to stop further extensions from loading this buffer
  87278. */
  87279. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87280. /**
  87281. * Defines an override for loading texture buffers
  87282. * Return true to stop further extensions from loading this texture data
  87283. */
  87284. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87285. /**
  87286. * Defines an override for creating textures
  87287. * Return true to stop further extensions from loading this texture
  87288. */
  87289. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87290. /**
  87291. * Defines an override for loading shader strings
  87292. * Return true to stop further extensions from loading this shader data
  87293. */
  87294. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87295. /**
  87296. * Defines an override for loading materials
  87297. * Return true to stop further extensions from loading this material
  87298. */
  87299. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87300. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87301. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87302. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87303. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87304. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87305. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87306. private static LoadTextureBufferAsync;
  87307. private static CreateTextureAsync;
  87308. private static ApplyExtensions;
  87309. }
  87310. }
  87311. declare module BABYLON.GLTF1 {
  87312. /** @hidden */
  87313. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87314. private _bin;
  87315. constructor();
  87316. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87317. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87318. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87319. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87320. }
  87321. }
  87322. declare module BABYLON.GLTF1 {
  87323. /** @hidden */
  87324. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87325. constructor();
  87326. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87327. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87328. private _loadTexture;
  87329. }
  87330. }
  87331. declare module BABYLON.GLTF2.Loader {
  87332. /**
  87333. * Loader interface with an index field.
  87334. */
  87335. export interface IArrayItem {
  87336. /**
  87337. * The index of this item in the array.
  87338. */
  87339. index: number;
  87340. }
  87341. /**
  87342. * Loader interface with additional members.
  87343. */
  87344. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87345. /** @hidden */
  87346. _data?: Promise<ArrayBufferView>;
  87347. /** @hidden */
  87348. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87349. }
  87350. /**
  87351. * Loader interface with additional members.
  87352. */
  87353. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87354. }
  87355. /** @hidden */
  87356. export interface _IAnimationSamplerData {
  87357. input: Float32Array;
  87358. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87359. output: Float32Array;
  87360. }
  87361. /**
  87362. * Loader interface with additional members.
  87363. */
  87364. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87365. /** @hidden */
  87366. _data?: Promise<_IAnimationSamplerData>;
  87367. }
  87368. /**
  87369. * Loader interface with additional members.
  87370. */
  87371. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87372. channels: IAnimationChannel[];
  87373. samplers: IAnimationSampler[];
  87374. /** @hidden */
  87375. _babylonAnimationGroup?: AnimationGroup;
  87376. }
  87377. /**
  87378. * Loader interface with additional members.
  87379. */
  87380. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87381. /** @hidden */
  87382. _data?: Promise<ArrayBufferView>;
  87383. }
  87384. /**
  87385. * Loader interface with additional members.
  87386. */
  87387. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87388. /** @hidden */
  87389. _data?: Promise<ArrayBufferView>;
  87390. /** @hidden */
  87391. _babylonBuffer?: Promise<Buffer>;
  87392. }
  87393. /**
  87394. * Loader interface with additional members.
  87395. */
  87396. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87397. }
  87398. /**
  87399. * Loader interface with additional members.
  87400. */
  87401. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87402. /** @hidden */
  87403. _data?: Promise<ArrayBufferView>;
  87404. }
  87405. /**
  87406. * Loader interface with additional members.
  87407. */
  87408. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87409. }
  87410. /**
  87411. * Loader interface with additional members.
  87412. */
  87413. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87414. }
  87415. /**
  87416. * Loader interface with additional members.
  87417. */
  87418. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87419. baseColorTexture?: ITextureInfo;
  87420. metallicRoughnessTexture?: ITextureInfo;
  87421. }
  87422. /**
  87423. * Loader interface with additional members.
  87424. */
  87425. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87426. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87427. normalTexture?: IMaterialNormalTextureInfo;
  87428. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87429. emissiveTexture?: ITextureInfo;
  87430. /** @hidden */
  87431. _data?: {
  87432. [babylonDrawMode: number]: {
  87433. babylonMaterial: Material;
  87434. babylonMeshes: AbstractMesh[];
  87435. promise: Promise<void>;
  87436. };
  87437. };
  87438. }
  87439. /**
  87440. * Loader interface with additional members.
  87441. */
  87442. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87443. primitives: IMeshPrimitive[];
  87444. }
  87445. /**
  87446. * Loader interface with additional members.
  87447. */
  87448. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87449. /** @hidden */
  87450. _instanceData?: {
  87451. babylonSourceMesh: Mesh;
  87452. promise: Promise<any>;
  87453. };
  87454. }
  87455. /**
  87456. * Loader interface with additional members.
  87457. */
  87458. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87459. /**
  87460. * The parent glTF node.
  87461. */
  87462. parent?: INode;
  87463. /** @hidden */
  87464. _babylonTransformNode?: TransformNode;
  87465. /** @hidden */
  87466. _primitiveBabylonMeshes?: AbstractMesh[];
  87467. /** @hidden */
  87468. _babylonBones?: Bone[];
  87469. /** @hidden */
  87470. _numMorphTargets?: number;
  87471. }
  87472. /** @hidden */
  87473. export interface _ISamplerData {
  87474. noMipMaps: boolean;
  87475. samplingMode: number;
  87476. wrapU: number;
  87477. wrapV: number;
  87478. }
  87479. /**
  87480. * Loader interface with additional members.
  87481. */
  87482. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87483. /** @hidden */
  87484. _data?: _ISamplerData;
  87485. }
  87486. /**
  87487. * Loader interface with additional members.
  87488. */
  87489. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87490. }
  87491. /**
  87492. * Loader interface with additional members.
  87493. */
  87494. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87495. /** @hidden */
  87496. _data?: {
  87497. babylonSkeleton: Skeleton;
  87498. promise: Promise<void>;
  87499. };
  87500. }
  87501. /**
  87502. * Loader interface with additional members.
  87503. */
  87504. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87505. /** @hidden */
  87506. _textureInfo: ITextureInfo;
  87507. }
  87508. /**
  87509. * Loader interface with additional members.
  87510. */
  87511. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87512. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87513. nonColorData?: boolean;
  87514. }
  87515. /**
  87516. * Loader interface with additional members.
  87517. */
  87518. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87519. accessors?: IAccessor[];
  87520. animations?: IAnimation[];
  87521. buffers?: IBuffer[];
  87522. bufferViews?: IBufferView[];
  87523. cameras?: ICamera[];
  87524. images?: IImage[];
  87525. materials?: IMaterial[];
  87526. meshes?: IMesh[];
  87527. nodes?: INode[];
  87528. samplers?: ISampler[];
  87529. scenes?: IScene[];
  87530. skins?: ISkin[];
  87531. textures?: ITexture[];
  87532. }
  87533. }
  87534. declare module BABYLON.GLTF2 {
  87535. /**
  87536. * Interface for a glTF loader extension.
  87537. */
  87538. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87539. /**
  87540. * Called after the loader state changes to LOADING.
  87541. */
  87542. onLoading?(): void;
  87543. /**
  87544. * Called after the loader state changes to READY.
  87545. */
  87546. onReady?(): void;
  87547. /**
  87548. * Define this method to modify the default behavior when loading scenes.
  87549. * @param context The context when loading the asset
  87550. * @param scene The glTF scene property
  87551. * @returns A promise that resolves when the load is complete or null if not handled
  87552. */
  87553. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87554. /**
  87555. * Define this method to modify the default behavior when loading nodes.
  87556. * @param context The context when loading the asset
  87557. * @param node The glTF node property
  87558. * @param assign A function called synchronously after parsing the glTF properties
  87559. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87560. */
  87561. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87562. /**
  87563. * Define this method to modify the default behavior when loading cameras.
  87564. * @param context The context when loading the asset
  87565. * @param camera The glTF camera property
  87566. * @param assign A function called synchronously after parsing the glTF properties
  87567. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87568. */
  87569. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87570. /**
  87571. * @hidden
  87572. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87573. * @param context The context when loading the asset
  87574. * @param primitive The glTF mesh primitive property
  87575. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87576. */
  87577. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87578. /**
  87579. * @hidden
  87580. * Define this method to modify the default behavior when loading data for mesh primitives.
  87581. * @param context The context when loading the asset
  87582. * @param name The mesh name when loading the asset
  87583. * @param node The glTF node when loading the asset
  87584. * @param mesh The glTF mesh when loading the asset
  87585. * @param primitive The glTF mesh primitive property
  87586. * @param assign A function called synchronously after parsing the glTF properties
  87587. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87588. */
  87589. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87590. /**
  87591. * @hidden
  87592. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87593. * @param context The context when loading the asset
  87594. * @param material The glTF material property
  87595. * @param assign A function called synchronously after parsing the glTF properties
  87596. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87597. */
  87598. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87599. /**
  87600. * Define this method to modify the default behavior when creating materials.
  87601. * @param context The context when loading the asset
  87602. * @param material The glTF material property
  87603. * @param babylonDrawMode The draw mode for the Babylon material
  87604. * @returns The Babylon material or null if not handled
  87605. */
  87606. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87607. /**
  87608. * Define this method to modify the default behavior when loading material properties.
  87609. * @param context The context when loading the asset
  87610. * @param material The glTF material property
  87611. * @param babylonMaterial The Babylon material
  87612. * @returns A promise that resolves when the load is complete or null if not handled
  87613. */
  87614. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87615. /**
  87616. * Define this method to modify the default behavior when loading texture infos.
  87617. * @param context The context when loading the asset
  87618. * @param textureInfo The glTF texture info property
  87619. * @param assign A function called synchronously after parsing the glTF properties
  87620. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87621. */
  87622. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87623. /**
  87624. * @hidden
  87625. * Define this method to modify the default behavior when loading textures.
  87626. * @param context The context when loading the asset
  87627. * @param texture The glTF texture property
  87628. * @param assign A function called synchronously after parsing the glTF properties
  87629. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87630. */
  87631. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87632. /**
  87633. * Define this method to modify the default behavior when loading animations.
  87634. * @param context The context when loading the asset
  87635. * @param animation The glTF animation property
  87636. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87637. */
  87638. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87639. /**
  87640. * @hidden
  87641. * Define this method to modify the default behavior when loading skins.
  87642. * @param context The context when loading the asset
  87643. * @param node The glTF node property
  87644. * @param skin The glTF skin property
  87645. * @returns A promise that resolves when the load is complete or null if not handled
  87646. */
  87647. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87648. /**
  87649. * @hidden
  87650. * Define this method to modify the default behavior when loading uris.
  87651. * @param context The context when loading the asset
  87652. * @param property The glTF property associated with the uri
  87653. * @param uri The uri to load
  87654. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87655. */
  87656. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87657. /**
  87658. * Define this method to modify the default behavior when loading buffer views.
  87659. * @param context The context when loading the asset
  87660. * @param bufferView The glTF buffer view property
  87661. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87662. */
  87663. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87664. /**
  87665. * Define this method to modify the default behavior when loading buffers.
  87666. * @param context The context when loading the asset
  87667. * @param buffer The glTF buffer property
  87668. * @param byteOffset The byte offset to load
  87669. * @param byteLength The byte length to load
  87670. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87671. */
  87672. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87673. }
  87674. }
  87675. declare module BABYLON.GLTF2 {
  87676. /**
  87677. * Helper class for working with arrays when loading the glTF asset
  87678. */
  87679. export class ArrayItem {
  87680. /**
  87681. * Gets an item from the given array.
  87682. * @param context The context when loading the asset
  87683. * @param array The array to get the item from
  87684. * @param index The index to the array
  87685. * @returns The array item
  87686. */
  87687. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87688. /**
  87689. * Assign an `index` field to each item of the given array.
  87690. * @param array The array of items
  87691. */
  87692. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87693. }
  87694. /**
  87695. * The glTF 2.0 loader
  87696. */
  87697. export class GLTFLoader implements IGLTFLoader {
  87698. /** @hidden */
  87699. _completePromises: Promise<any>[];
  87700. /** @hidden */
  87701. _forAssetContainer: boolean;
  87702. /** Storage */
  87703. _babylonLights: Light[];
  87704. /** @hidden */
  87705. _disableInstancedMesh: number;
  87706. private _disposed;
  87707. private _parent;
  87708. private _state;
  87709. private _extensions;
  87710. private _rootUrl;
  87711. private _fileName;
  87712. private _uniqueRootUrl;
  87713. private _gltf;
  87714. private _bin;
  87715. private _babylonScene;
  87716. private _rootBabylonMesh;
  87717. private _defaultBabylonMaterialData;
  87718. private static _RegisteredExtensions;
  87719. /**
  87720. * The default glTF sampler.
  87721. */
  87722. static readonly DefaultSampler: ISampler;
  87723. /**
  87724. * Registers a loader extension.
  87725. * @param name The name of the loader extension.
  87726. * @param factory The factory function that creates the loader extension.
  87727. */
  87728. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87729. /**
  87730. * Unregisters a loader extension.
  87731. * @param name The name of the loader extension.
  87732. * @returns A boolean indicating whether the extension has been unregistered
  87733. */
  87734. static UnregisterExtension(name: string): boolean;
  87735. /**
  87736. * The loader state.
  87737. */
  87738. get state(): Nullable<GLTFLoaderState>;
  87739. /**
  87740. * The object that represents the glTF JSON.
  87741. */
  87742. get gltf(): IGLTF;
  87743. /**
  87744. * The BIN chunk of a binary glTF.
  87745. */
  87746. get bin(): Nullable<IDataBuffer>;
  87747. /**
  87748. * The parent file loader.
  87749. */
  87750. get parent(): GLTFFileLoader;
  87751. /**
  87752. * The Babylon scene when loading the asset.
  87753. */
  87754. get babylonScene(): Scene;
  87755. /**
  87756. * The root Babylon mesh when loading the asset.
  87757. */
  87758. get rootBabylonMesh(): Mesh;
  87759. /** @hidden */
  87760. constructor(parent: GLTFFileLoader);
  87761. /** @hidden */
  87762. dispose(): void;
  87763. /** @hidden */
  87764. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87765. /** @hidden */
  87766. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87767. private _loadAsync;
  87768. private _loadData;
  87769. private _setupData;
  87770. private _loadExtensions;
  87771. private _checkExtensions;
  87772. private _setState;
  87773. private _createRootNode;
  87774. /**
  87775. * Loads a glTF scene.
  87776. * @param context The context when loading the asset
  87777. * @param scene The glTF scene property
  87778. * @returns A promise that resolves when the load is complete
  87779. */
  87780. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87781. private _forEachPrimitive;
  87782. private _getGeometries;
  87783. private _getMeshes;
  87784. private _getTransformNodes;
  87785. private _getSkeletons;
  87786. private _getAnimationGroups;
  87787. private _startAnimations;
  87788. /**
  87789. * Loads a glTF node.
  87790. * @param context The context when loading the asset
  87791. * @param node The glTF node property
  87792. * @param assign A function called synchronously after parsing the glTF properties
  87793. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87794. */
  87795. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87796. private _loadMeshAsync;
  87797. /**
  87798. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87799. * @param context The context when loading the asset
  87800. * @param name The mesh name when loading the asset
  87801. * @param node The glTF node when loading the asset
  87802. * @param mesh The glTF mesh when loading the asset
  87803. * @param primitive The glTF mesh primitive property
  87804. * @param assign A function called synchronously after parsing the glTF properties
  87805. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87806. */
  87807. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87808. private _loadVertexDataAsync;
  87809. private _createMorphTargets;
  87810. private _loadMorphTargetsAsync;
  87811. private _loadMorphTargetVertexDataAsync;
  87812. private static _LoadTransform;
  87813. private _loadSkinAsync;
  87814. private _loadBones;
  87815. private _loadBone;
  87816. private _loadSkinInverseBindMatricesDataAsync;
  87817. private _updateBoneMatrices;
  87818. private _getNodeMatrix;
  87819. /**
  87820. * Loads a glTF camera.
  87821. * @param context The context when loading the asset
  87822. * @param camera The glTF camera property
  87823. * @param assign A function called synchronously after parsing the glTF properties
  87824. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87825. */
  87826. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87827. private _loadAnimationsAsync;
  87828. /**
  87829. * Loads a glTF animation.
  87830. * @param context The context when loading the asset
  87831. * @param animation The glTF animation property
  87832. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87833. */
  87834. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87835. /**
  87836. * @hidden Loads a glTF animation channel.
  87837. * @param context The context when loading the asset
  87838. * @param animationContext The context of the animation when loading the asset
  87839. * @param animation The glTF animation property
  87840. * @param channel The glTF animation channel property
  87841. * @param babylonAnimationGroup The babylon animation group property
  87842. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87843. * @returns A void promise when the channel load is complete
  87844. */
  87845. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87846. private _loadAnimationSamplerAsync;
  87847. /**
  87848. * Loads a glTF buffer.
  87849. * @param context The context when loading the asset
  87850. * @param buffer The glTF buffer property
  87851. * @param byteOffset The byte offset to use
  87852. * @param byteLength The byte length to use
  87853. * @returns A promise that resolves with the loaded data when the load is complete
  87854. */
  87855. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  87856. /**
  87857. * Loads a glTF buffer view.
  87858. * @param context The context when loading the asset
  87859. * @param bufferView The glTF buffer view property
  87860. * @returns A promise that resolves with the loaded data when the load is complete
  87861. */
  87862. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  87863. private _loadAccessorAsync;
  87864. /** @hidden */
  87865. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  87866. private _loadIndicesAccessorAsync;
  87867. private _loadVertexBufferViewAsync;
  87868. private _loadVertexAccessorAsync;
  87869. private _loadMaterialMetallicRoughnessPropertiesAsync;
  87870. /** @hidden */
  87871. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  87872. private _createDefaultMaterial;
  87873. /**
  87874. * Creates a Babylon material from a glTF material.
  87875. * @param context The context when loading the asset
  87876. * @param material The glTF material property
  87877. * @param babylonDrawMode The draw mode for the Babylon material
  87878. * @returns The Babylon material
  87879. */
  87880. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  87881. /**
  87882. * Loads properties from a glTF material into a Babylon material.
  87883. * @param context The context when loading the asset
  87884. * @param material The glTF material property
  87885. * @param babylonMaterial The Babylon material
  87886. * @returns A promise that resolves when the load is complete
  87887. */
  87888. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87889. /**
  87890. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  87891. * @param context The context when loading the asset
  87892. * @param material The glTF material property
  87893. * @param babylonMaterial The Babylon material
  87894. * @returns A promise that resolves when the load is complete
  87895. */
  87896. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87897. /**
  87898. * Loads the alpha properties from a glTF material into a Babylon material.
  87899. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  87900. * @param context The context when loading the asset
  87901. * @param material The glTF material property
  87902. * @param babylonMaterial The Babylon material
  87903. */
  87904. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  87905. /**
  87906. * Loads a glTF texture info.
  87907. * @param context The context when loading the asset
  87908. * @param textureInfo The glTF texture info property
  87909. * @param assign A function called synchronously after parsing the glTF properties
  87910. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  87911. */
  87912. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87913. /** @hidden */
  87914. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87915. /** @hidden */
  87916. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  87917. private _loadSampler;
  87918. /**
  87919. * Loads a glTF image.
  87920. * @param context The context when loading the asset
  87921. * @param image The glTF image property
  87922. * @returns A promise that resolves with the loaded data when the load is complete
  87923. */
  87924. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  87925. /**
  87926. * Loads a glTF uri.
  87927. * @param context The context when loading the asset
  87928. * @param property The glTF property associated with the uri
  87929. * @param uri The base64 or relative uri
  87930. * @returns A promise that resolves with the loaded data when the load is complete
  87931. */
  87932. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  87933. /**
  87934. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  87935. * @param babylonObject the Babylon object with metadata
  87936. * @param pointer the JSON pointer
  87937. */
  87938. static AddPointerMetadata(babylonObject: {
  87939. metadata: any;
  87940. }, pointer: string): void;
  87941. private static _GetTextureWrapMode;
  87942. private static _GetTextureSamplingMode;
  87943. private static _GetTypedArrayConstructor;
  87944. private static _GetTypedArray;
  87945. private static _GetNumComponents;
  87946. private static _ValidateUri;
  87947. /** @hidden */
  87948. static _GetDrawMode(context: string, mode: number | undefined): number;
  87949. private _compileMaterialsAsync;
  87950. private _compileShadowGeneratorsAsync;
  87951. private _forEachExtensions;
  87952. private _applyExtensions;
  87953. private _extensionsOnLoading;
  87954. private _extensionsOnReady;
  87955. private _extensionsLoadSceneAsync;
  87956. private _extensionsLoadNodeAsync;
  87957. private _extensionsLoadCameraAsync;
  87958. private _extensionsLoadVertexDataAsync;
  87959. private _extensionsLoadMeshPrimitiveAsync;
  87960. private _extensionsLoadMaterialAsync;
  87961. private _extensionsCreateMaterial;
  87962. private _extensionsLoadMaterialPropertiesAsync;
  87963. private _extensionsLoadTextureInfoAsync;
  87964. private _extensionsLoadTextureAsync;
  87965. private _extensionsLoadAnimationAsync;
  87966. private _extensionsLoadSkinAsync;
  87967. private _extensionsLoadUriAsync;
  87968. private _extensionsLoadBufferViewAsync;
  87969. private _extensionsLoadBufferAsync;
  87970. /**
  87971. * Helper method called by a loader extension to load an glTF extension.
  87972. * @param context The context when loading the asset
  87973. * @param property The glTF property to load the extension from
  87974. * @param extensionName The name of the extension to load
  87975. * @param actionAsync The action to run
  87976. * @returns The promise returned by actionAsync or null if the extension does not exist
  87977. */
  87978. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87979. /**
  87980. * Helper method called by a loader extension to load a glTF extra.
  87981. * @param context The context when loading the asset
  87982. * @param property The glTF property to load the extra from
  87983. * @param extensionName The name of the extension to load
  87984. * @param actionAsync The action to run
  87985. * @returns The promise returned by actionAsync or null if the extra does not exist
  87986. */
  87987. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87988. /**
  87989. * Checks for presence of an extension.
  87990. * @param name The name of the extension to check
  87991. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  87992. */
  87993. isExtensionUsed(name: string): boolean;
  87994. /**
  87995. * Increments the indentation level and logs a message.
  87996. * @param message The message to log
  87997. */
  87998. logOpen(message: string): void;
  87999. /**
  88000. * Decrements the indentation level.
  88001. */
  88002. logClose(): void;
  88003. /**
  88004. * Logs a message
  88005. * @param message The message to log
  88006. */
  88007. log(message: string): void;
  88008. /**
  88009. * Starts a performance counter.
  88010. * @param counterName The name of the performance counter
  88011. */
  88012. startPerformanceCounter(counterName: string): void;
  88013. /**
  88014. * Ends a performance counter.
  88015. * @param counterName The name of the performance counter
  88016. */
  88017. endPerformanceCounter(counterName: string): void;
  88018. }
  88019. }
  88020. declare module BABYLON.GLTF2.Loader.Extensions {
  88021. /** @hidden */
  88022. interface IEXTLightsImageBased_LightImageBased {
  88023. _babylonTexture?: BaseTexture;
  88024. _loaded?: Promise<void>;
  88025. }
  88026. /**
  88027. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88028. */
  88029. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88030. /**
  88031. * The name of this extension.
  88032. */
  88033. readonly name: string;
  88034. /**
  88035. * Defines whether this extension is enabled.
  88036. */
  88037. enabled: boolean;
  88038. private _loader;
  88039. private _lights?;
  88040. /** @hidden */
  88041. constructor(loader: GLTFLoader);
  88042. /** @hidden */
  88043. dispose(): void;
  88044. /** @hidden */
  88045. onLoading(): void;
  88046. /** @hidden */
  88047. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88048. private _loadLightAsync;
  88049. }
  88050. }
  88051. declare module BABYLON.GLTF2.Loader.Extensions {
  88052. /**
  88053. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88054. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88055. * !!! Experimental Extension Subject to Changes !!!
  88056. */
  88057. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88058. /**
  88059. * The name of this extension.
  88060. */
  88061. readonly name: string;
  88062. /**
  88063. * Defines whether this extension is enabled.
  88064. */
  88065. enabled: boolean;
  88066. private _loader;
  88067. /** @hidden */
  88068. constructor(loader: GLTFLoader);
  88069. /** @hidden */
  88070. dispose(): void;
  88071. /** @hidden */
  88072. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88073. }
  88074. }
  88075. declare module BABYLON.GLTF2.Loader.Extensions {
  88076. /**
  88077. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88078. *
  88079. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88080. */
  88081. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88082. /**
  88083. * The name of this extension.
  88084. */
  88085. readonly name: string;
  88086. /**
  88087. * Defines whether this extension is enabled.
  88088. */
  88089. enabled: boolean;
  88090. /**
  88091. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88092. */
  88093. static DecoderPath: string;
  88094. private _loader;
  88095. private _decoderPromise?;
  88096. /** @hidden */
  88097. constructor(loader: GLTFLoader);
  88098. /** @hidden */
  88099. dispose(): void;
  88100. /** @hidden */
  88101. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88102. }
  88103. }
  88104. declare module BABYLON.GLTF2.Loader.Extensions {
  88105. /**
  88106. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88107. */
  88108. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88109. /** The name of this extension. */
  88110. readonly name: string;
  88111. /** Defines whether this extension is enabled. */
  88112. enabled: boolean;
  88113. private _loader;
  88114. /** @hidden */
  88115. constructor(loader: GLTFLoader);
  88116. /** @hidden */
  88117. dispose(): void;
  88118. /** @hidden */
  88119. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88120. }
  88121. }
  88122. declare module BABYLON.GLTF2.Loader.Extensions {
  88123. /**
  88124. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88125. */
  88126. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88127. /**
  88128. * The name of this extension.
  88129. */
  88130. readonly name: string;
  88131. /**
  88132. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88133. */
  88134. dracoCompression?: DracoCompression;
  88135. /**
  88136. * Defines whether this extension is enabled.
  88137. */
  88138. enabled: boolean;
  88139. private _loader;
  88140. /** @hidden */
  88141. constructor(loader: GLTFLoader);
  88142. /** @hidden */
  88143. dispose(): void;
  88144. /** @hidden */
  88145. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88146. }
  88147. }
  88148. declare module BABYLON.GLTF2.Loader.Extensions {
  88149. /**
  88150. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88151. */
  88152. export class KHR_lights implements IGLTFLoaderExtension {
  88153. /**
  88154. * The name of this extension.
  88155. */
  88156. readonly name: string;
  88157. /**
  88158. * Defines whether this extension is enabled.
  88159. */
  88160. enabled: boolean;
  88161. private _loader;
  88162. private _lights?;
  88163. /** @hidden */
  88164. constructor(loader: GLTFLoader);
  88165. /** @hidden */
  88166. dispose(): void;
  88167. /** @hidden */
  88168. onLoading(): void;
  88169. /** @hidden */
  88170. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88171. }
  88172. }
  88173. declare module BABYLON.GLTF2.Loader.Extensions {
  88174. /**
  88175. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88176. */
  88177. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88178. /**
  88179. * The name of this extension.
  88180. */
  88181. readonly name: string;
  88182. /**
  88183. * Defines whether this extension is enabled.
  88184. */
  88185. enabled: boolean;
  88186. /**
  88187. * Defines a number that determines the order the extensions are applied.
  88188. */
  88189. order: number;
  88190. private _loader;
  88191. /** @hidden */
  88192. constructor(loader: GLTFLoader);
  88193. /** @hidden */
  88194. dispose(): void;
  88195. /** @hidden */
  88196. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88197. private _loadSpecularGlossinessPropertiesAsync;
  88198. }
  88199. }
  88200. declare module BABYLON.GLTF2.Loader.Extensions {
  88201. /**
  88202. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88203. */
  88204. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88205. /**
  88206. * The name of this extension.
  88207. */
  88208. readonly name: string;
  88209. /**
  88210. * Defines whether this extension is enabled.
  88211. */
  88212. enabled: boolean;
  88213. /**
  88214. * Defines a number that determines the order the extensions are applied.
  88215. */
  88216. order: number;
  88217. private _loader;
  88218. /** @hidden */
  88219. constructor(loader: GLTFLoader);
  88220. /** @hidden */
  88221. dispose(): void;
  88222. /** @hidden */
  88223. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88224. private _loadUnlitPropertiesAsync;
  88225. }
  88226. }
  88227. declare module BABYLON.GLTF2.Loader.Extensions {
  88228. /**
  88229. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88230. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88231. */
  88232. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88233. /**
  88234. * The name of this extension.
  88235. */
  88236. readonly name: string;
  88237. /**
  88238. * Defines whether this extension is enabled.
  88239. */
  88240. enabled: boolean;
  88241. /**
  88242. * Defines a number that determines the order the extensions are applied.
  88243. */
  88244. order: number;
  88245. private _loader;
  88246. /** @hidden */
  88247. constructor(loader: GLTFLoader);
  88248. /** @hidden */
  88249. dispose(): void;
  88250. /** @hidden */
  88251. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88252. private _loadClearCoatPropertiesAsync;
  88253. }
  88254. }
  88255. declare module BABYLON.GLTF2.Loader.Extensions {
  88256. /**
  88257. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88258. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88259. * !!! Experimental Extension Subject to Changes !!!
  88260. */
  88261. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88262. /**
  88263. * The name of this extension.
  88264. */
  88265. readonly name: string;
  88266. /**
  88267. * Defines whether this extension is enabled.
  88268. */
  88269. enabled: boolean;
  88270. /**
  88271. * Defines a number that determines the order the extensions are applied.
  88272. */
  88273. order: number;
  88274. private _loader;
  88275. /** @hidden */
  88276. constructor(loader: GLTFLoader);
  88277. /** @hidden */
  88278. dispose(): void;
  88279. /** @hidden */
  88280. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88281. private _loadSheenPropertiesAsync;
  88282. }
  88283. }
  88284. declare module BABYLON.GLTF2.Loader.Extensions {
  88285. /**
  88286. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88287. * !!! Experimental Extension Subject to Changes !!!
  88288. */
  88289. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88290. /**
  88291. * The name of this extension.
  88292. */
  88293. readonly name: string;
  88294. /**
  88295. * Defines whether this extension is enabled.
  88296. */
  88297. enabled: boolean;
  88298. /**
  88299. * Defines a number that determines the order the extensions are applied.
  88300. */
  88301. order: number;
  88302. private _loader;
  88303. /** @hidden */
  88304. constructor(loader: GLTFLoader);
  88305. /** @hidden */
  88306. dispose(): void;
  88307. /** @hidden */
  88308. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88309. private _loadSpecularPropertiesAsync;
  88310. }
  88311. }
  88312. declare module BABYLON.GLTF2.Loader.Extensions {
  88313. /**
  88314. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88315. * !!! Experimental Extension Subject to Changes !!!
  88316. */
  88317. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88318. /**
  88319. * Default ior Value from the spec.
  88320. */
  88321. private static readonly _DEFAULT_IOR;
  88322. /**
  88323. * The name of this extension.
  88324. */
  88325. readonly name: string;
  88326. /**
  88327. * Defines whether this extension is enabled.
  88328. */
  88329. enabled: boolean;
  88330. /**
  88331. * Defines a number that determines the order the extensions are applied.
  88332. */
  88333. order: number;
  88334. private _loader;
  88335. /** @hidden */
  88336. constructor(loader: GLTFLoader);
  88337. /** @hidden */
  88338. dispose(): void;
  88339. /** @hidden */
  88340. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88341. private _loadIorPropertiesAsync;
  88342. }
  88343. }
  88344. declare module BABYLON.GLTF2.Loader.Extensions {
  88345. /**
  88346. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88347. */
  88348. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88349. /**
  88350. * The name of this extension.
  88351. */
  88352. readonly name: string;
  88353. /**
  88354. * Defines whether this extension is enabled.
  88355. */
  88356. enabled: boolean;
  88357. private _loader;
  88358. private _variants?;
  88359. /** @hidden */
  88360. constructor(loader: GLTFLoader);
  88361. /** @hidden */
  88362. dispose(): void;
  88363. /**
  88364. * Gets the list of available variant names for this asset.
  88365. * @param rootMesh The glTF root mesh
  88366. * @returns the list of all the variant names for this model
  88367. */
  88368. static GetAvailableVariants(rootMesh: Mesh): string[];
  88369. /**
  88370. * Gets the list of available variant names for this asset.
  88371. * @param rootMesh The glTF root mesh
  88372. * @returns the list of all the variant names for this model
  88373. */
  88374. getAvailableVariants(rootMesh: Mesh): string[];
  88375. /**
  88376. * Select a variant given a variant name or a list of variant names.
  88377. * @param rootMesh The glTF root mesh
  88378. * @param variantName The variant name(s) to select.
  88379. */
  88380. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88381. /**
  88382. * Select a variant given a variant name or a list of variant names.
  88383. * @param rootMesh The glTF root mesh
  88384. * @param variantName The variant name(s) to select.
  88385. */
  88386. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88387. /**
  88388. * Reset back to the original before selecting a variant.
  88389. * @param rootMesh The glTF root mesh
  88390. */
  88391. static Reset(rootMesh: Mesh): void;
  88392. /**
  88393. * Reset back to the original before selecting a variant.
  88394. * @param rootMesh The glTF root mesh
  88395. */
  88396. reset(rootMesh: Mesh): void;
  88397. /**
  88398. * Gets the last selected variant name(s) or null if original.
  88399. * @param rootMesh The glTF root mesh
  88400. * @returns The selected variant name(s).
  88401. */
  88402. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88403. /**
  88404. * Gets the last selected variant name(s) or null if original.
  88405. * @param rootMesh The glTF root mesh
  88406. * @returns The selected variant name(s).
  88407. */
  88408. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88409. private static _GetExtensionMetadata;
  88410. /** @hidden */
  88411. onLoading(): void;
  88412. /** @hidden */
  88413. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88414. }
  88415. }
  88416. declare module BABYLON.GLTF2.Loader.Extensions {
  88417. /**
  88418. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88419. */
  88420. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88421. /**
  88422. * The name of this extension.
  88423. */
  88424. readonly name: string;
  88425. /**
  88426. * Defines whether this extension is enabled.
  88427. */
  88428. enabled: boolean;
  88429. /**
  88430. * Defines a number that determines the order the extensions are applied.
  88431. */
  88432. order: number;
  88433. private _loader;
  88434. /** @hidden */
  88435. constructor(loader: GLTFLoader);
  88436. /** @hidden */
  88437. dispose(): void;
  88438. /** @hidden */
  88439. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88440. private _loadTransparentPropertiesAsync;
  88441. }
  88442. }
  88443. declare module BABYLON.GLTF2.Loader.Extensions {
  88444. /**
  88445. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88446. * !!! Experimental Extension Subject to Changes !!!
  88447. */
  88448. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88449. /**
  88450. * The name of this extension.
  88451. */
  88452. readonly name: string;
  88453. /**
  88454. * Defines whether this extension is enabled.
  88455. */
  88456. enabled: boolean;
  88457. /**
  88458. * Defines a number that determines the order the extensions are applied.
  88459. */
  88460. order: number;
  88461. private _loader;
  88462. /** @hidden */
  88463. constructor(loader: GLTFLoader);
  88464. /** @hidden */
  88465. dispose(): void;
  88466. /** @hidden */
  88467. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88468. private _loadTranslucentPropertiesAsync;
  88469. }
  88470. }
  88471. declare module BABYLON.GLTF2.Loader.Extensions {
  88472. /**
  88473. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88474. */
  88475. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88476. /**
  88477. * The name of this extension.
  88478. */
  88479. readonly name: string;
  88480. /**
  88481. * Defines whether this extension is enabled.
  88482. */
  88483. enabled: boolean;
  88484. /** @hidden */
  88485. constructor(loader: GLTFLoader);
  88486. /** @hidden */
  88487. dispose(): void;
  88488. }
  88489. }
  88490. declare module BABYLON.GLTF2.Loader.Extensions {
  88491. /**
  88492. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88493. * !!! Experimental Extension Subject to Changes !!!
  88494. */
  88495. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88496. /** The name of this extension. */
  88497. readonly name: string;
  88498. /** Defines whether this extension is enabled. */
  88499. enabled: boolean;
  88500. private _loader;
  88501. /** @hidden */
  88502. constructor(loader: GLTFLoader);
  88503. /** @hidden */
  88504. dispose(): void;
  88505. /** @hidden */
  88506. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88507. }
  88508. }
  88509. declare module BABYLON.GLTF2.Loader.Extensions {
  88510. /**
  88511. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88512. */
  88513. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88514. /**
  88515. * The name of this extension.
  88516. */
  88517. readonly name: string;
  88518. /**
  88519. * Defines whether this extension is enabled.
  88520. */
  88521. enabled: boolean;
  88522. private _loader;
  88523. /** @hidden */
  88524. constructor(loader: GLTFLoader);
  88525. /** @hidden */
  88526. dispose(): void;
  88527. /** @hidden */
  88528. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88529. }
  88530. }
  88531. declare module BABYLON.GLTF2.Loader.Extensions {
  88532. /**
  88533. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  88534. * !!! Experimental Extension Subject to Changes !!!
  88535. */
  88536. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  88537. /**
  88538. * The name of this extension.
  88539. */
  88540. readonly name: string;
  88541. /**
  88542. * Defines whether this extension is enabled.
  88543. */
  88544. enabled: boolean;
  88545. /**
  88546. * Defines a number that determines the order the extensions are applied.
  88547. */
  88548. order: number;
  88549. private _loader;
  88550. /** @hidden */
  88551. constructor(loader: GLTFLoader);
  88552. /** @hidden */
  88553. dispose(): void;
  88554. /**
  88555. * Called after the loader state changes to LOADING.
  88556. */
  88557. onLoading(): void;
  88558. }
  88559. }
  88560. declare module BABYLON.GLTF2.Loader.Extensions {
  88561. /**
  88562. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88563. */
  88564. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88565. /**
  88566. * The name of this extension.
  88567. */
  88568. readonly name: string;
  88569. /**
  88570. * Defines whether this extension is enabled.
  88571. */
  88572. enabled: boolean;
  88573. private _loader;
  88574. private _clips;
  88575. private _emitters;
  88576. /** @hidden */
  88577. constructor(loader: GLTFLoader);
  88578. /** @hidden */
  88579. dispose(): void;
  88580. /** @hidden */
  88581. onLoading(): void;
  88582. /** @hidden */
  88583. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88584. /** @hidden */
  88585. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88586. /** @hidden */
  88587. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88588. private _loadClipAsync;
  88589. private _loadEmitterAsync;
  88590. private _getEventAction;
  88591. private _loadAnimationEventAsync;
  88592. }
  88593. }
  88594. declare module BABYLON.GLTF2.Loader.Extensions {
  88595. /**
  88596. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88597. */
  88598. export class MSFT_lod implements IGLTFLoaderExtension {
  88599. /**
  88600. * The name of this extension.
  88601. */
  88602. readonly name: string;
  88603. /**
  88604. * Defines whether this extension is enabled.
  88605. */
  88606. enabled: boolean;
  88607. /**
  88608. * Defines a number that determines the order the extensions are applied.
  88609. */
  88610. order: number;
  88611. /**
  88612. * Maximum number of LODs to load, starting from the lowest LOD.
  88613. */
  88614. maxLODsToLoad: number;
  88615. /**
  88616. * Observable raised when all node LODs of one level are loaded.
  88617. * The event data is the index of the loaded LOD starting from zero.
  88618. * Dispose the loader to cancel the loading of the next level of LODs.
  88619. */
  88620. onNodeLODsLoadedObservable: Observable<number>;
  88621. /**
  88622. * Observable raised when all material LODs of one level are loaded.
  88623. * The event data is the index of the loaded LOD starting from zero.
  88624. * Dispose the loader to cancel the loading of the next level of LODs.
  88625. */
  88626. onMaterialLODsLoadedObservable: Observable<number>;
  88627. private _loader;
  88628. private _bufferLODs;
  88629. private _nodeIndexLOD;
  88630. private _nodeSignalLODs;
  88631. private _nodePromiseLODs;
  88632. private _nodeBufferLODs;
  88633. private _materialIndexLOD;
  88634. private _materialSignalLODs;
  88635. private _materialPromiseLODs;
  88636. private _materialBufferLODs;
  88637. /** @hidden */
  88638. constructor(loader: GLTFLoader);
  88639. /** @hidden */
  88640. dispose(): void;
  88641. /** @hidden */
  88642. onReady(): void;
  88643. /** @hidden */
  88644. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88645. /** @hidden */
  88646. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88647. /** @hidden */
  88648. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88649. /** @hidden */
  88650. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88651. /** @hidden */
  88652. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88653. private _loadBufferLOD;
  88654. /**
  88655. * Gets an array of LOD properties from lowest to highest.
  88656. */
  88657. private _getLODs;
  88658. private _disposeTransformNode;
  88659. private _disposeMaterials;
  88660. }
  88661. }
  88662. declare module BABYLON.GLTF2.Loader.Extensions {
  88663. /** @hidden */
  88664. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88665. readonly name: string;
  88666. enabled: boolean;
  88667. private _loader;
  88668. constructor(loader: GLTFLoader);
  88669. dispose(): void;
  88670. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88671. }
  88672. }
  88673. declare module BABYLON.GLTF2.Loader.Extensions {
  88674. /** @hidden */
  88675. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88676. readonly name: string;
  88677. enabled: boolean;
  88678. private _loader;
  88679. constructor(loader: GLTFLoader);
  88680. dispose(): void;
  88681. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88682. }
  88683. }
  88684. declare module BABYLON.GLTF2.Loader.Extensions {
  88685. /**
  88686. * Store glTF extras (if present) in BJS objects' metadata
  88687. */
  88688. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88689. /**
  88690. * The name of this extension.
  88691. */
  88692. readonly name: string;
  88693. /**
  88694. * Defines whether this extension is enabled.
  88695. */
  88696. enabled: boolean;
  88697. private _loader;
  88698. private _assignExtras;
  88699. /** @hidden */
  88700. constructor(loader: GLTFLoader);
  88701. /** @hidden */
  88702. dispose(): void;
  88703. /** @hidden */
  88704. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88705. /** @hidden */
  88706. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88707. /** @hidden */
  88708. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88709. }
  88710. }
  88711. declare module BABYLON {
  88712. /**
  88713. * Class reading and parsing the MTL file bundled with the obj file.
  88714. */
  88715. export class MTLFileLoader {
  88716. /**
  88717. * Invert Y-Axis of referenced textures on load
  88718. */
  88719. static INVERT_TEXTURE_Y: boolean;
  88720. /**
  88721. * All material loaded from the mtl will be set here
  88722. */
  88723. materials: StandardMaterial[];
  88724. /**
  88725. * This function will read the mtl file and create each material described inside
  88726. * This function could be improve by adding :
  88727. * -some component missing (Ni, Tf...)
  88728. * -including the specific options available
  88729. *
  88730. * @param scene defines the scene the material will be created in
  88731. * @param data defines the mtl data to parse
  88732. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88733. * @param forAssetContainer defines if the material should be registered in the scene
  88734. */
  88735. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88736. /**
  88737. * Gets the texture for the material.
  88738. *
  88739. * If the material is imported from input file,
  88740. * We sanitize the url to ensure it takes the textre from aside the material.
  88741. *
  88742. * @param rootUrl The root url to load from
  88743. * @param value The value stored in the mtl
  88744. * @return The Texture
  88745. */
  88746. private static _getTexture;
  88747. }
  88748. }
  88749. declare module BABYLON {
  88750. /**
  88751. * Options for loading OBJ/MTL files
  88752. */
  88753. type MeshLoadOptions = {
  88754. /**
  88755. * Defines if UVs are optimized by default during load.
  88756. */
  88757. OptimizeWithUV: boolean;
  88758. /**
  88759. * Defines custom scaling of UV coordinates of loaded meshes.
  88760. */
  88761. UVScaling: Vector2;
  88762. /**
  88763. * Invert model on y-axis (does a model scaling inversion)
  88764. */
  88765. InvertY: boolean;
  88766. /**
  88767. * Invert Y-Axis of referenced textures on load
  88768. */
  88769. InvertTextureY: boolean;
  88770. /**
  88771. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88772. */
  88773. ImportVertexColors: boolean;
  88774. /**
  88775. * Compute the normals for the model, even if normals are present in the file.
  88776. */
  88777. ComputeNormals: boolean;
  88778. /**
  88779. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88780. */
  88781. SkipMaterials: boolean;
  88782. /**
  88783. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88784. */
  88785. MaterialLoadingFailsSilently: boolean;
  88786. };
  88787. /**
  88788. * OBJ file type loader.
  88789. * This is a babylon scene loader plugin.
  88790. */
  88791. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88792. /**
  88793. * Defines if UVs are optimized by default during load.
  88794. */
  88795. static OPTIMIZE_WITH_UV: boolean;
  88796. /**
  88797. * Invert model on y-axis (does a model scaling inversion)
  88798. */
  88799. static INVERT_Y: boolean;
  88800. /**
  88801. * Invert Y-Axis of referenced textures on load
  88802. */
  88803. static get INVERT_TEXTURE_Y(): boolean;
  88804. static set INVERT_TEXTURE_Y(value: boolean);
  88805. /**
  88806. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88807. */
  88808. static IMPORT_VERTEX_COLORS: boolean;
  88809. /**
  88810. * Compute the normals for the model, even if normals are present in the file.
  88811. */
  88812. static COMPUTE_NORMALS: boolean;
  88813. /**
  88814. * Defines custom scaling of UV coordinates of loaded meshes.
  88815. */
  88816. static UV_SCALING: Vector2;
  88817. /**
  88818. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88819. */
  88820. static SKIP_MATERIALS: boolean;
  88821. /**
  88822. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88823. *
  88824. * Defaults to true for backwards compatibility.
  88825. */
  88826. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88827. /**
  88828. * Defines the name of the plugin.
  88829. */
  88830. name: string;
  88831. /**
  88832. * Defines the extension the plugin is able to load.
  88833. */
  88834. extensions: string;
  88835. /** @hidden */
  88836. obj: RegExp;
  88837. /** @hidden */
  88838. group: RegExp;
  88839. /** @hidden */
  88840. mtllib: RegExp;
  88841. /** @hidden */
  88842. usemtl: RegExp;
  88843. /** @hidden */
  88844. smooth: RegExp;
  88845. /** @hidden */
  88846. vertexPattern: RegExp;
  88847. /** @hidden */
  88848. normalPattern: RegExp;
  88849. /** @hidden */
  88850. uvPattern: RegExp;
  88851. /** @hidden */
  88852. facePattern1: RegExp;
  88853. /** @hidden */
  88854. facePattern2: RegExp;
  88855. /** @hidden */
  88856. facePattern3: RegExp;
  88857. /** @hidden */
  88858. facePattern4: RegExp;
  88859. /** @hidden */
  88860. facePattern5: RegExp;
  88861. private _forAssetContainer;
  88862. private _meshLoadOptions;
  88863. /**
  88864. * Creates loader for .OBJ files
  88865. *
  88866. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  88867. */
  88868. constructor(meshLoadOptions?: MeshLoadOptions);
  88869. private static get currentMeshLoadOptions();
  88870. /**
  88871. * Calls synchronously the MTL file attached to this obj.
  88872. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  88873. * Without this function materials are not displayed in the first frame (but displayed after).
  88874. * In consequence it is impossible to get material information in your HTML file
  88875. *
  88876. * @param url The URL of the MTL file
  88877. * @param rootUrl
  88878. * @param onSuccess Callback function to be called when the MTL file is loaded
  88879. * @private
  88880. */
  88881. private _loadMTL;
  88882. /**
  88883. * Instantiates a OBJ file loader plugin.
  88884. * @returns the created plugin
  88885. */
  88886. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  88887. /**
  88888. * If the data string can be loaded directly.
  88889. *
  88890. * @param data string containing the file data
  88891. * @returns if the data can be loaded directly
  88892. */
  88893. canDirectLoad(data: string): boolean;
  88894. /**
  88895. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  88896. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88897. * @param scene the scene the meshes should be added to
  88898. * @param data the OBJ data to load
  88899. * @param rootUrl root url to load from
  88900. * @param onProgress event that fires when loading progress has occured
  88901. * @param fileName Defines the name of the file to load
  88902. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88903. */
  88904. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88905. /**
  88906. * Imports all objects from the loaded OBJ data and adds them to the scene
  88907. * @param scene the scene the objects should be added to
  88908. * @param data the OBJ data to load
  88909. * @param rootUrl root url to load from
  88910. * @param onProgress event that fires when loading progress has occured
  88911. * @param fileName Defines the name of the file to load
  88912. * @returns a promise which completes when objects have been loaded to the scene
  88913. */
  88914. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88915. /**
  88916. * Load into an asset container.
  88917. * @param scene The scene to load into
  88918. * @param data The data to import
  88919. * @param rootUrl The root url for scene and resources
  88920. * @param onProgress The callback when the load progresses
  88921. * @param fileName Defines the name of the file to load
  88922. * @returns The loaded asset container
  88923. */
  88924. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  88925. /**
  88926. * Read the OBJ file and create an Array of meshes.
  88927. * Each mesh contains all information given by the OBJ and the MTL file.
  88928. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  88929. *
  88930. * @param meshesNames
  88931. * @param scene Scene The scene where are displayed the data
  88932. * @param data String The content of the obj file
  88933. * @param rootUrl String The path to the folder
  88934. * @returns Array<AbstractMesh>
  88935. * @private
  88936. */
  88937. private _parseSolid;
  88938. }
  88939. }
  88940. declare module BABYLON {
  88941. /**
  88942. * STL file type loader.
  88943. * This is a babylon scene loader plugin.
  88944. */
  88945. export class STLFileLoader implements ISceneLoaderPlugin {
  88946. /** @hidden */
  88947. solidPattern: RegExp;
  88948. /** @hidden */
  88949. facetsPattern: RegExp;
  88950. /** @hidden */
  88951. normalPattern: RegExp;
  88952. /** @hidden */
  88953. vertexPattern: RegExp;
  88954. /**
  88955. * Defines the name of the plugin.
  88956. */
  88957. name: string;
  88958. /**
  88959. * Defines the extensions the stl loader is able to load.
  88960. * force data to come in as an ArrayBuffer
  88961. * we'll convert to string if it looks like it's an ASCII .stl
  88962. */
  88963. extensions: ISceneLoaderPluginExtensions;
  88964. /**
  88965. * Import meshes into a scene.
  88966. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  88967. * @param scene The scene to import into
  88968. * @param data The data to import
  88969. * @param rootUrl The root url for scene and resources
  88970. * @param meshes The meshes array to import into
  88971. * @param particleSystems The particle systems array to import into
  88972. * @param skeletons The skeletons array to import into
  88973. * @param onError The callback when import fails
  88974. * @returns True if successful or false otherwise
  88975. */
  88976. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  88977. /**
  88978. * Load into a scene.
  88979. * @param scene The scene to load into
  88980. * @param data The data to import
  88981. * @param rootUrl The root url for scene and resources
  88982. * @param onError The callback when import fails
  88983. * @returns true if successful or false otherwise
  88984. */
  88985. load(scene: Scene, data: any, rootUrl: string): boolean;
  88986. /**
  88987. * Load into an asset container.
  88988. * @param scene The scene to load into
  88989. * @param data The data to import
  88990. * @param rootUrl The root url for scene and resources
  88991. * @param onError The callback when import fails
  88992. * @returns The loaded asset container
  88993. */
  88994. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  88995. private _isBinary;
  88996. private _parseBinary;
  88997. private _parseASCII;
  88998. }
  88999. }
  89000. declare module BABYLON {
  89001. /**
  89002. * Class for generating OBJ data from a Babylon scene.
  89003. */
  89004. export class OBJExport {
  89005. /**
  89006. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89007. * @param mesh defines the list of meshes to serialize
  89008. * @param materials defines if materials should be exported
  89009. * @param matlibname defines the name of the associated mtl file
  89010. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89011. * @returns the OBJ content
  89012. */
  89013. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89014. /**
  89015. * Exports the material(s) of a mesh in .MTL file format (text)
  89016. * @param mesh defines the mesh to extract the material from
  89017. * @returns the mtl content
  89018. */
  89019. static MTL(mesh: Mesh): string;
  89020. }
  89021. }
  89022. declare module BABYLON {
  89023. /** @hidden */
  89024. export var __IGLTFExporterExtension: number;
  89025. /**
  89026. * Interface for extending the exporter
  89027. * @hidden
  89028. */
  89029. export interface IGLTFExporterExtension {
  89030. /**
  89031. * The name of this extension
  89032. */
  89033. readonly name: string;
  89034. /**
  89035. * Defines whether this extension is enabled
  89036. */
  89037. enabled: boolean;
  89038. /**
  89039. * Defines whether this extension is required
  89040. */
  89041. required: boolean;
  89042. }
  89043. }
  89044. declare module BABYLON.GLTF2.Exporter {
  89045. /** @hidden */
  89046. export var __IGLTFExporterExtensionV2: number;
  89047. /**
  89048. * Interface for a glTF exporter extension
  89049. * @hidden
  89050. */
  89051. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89052. /**
  89053. * Define this method to modify the default behavior before exporting a texture
  89054. * @param context The context when loading the asset
  89055. * @param babylonTexture The Babylon.js texture
  89056. * @param mimeType The mime-type of the generated image
  89057. * @returns A promise that resolves with the exported texture
  89058. */
  89059. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89060. /**
  89061. * Define this method to get notified when a texture info is created
  89062. * @param context The context when loading the asset
  89063. * @param textureInfo The glTF texture info
  89064. * @param babylonTexture The Babylon.js texture
  89065. */
  89066. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89067. /**
  89068. * Define this method to modify the default behavior when exporting texture info
  89069. * @param context The context when loading the asset
  89070. * @param meshPrimitive glTF mesh primitive
  89071. * @param babylonSubMesh Babylon submesh
  89072. * @param binaryWriter glTF serializer binary writer instance
  89073. * @returns nullable IMeshPrimitive promise
  89074. */
  89075. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89076. /**
  89077. * Define this method to modify the default behavior when exporting a node
  89078. * @param context The context when exporting the node
  89079. * @param node glTF node
  89080. * @param babylonNode BabylonJS node
  89081. * @returns nullable INode promise
  89082. */
  89083. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89084. [key: number]: number;
  89085. }): Promise<Nullable<INode>>;
  89086. /**
  89087. * Define this method to modify the default behavior when exporting a material
  89088. * @param material glTF material
  89089. * @param babylonMaterial BabylonJS material
  89090. * @returns nullable IMaterial promise
  89091. */
  89092. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89093. /**
  89094. * Define this method to return additional textures to export from a material
  89095. * @param material glTF material
  89096. * @param babylonMaterial BabylonJS material
  89097. * @returns List of textures
  89098. */
  89099. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89100. /** Gets a boolean indicating that this extension was used */
  89101. wasUsed: boolean;
  89102. /** Gets a boolean indicating that this extension is required for the file to work */
  89103. required: boolean;
  89104. /**
  89105. * Called after the exporter state changes to EXPORTING
  89106. */
  89107. onExporting?(): void;
  89108. }
  89109. }
  89110. declare module BABYLON.GLTF2.Exporter {
  89111. /**
  89112. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89113. * @hidden
  89114. */
  89115. export class _GLTFMaterialExporter {
  89116. /**
  89117. * Represents the dielectric specular values for R, G and B
  89118. */
  89119. private static readonly _DielectricSpecular;
  89120. /**
  89121. * Allows the maximum specular power to be defined for material calculations
  89122. */
  89123. private static readonly _MaxSpecularPower;
  89124. /**
  89125. * Mapping to store textures
  89126. */
  89127. private _textureMap;
  89128. /**
  89129. * Numeric tolerance value
  89130. */
  89131. private static readonly _Epsilon;
  89132. /**
  89133. * Reference to the glTF Exporter
  89134. */
  89135. private _exporter;
  89136. constructor(exporter: _Exporter);
  89137. /**
  89138. * Specifies if two colors are approximately equal in value
  89139. * @param color1 first color to compare to
  89140. * @param color2 second color to compare to
  89141. * @param epsilon threshold value
  89142. */
  89143. private static FuzzyEquals;
  89144. /**
  89145. * Gets the materials from a Babylon scene and converts them to glTF materials
  89146. * @param scene babylonjs scene
  89147. * @param mimeType texture mime type
  89148. * @param images array of images
  89149. * @param textures array of textures
  89150. * @param materials array of materials
  89151. * @param imageData mapping of texture names to base64 textures
  89152. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89153. */
  89154. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89155. /**
  89156. * Makes a copy of the glTF material without the texture parameters
  89157. * @param originalMaterial original glTF material
  89158. * @returns glTF material without texture parameters
  89159. */
  89160. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89161. /**
  89162. * Specifies if the material has any texture parameters present
  89163. * @param material glTF Material
  89164. * @returns boolean specifying if texture parameters are present
  89165. */
  89166. _hasTexturesPresent(material: IMaterial): boolean;
  89167. /**
  89168. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89169. * @param babylonStandardMaterial
  89170. * @returns glTF Metallic Roughness Material representation
  89171. */
  89172. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89173. /**
  89174. * Computes the metallic factor
  89175. * @param diffuse diffused value
  89176. * @param specular specular value
  89177. * @param oneMinusSpecularStrength one minus the specular strength
  89178. * @returns metallic value
  89179. */
  89180. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89181. /**
  89182. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89183. * @param glTFMaterial glTF material
  89184. * @param babylonMaterial Babylon material
  89185. */
  89186. private static _SetAlphaMode;
  89187. /**
  89188. * Converts a Babylon Standard Material to a glTF Material
  89189. * @param babylonStandardMaterial BJS Standard Material
  89190. * @param mimeType mime type to use for the textures
  89191. * @param images array of glTF image interfaces
  89192. * @param textures array of glTF texture interfaces
  89193. * @param materials array of glTF material interfaces
  89194. * @param imageData map of image file name to data
  89195. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89196. */
  89197. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89198. private _finishMaterial;
  89199. /**
  89200. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89201. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89202. * @param mimeType mime type to use for the textures
  89203. * @param images array of glTF image interfaces
  89204. * @param textures array of glTF texture interfaces
  89205. * @param materials array of glTF material interfaces
  89206. * @param imageData map of image file name to data
  89207. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89208. */
  89209. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89210. /**
  89211. * Converts an image typed array buffer to a base64 image
  89212. * @param buffer typed array buffer
  89213. * @param width width of the image
  89214. * @param height height of the image
  89215. * @param mimeType mimetype of the image
  89216. * @returns base64 image string
  89217. */
  89218. private _createBase64FromCanvasAsync;
  89219. /**
  89220. * Generates a white texture based on the specified width and height
  89221. * @param width width of the texture in pixels
  89222. * @param height height of the texture in pixels
  89223. * @param scene babylonjs scene
  89224. * @returns white texture
  89225. */
  89226. private _createWhiteTexture;
  89227. /**
  89228. * 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
  89229. * @param texture1 first texture to resize
  89230. * @param texture2 second texture to resize
  89231. * @param scene babylonjs scene
  89232. * @returns resized textures or null
  89233. */
  89234. private _resizeTexturesToSameDimensions;
  89235. /**
  89236. * Converts an array of pixels to a Float32Array
  89237. * Throws an error if the pixel format is not supported
  89238. * @param pixels - array buffer containing pixel values
  89239. * @returns Float32 of pixels
  89240. */
  89241. private _convertPixelArrayToFloat32;
  89242. /**
  89243. * Convert Specular Glossiness Textures to Metallic Roughness
  89244. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89245. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89246. * @param diffuseTexture texture used to store diffuse information
  89247. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89248. * @param factors specular glossiness material factors
  89249. * @param mimeType the mime type to use for the texture
  89250. * @returns pbr metallic roughness interface or null
  89251. */
  89252. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89253. /**
  89254. * Converts specular glossiness material properties to metallic roughness
  89255. * @param specularGlossiness interface with specular glossiness material properties
  89256. * @returns interface with metallic roughness material properties
  89257. */
  89258. private _convertSpecularGlossinessToMetallicRoughness;
  89259. /**
  89260. * Calculates the surface reflectance, independent of lighting conditions
  89261. * @param color Color source to calculate brightness from
  89262. * @returns number representing the perceived brightness, or zero if color is undefined
  89263. */
  89264. private _getPerceivedBrightness;
  89265. /**
  89266. * Returns the maximum color component value
  89267. * @param color
  89268. * @returns maximum color component value, or zero if color is null or undefined
  89269. */
  89270. private _getMaxComponent;
  89271. /**
  89272. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89273. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89274. * @param mimeType mime type to use for the textures
  89275. * @param images array of glTF image interfaces
  89276. * @param textures array of glTF texture interfaces
  89277. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89278. * @param imageData map of image file name to data
  89279. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89280. * @returns glTF PBR Metallic Roughness factors
  89281. */
  89282. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89283. private _getGLTFTextureSampler;
  89284. private _getGLTFTextureWrapMode;
  89285. private _getGLTFTextureWrapModesSampler;
  89286. /**
  89287. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89288. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89289. * @param mimeType mime type to use for the textures
  89290. * @param images array of glTF image interfaces
  89291. * @param textures array of glTF texture interfaces
  89292. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89293. * @param imageData map of image file name to data
  89294. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89295. * @returns glTF PBR Metallic Roughness factors
  89296. */
  89297. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89298. /**
  89299. * Converts a Babylon PBR Base Material to a glTF Material
  89300. * @param babylonPBRMaterial BJS PBR Base 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. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89309. private setMetallicRoughnessPbrMaterial;
  89310. private getPixelsFromTexture;
  89311. /**
  89312. * Extracts a texture from a Babylon texture into file data and glTF data
  89313. * @param babylonTexture Babylon texture to extract
  89314. * @param mimeType Mime Type of the babylonTexture
  89315. * @return glTF texture info, or null if the texture format is not supported
  89316. */
  89317. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89318. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89319. /**
  89320. * Builds a texture from base64 string
  89321. * @param base64Texture base64 texture string
  89322. * @param baseTextureName Name to use for the texture
  89323. * @param mimeType image mime type for the texture
  89324. * @param images array of images
  89325. * @param textures array of textures
  89326. * @param imageData map of image data
  89327. * @returns glTF texture info, or null if the texture format is not supported
  89328. */
  89329. private _getTextureInfoFromBase64;
  89330. }
  89331. }
  89332. declare module BABYLON {
  89333. /**
  89334. * Class for holding and downloading glTF file data
  89335. */
  89336. export class GLTFData {
  89337. /**
  89338. * Object which contains the file name as the key and its data as the value
  89339. */
  89340. glTFFiles: {
  89341. [fileName: string]: string | Blob;
  89342. };
  89343. /**
  89344. * Initializes the glTF file object
  89345. */
  89346. constructor();
  89347. /**
  89348. * Downloads the glTF data as files based on their names and data
  89349. */
  89350. downloadFiles(): void;
  89351. }
  89352. }
  89353. declare module BABYLON {
  89354. /**
  89355. * Holds a collection of exporter options and parameters
  89356. */
  89357. export interface IExportOptions {
  89358. /**
  89359. * Function which indicates whether a babylon node should be exported or not
  89360. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89361. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89362. */
  89363. shouldExportNode?(node: Node): boolean;
  89364. /**
  89365. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89366. * @param metadata source metadata to read from
  89367. * @returns the data to store to glTF node extras
  89368. */
  89369. metadataSelector?(metadata: any): any;
  89370. /**
  89371. * The sample rate to bake animation curves
  89372. */
  89373. animationSampleRate?: number;
  89374. /**
  89375. * Begin serialization without waiting for the scene to be ready
  89376. */
  89377. exportWithoutWaitingForScene?: boolean;
  89378. /**
  89379. * Indicates if coordinate system swapping root nodes should be included in export
  89380. */
  89381. includeCoordinateSystemConversionNodes?: boolean;
  89382. }
  89383. /**
  89384. * Class for generating glTF data from a Babylon scene.
  89385. */
  89386. export class GLTF2Export {
  89387. /**
  89388. * Exports the geometry of the scene to .gltf file format asynchronously
  89389. * @param scene Babylon scene with scene hierarchy information
  89390. * @param filePrefix File prefix to use when generating the glTF file
  89391. * @param options Exporter options
  89392. * @returns Returns an object with a .gltf file and associates texture names
  89393. * as keys and their data and paths as values
  89394. */
  89395. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89396. private static _PreExportAsync;
  89397. private static _PostExportAsync;
  89398. /**
  89399. * Exports the geometry of the scene to .glb file format asychronously
  89400. * @param scene Babylon scene with scene hierarchy information
  89401. * @param filePrefix File prefix to use when generating glb file
  89402. * @param options Exporter options
  89403. * @returns Returns an object with a .glb filename as key and data as value
  89404. */
  89405. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89406. }
  89407. }
  89408. declare module BABYLON.GLTF2.Exporter {
  89409. /**
  89410. * @hidden
  89411. */
  89412. export class _GLTFUtilities {
  89413. /**
  89414. * Creates a buffer view based on the supplied arguments
  89415. * @param bufferIndex index value of the specified buffer
  89416. * @param byteOffset byte offset value
  89417. * @param byteLength byte length of the bufferView
  89418. * @param byteStride byte distance between conequential elements
  89419. * @param name name of the buffer view
  89420. * @returns bufferView for glTF
  89421. */
  89422. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89423. /**
  89424. * Creates an accessor based on the supplied arguments
  89425. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89426. * @param name The name of the accessor
  89427. * @param type The type of the accessor
  89428. * @param componentType The datatype of components in the attribute
  89429. * @param count The number of attributes referenced by this accessor
  89430. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89431. * @param min Minimum value of each component in this attribute
  89432. * @param max Maximum value of each component in this attribute
  89433. * @returns accessor for glTF
  89434. */
  89435. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89436. /**
  89437. * Calculates the minimum and maximum values of an array of position floats
  89438. * @param positions Positions array of a mesh
  89439. * @param vertexStart Starting vertex offset to calculate min and max values
  89440. * @param vertexCount Number of vertices to check for min and max values
  89441. * @returns min number array and max number array
  89442. */
  89443. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89444. min: number[];
  89445. max: number[];
  89446. };
  89447. /**
  89448. * Converts a new right-handed Vector3
  89449. * @param vector vector3 array
  89450. * @returns right-handed Vector3
  89451. */
  89452. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89453. /**
  89454. * Converts a Vector3 to right-handed
  89455. * @param vector Vector3 to convert to right-handed
  89456. */
  89457. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89458. /**
  89459. * Converts a three element number array to right-handed
  89460. * @param vector number array to convert to right-handed
  89461. */
  89462. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89463. /**
  89464. * Converts a new right-handed Vector3
  89465. * @param vector vector3 array
  89466. * @returns right-handed Vector3
  89467. */
  89468. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89469. /**
  89470. * Converts a Vector3 to right-handed
  89471. * @param vector Vector3 to convert to right-handed
  89472. */
  89473. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89474. /**
  89475. * Converts a three element number array to right-handed
  89476. * @param vector number array to convert to right-handed
  89477. */
  89478. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89479. /**
  89480. * Converts a Vector4 to right-handed
  89481. * @param vector Vector4 to convert to right-handed
  89482. */
  89483. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89484. /**
  89485. * Converts a Vector4 to right-handed
  89486. * @param vector Vector4 to convert to right-handed
  89487. */
  89488. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89489. /**
  89490. * Converts a Quaternion to right-handed
  89491. * @param quaternion Source quaternion to convert to right-handed
  89492. */
  89493. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89494. /**
  89495. * Converts a Quaternion to right-handed
  89496. * @param quaternion Source quaternion to convert to right-handed
  89497. */
  89498. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89499. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89500. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89501. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89502. }
  89503. }
  89504. declare module BABYLON.GLTF2.Exporter {
  89505. /**
  89506. * Converts Babylon Scene into glTF 2.0.
  89507. * @hidden
  89508. */
  89509. export class _Exporter {
  89510. /**
  89511. * Stores the glTF to export
  89512. */
  89513. _glTF: IGLTF;
  89514. /**
  89515. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89516. */
  89517. _bufferViews: IBufferView[];
  89518. /**
  89519. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89520. */
  89521. _accessors: IAccessor[];
  89522. /**
  89523. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89524. */
  89525. _nodes: INode[];
  89526. /**
  89527. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89528. */
  89529. private _scenes;
  89530. /**
  89531. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89532. */
  89533. private _meshes;
  89534. /**
  89535. * Stores all the generated material information, which represents the appearance of each primitive
  89536. */
  89537. _materials: IMaterial[];
  89538. _materialMap: {
  89539. [materialID: number]: number;
  89540. };
  89541. /**
  89542. * Stores all the generated texture information, which is referenced by glTF materials
  89543. */
  89544. _textures: ITexture[];
  89545. /**
  89546. * Stores all the generated image information, which is referenced by glTF textures
  89547. */
  89548. _images: IImage[];
  89549. /**
  89550. * Stores all the texture samplers
  89551. */
  89552. _samplers: ISampler[];
  89553. /**
  89554. * Stores all the generated glTF skins
  89555. */
  89556. _skins: ISkin[];
  89557. /**
  89558. * Stores all the generated animation samplers, which is referenced by glTF animations
  89559. */
  89560. /**
  89561. * Stores the animations for glTF models
  89562. */
  89563. private _animations;
  89564. /**
  89565. * Stores the total amount of bytes stored in the glTF buffer
  89566. */
  89567. private _totalByteLength;
  89568. /**
  89569. * Stores a reference to the Babylon scene containing the source geometry and material information
  89570. */
  89571. _babylonScene: Scene;
  89572. /**
  89573. * Stores a map of the image data, where the key is the file name and the value
  89574. * is the image data
  89575. */
  89576. _imageData: {
  89577. [fileName: string]: {
  89578. data: Uint8Array;
  89579. mimeType: ImageMimeType;
  89580. };
  89581. };
  89582. protected _orderedImageData: Array<{
  89583. data: Uint8Array;
  89584. mimeType: ImageMimeType;
  89585. }>;
  89586. /**
  89587. * Stores a map of the unique id of a node to its index in the node array
  89588. */
  89589. _nodeMap: {
  89590. [key: number]: number;
  89591. };
  89592. /**
  89593. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89594. */
  89595. _convertToRightHandedSystem: boolean;
  89596. /**
  89597. * Specifies if a Babylon node should be converted to right-handed on export
  89598. */
  89599. _convertToRightHandedSystemMap: {
  89600. [nodeId: number]: boolean;
  89601. };
  89602. _includeCoordinateSystemConversionNodes: boolean;
  89603. /**
  89604. * Baked animation sample rate
  89605. */
  89606. private _animationSampleRate;
  89607. private _options;
  89608. private _localEngine;
  89609. _glTFMaterialExporter: _GLTFMaterialExporter;
  89610. private _extensions;
  89611. private static _ExtensionNames;
  89612. private static _ExtensionFactories;
  89613. private _applyExtension;
  89614. private _applyExtensions;
  89615. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89616. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89617. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89618. [key: number]: number;
  89619. }): Promise<Nullable<INode>>;
  89620. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89621. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89622. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89623. private _forEachExtensions;
  89624. private _extensionsOnExporting;
  89625. /**
  89626. * Load glTF serializer extensions
  89627. */
  89628. private _loadExtensions;
  89629. /**
  89630. * Creates a glTF Exporter instance, which can accept optional exporter options
  89631. * @param babylonScene Babylon scene object
  89632. * @param options Options to modify the behavior of the exporter
  89633. */
  89634. constructor(babylonScene: Scene, options?: IExportOptions);
  89635. dispose(): void;
  89636. /**
  89637. * Registers a glTF exporter extension
  89638. * @param name Name of the extension to export
  89639. * @param factory The factory function that creates the exporter extension
  89640. */
  89641. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89642. /**
  89643. * Un-registers an exporter extension
  89644. * @param name The name fo the exporter extension
  89645. * @returns A boolean indicating whether the extension has been un-registered
  89646. */
  89647. static UnregisterExtension(name: string): boolean;
  89648. private reorderIndicesBasedOnPrimitiveMode;
  89649. /**
  89650. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89651. * clock-wise during export to glTF
  89652. * @param submesh BabylonJS submesh
  89653. * @param primitiveMode Primitive mode of the mesh
  89654. * @param sideOrientation the winding order of the submesh
  89655. * @param vertexBufferKind The type of vertex attribute
  89656. * @param meshAttributeArray The vertex attribute data
  89657. * @param byteOffset The offset to the binary data
  89658. * @param binaryWriter The binary data for the glTF file
  89659. * @param convertToRightHandedSystem Converts the values to right-handed
  89660. */
  89661. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89662. /**
  89663. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89664. * clock-wise during export to glTF
  89665. * @param submesh BabylonJS submesh
  89666. * @param primitiveMode Primitive mode of the mesh
  89667. * @param sideOrientation the winding order of the submesh
  89668. * @param vertexBufferKind The type of vertex attribute
  89669. * @param meshAttributeArray The vertex attribute data
  89670. * @param byteOffset The offset to the binary data
  89671. * @param binaryWriter The binary data for the glTF file
  89672. * @param convertToRightHandedSystem Converts the values to right-handed
  89673. */
  89674. private reorderTriangleFillMode;
  89675. /**
  89676. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89677. * clock-wise during export to glTF
  89678. * @param submesh BabylonJS submesh
  89679. * @param primitiveMode Primitive mode of the mesh
  89680. * @param sideOrientation the winding order of the submesh
  89681. * @param vertexBufferKind The type of vertex attribute
  89682. * @param meshAttributeArray The vertex attribute data
  89683. * @param byteOffset The offset to the binary data
  89684. * @param binaryWriter The binary data for the glTF file
  89685. * @param convertToRightHandedSystem Converts the values to right-handed
  89686. */
  89687. private reorderTriangleStripDrawMode;
  89688. /**
  89689. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89690. * clock-wise during export to glTF
  89691. * @param submesh BabylonJS submesh
  89692. * @param primitiveMode Primitive mode of the mesh
  89693. * @param sideOrientation the winding order of the submesh
  89694. * @param vertexBufferKind The type of vertex attribute
  89695. * @param meshAttributeArray The vertex attribute data
  89696. * @param byteOffset The offset to the binary data
  89697. * @param binaryWriter The binary data for the glTF file
  89698. * @param convertToRightHandedSystem Converts the values to right-handed
  89699. */
  89700. private reorderTriangleFanMode;
  89701. /**
  89702. * Writes the vertex attribute data to binary
  89703. * @param vertices The vertices to write to the binary writer
  89704. * @param byteOffset The offset into the binary writer to overwrite binary data
  89705. * @param vertexAttributeKind The vertex attribute type
  89706. * @param meshAttributeArray The vertex attribute data
  89707. * @param binaryWriter The writer containing the binary data
  89708. * @param convertToRightHandedSystem Converts the values to right-handed
  89709. */
  89710. private writeVertexAttributeData;
  89711. /**
  89712. * Writes mesh attribute data to a data buffer
  89713. * Returns the bytelength of the data
  89714. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89715. * @param meshAttributeArray Array containing the attribute data
  89716. * @param byteStride Specifies the space between data
  89717. * @param binaryWriter The buffer to write the binary data to
  89718. * @param convertToRightHandedSystem Converts the values to right-handed
  89719. */
  89720. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89721. /**
  89722. * Writes mesh attribute data to a data buffer
  89723. * Returns the bytelength of the data
  89724. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89725. * @param meshAttributeArray Array containing the attribute data
  89726. * @param byteStride Specifies the space between data
  89727. * @param binaryWriter The buffer to write the binary data to
  89728. * @param convertToRightHandedSystem Converts the values to right-handed
  89729. */
  89730. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89731. /**
  89732. * Generates glTF json data
  89733. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89734. * @param glTFPrefix Text to use when prefixing a glTF file
  89735. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89736. * @returns json data as string
  89737. */
  89738. private generateJSON;
  89739. /**
  89740. * Generates data for .gltf and .bin files based on the glTF prefix string
  89741. * @param glTFPrefix Text to use when prefixing a glTF file
  89742. * @param dispose Dispose the exporter
  89743. * @returns GLTFData with glTF file data
  89744. */
  89745. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89746. /**
  89747. * Creates a binary buffer for glTF
  89748. * @returns array buffer for binary data
  89749. */
  89750. private _generateBinaryAsync;
  89751. /**
  89752. * Pads the number to a multiple of 4
  89753. * @param num number to pad
  89754. * @returns padded number
  89755. */
  89756. private _getPadding;
  89757. /**
  89758. * @hidden
  89759. */
  89760. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89761. /**
  89762. * Sets the TRS for each node
  89763. * @param node glTF Node for storing the transformation data
  89764. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89765. * @param convertToRightHandedSystem Converts the values to right-handed
  89766. */
  89767. private setNodeTransformation;
  89768. private getVertexBufferFromMesh;
  89769. /**
  89770. * Creates a bufferview based on the vertices type for the Babylon mesh
  89771. * @param kind Indicates the type of vertices data
  89772. * @param componentType Indicates the numerical type used to store the data
  89773. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89774. * @param binaryWriter The buffer to write the bufferview data to
  89775. * @param convertToRightHandedSystem Converts the values to right-handed
  89776. */
  89777. private createBufferViewKind;
  89778. /**
  89779. * Creates a bufferview based on the vertices type for the Babylon mesh
  89780. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89781. * @param babylonMorphTarget the morph target to be exported
  89782. * @param binaryWriter The buffer to write the bufferview data to
  89783. * @param convertToRightHandedSystem Converts the values to right-handed
  89784. */
  89785. private setMorphTargetAttributes;
  89786. /**
  89787. * The primitive mode of the Babylon mesh
  89788. * @param babylonMesh The BabylonJS mesh
  89789. */
  89790. private getMeshPrimitiveMode;
  89791. /**
  89792. * Sets the primitive mode of the glTF mesh primitive
  89793. * @param meshPrimitive glTF mesh primitive
  89794. * @param primitiveMode The primitive mode
  89795. */
  89796. private setPrimitiveMode;
  89797. /**
  89798. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89799. * @param meshPrimitive glTF mesh primitive
  89800. * @param attributeKind vertex attribute
  89801. * @returns boolean specifying if uv coordinates are present
  89802. */
  89803. private setAttributeKind;
  89804. /**
  89805. * Sets data for the primitive attributes of each submesh
  89806. * @param mesh glTF Mesh object to store the primitive attribute information
  89807. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89808. * @param binaryWriter Buffer to write the attribute data to
  89809. * @param convertToRightHandedSystem Converts the values to right-handed
  89810. */
  89811. private setPrimitiveAttributesAsync;
  89812. /**
  89813. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89814. * @param node The node to check
  89815. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89816. */
  89817. private isBabylonCoordinateSystemConvertingNode;
  89818. /**
  89819. * Creates a glTF scene based on the array of meshes
  89820. * Returns the the total byte offset
  89821. * @param babylonScene Babylon scene to get the mesh data from
  89822. * @param binaryWriter Buffer to write binary data to
  89823. */
  89824. private createSceneAsync;
  89825. /**
  89826. * Creates a mapping of Node unique id to node index and handles animations
  89827. * @param babylonScene Babylon Scene
  89828. * @param nodes Babylon transform nodes
  89829. * @param binaryWriter Buffer to write binary data to
  89830. * @returns Node mapping of unique id to index
  89831. */
  89832. private createNodeMapAndAnimationsAsync;
  89833. /**
  89834. * Creates a glTF node from a Babylon mesh
  89835. * @param babylonMesh Source Babylon mesh
  89836. * @param binaryWriter Buffer for storing geometry data
  89837. * @param convertToRightHandedSystem Converts the values to right-handed
  89838. * @param nodeMap Node mapping of unique id to glTF node index
  89839. * @returns glTF node
  89840. */
  89841. private createNodeAsync;
  89842. /**
  89843. * Creates a glTF skin from a Babylon skeleton
  89844. * @param babylonScene Babylon Scene
  89845. * @param nodes Babylon transform nodes
  89846. * @param binaryWriter Buffer to write binary data to
  89847. * @returns Node mapping of unique id to index
  89848. */
  89849. private createSkinsAsync;
  89850. }
  89851. /**
  89852. * @hidden
  89853. *
  89854. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  89855. */
  89856. export class _BinaryWriter {
  89857. /**
  89858. * Array buffer which stores all binary data
  89859. */
  89860. private _arrayBuffer;
  89861. /**
  89862. * View of the array buffer
  89863. */
  89864. private _dataView;
  89865. /**
  89866. * byte offset of data in array buffer
  89867. */
  89868. private _byteOffset;
  89869. /**
  89870. * Initialize binary writer with an initial byte length
  89871. * @param byteLength Initial byte length of the array buffer
  89872. */
  89873. constructor(byteLength: number);
  89874. /**
  89875. * Resize the array buffer to the specified byte length
  89876. * @param byteLength
  89877. */
  89878. private resizeBuffer;
  89879. /**
  89880. * Get an array buffer with the length of the byte offset
  89881. * @returns ArrayBuffer resized to the byte offset
  89882. */
  89883. getArrayBuffer(): ArrayBuffer;
  89884. /**
  89885. * Get the byte offset of the array buffer
  89886. * @returns byte offset
  89887. */
  89888. getByteOffset(): number;
  89889. /**
  89890. * Stores an UInt8 in the array buffer
  89891. * @param entry
  89892. * @param byteOffset If defined, specifies where to set the value as an offset.
  89893. */
  89894. setUInt8(entry: number, byteOffset?: number): void;
  89895. /**
  89896. * Stores an UInt16 in the array buffer
  89897. * @param entry
  89898. * @param byteOffset If defined, specifies where to set the value as an offset.
  89899. */
  89900. setUInt16(entry: number, byteOffset?: number): void;
  89901. /**
  89902. * Gets an UInt32 in the array buffer
  89903. * @param entry
  89904. * @param byteOffset If defined, specifies where to set the value as an offset.
  89905. */
  89906. getUInt32(byteOffset: number): number;
  89907. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89908. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89909. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89910. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89911. /**
  89912. * Stores a Float32 in the array buffer
  89913. * @param entry
  89914. */
  89915. setFloat32(entry: number, byteOffset?: number): void;
  89916. /**
  89917. * Stores an UInt32 in the array buffer
  89918. * @param entry
  89919. * @param byteOffset If defined, specifies where to set the value as an offset.
  89920. */
  89921. setUInt32(entry: number, byteOffset?: number): void;
  89922. }
  89923. }
  89924. declare module BABYLON.GLTF2.Exporter {
  89925. /**
  89926. * @hidden
  89927. * Interface to store animation data.
  89928. */
  89929. export interface _IAnimationData {
  89930. /**
  89931. * Keyframe data.
  89932. */
  89933. inputs: number[];
  89934. /**
  89935. * Value data.
  89936. */
  89937. outputs: number[][];
  89938. /**
  89939. * Animation interpolation data.
  89940. */
  89941. samplerInterpolation: AnimationSamplerInterpolation;
  89942. /**
  89943. * Minimum keyframe value.
  89944. */
  89945. inputsMin: number;
  89946. /**
  89947. * Maximum keyframe value.
  89948. */
  89949. inputsMax: number;
  89950. }
  89951. /**
  89952. * @hidden
  89953. */
  89954. export interface _IAnimationInfo {
  89955. /**
  89956. * The target channel for the animation
  89957. */
  89958. animationChannelTargetPath: AnimationChannelTargetPath;
  89959. /**
  89960. * The glTF accessor type for the data.
  89961. */
  89962. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  89963. /**
  89964. * Specifies if quaternions should be used.
  89965. */
  89966. useQuaternion: boolean;
  89967. }
  89968. /**
  89969. * @hidden
  89970. * Utility class for generating glTF animation data from BabylonJS.
  89971. */
  89972. export class _GLTFAnimation {
  89973. /**
  89974. * @ignore
  89975. *
  89976. * Creates glTF channel animation from BabylonJS animation.
  89977. * @param babylonTransformNode - BabylonJS mesh.
  89978. * @param animation - animation.
  89979. * @param animationChannelTargetPath - The target animation channel.
  89980. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  89981. * @param useQuaternion - Specifies if quaternions are used.
  89982. * @returns nullable IAnimationData
  89983. */
  89984. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  89985. private static _DeduceAnimationInfo;
  89986. /**
  89987. * @ignore
  89988. * Create node animations from the transform node animations
  89989. * @param babylonNode
  89990. * @param runtimeGLTFAnimation
  89991. * @param idleGLTFAnimations
  89992. * @param nodeMap
  89993. * @param nodes
  89994. * @param binaryWriter
  89995. * @param bufferViews
  89996. * @param accessors
  89997. * @param convertToRightHandedSystem
  89998. * @param animationSampleRate
  89999. */
  90000. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90001. [key: number]: number;
  90002. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90003. /**
  90004. * @ignore
  90005. * Create individual morph animations from the mesh's morph target animation tracks
  90006. * @param babylonNode
  90007. * @param runtimeGLTFAnimation
  90008. * @param idleGLTFAnimations
  90009. * @param nodeMap
  90010. * @param nodes
  90011. * @param binaryWriter
  90012. * @param bufferViews
  90013. * @param accessors
  90014. * @param convertToRightHandedSystem
  90015. * @param animationSampleRate
  90016. */
  90017. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90018. [key: number]: number;
  90019. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90020. /**
  90021. * @ignore
  90022. * Create node and morph animations from the animation groups
  90023. * @param babylonScene
  90024. * @param glTFAnimations
  90025. * @param nodeMap
  90026. * @param nodes
  90027. * @param binaryWriter
  90028. * @param bufferViews
  90029. * @param accessors
  90030. * @param convertToRightHandedSystemMap
  90031. * @param animationSampleRate
  90032. */
  90033. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90034. [key: number]: number;
  90035. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90036. [nodeId: number]: boolean;
  90037. }, animationSampleRate: number): void;
  90038. private static AddAnimation;
  90039. /**
  90040. * Create a baked animation
  90041. * @param babylonTransformNode BabylonJS mesh
  90042. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90043. * @param animationChannelTargetPath animation target channel
  90044. * @param minFrame minimum animation frame
  90045. * @param maxFrame maximum animation frame
  90046. * @param fps frames per second of the animation
  90047. * @param inputs input key frames of the animation
  90048. * @param outputs output key frame data of the animation
  90049. * @param convertToRightHandedSystem converts the values to right-handed
  90050. * @param useQuaternion specifies if quaternions should be used
  90051. */
  90052. private static _CreateBakedAnimation;
  90053. private static _ConvertFactorToVector3OrQuaternion;
  90054. private static _SetInterpolatedValue;
  90055. /**
  90056. * Creates linear animation from the animation key frames
  90057. * @param babylonTransformNode BabylonJS mesh
  90058. * @param animation BabylonJS animation
  90059. * @param animationChannelTargetPath The target animation channel
  90060. * @param frameDelta The difference between the last and first frame of the animation
  90061. * @param inputs Array to store the key frame times
  90062. * @param outputs Array to store the key frame data
  90063. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90064. * @param useQuaternion Specifies if quaternions are used in the animation
  90065. */
  90066. private static _CreateLinearOrStepAnimation;
  90067. /**
  90068. * Creates cubic spline animation from the animation key frames
  90069. * @param babylonTransformNode BabylonJS mesh
  90070. * @param animation BabylonJS animation
  90071. * @param animationChannelTargetPath The target animation channel
  90072. * @param frameDelta The difference between the last and first frame of the animation
  90073. * @param inputs Array to store the key frame times
  90074. * @param outputs Array to store the key frame data
  90075. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90076. * @param useQuaternion Specifies if quaternions are used in the animation
  90077. */
  90078. private static _CreateCubicSplineAnimation;
  90079. private static _GetBasePositionRotationOrScale;
  90080. /**
  90081. * Adds a key frame value
  90082. * @param keyFrame
  90083. * @param animation
  90084. * @param outputs
  90085. * @param animationChannelTargetPath
  90086. * @param basePositionRotationOrScale
  90087. * @param convertToRightHandedSystem
  90088. * @param useQuaternion
  90089. */
  90090. private static _AddKeyframeValue;
  90091. /**
  90092. * Determine the interpolation based on the key frames
  90093. * @param keyFrames
  90094. * @param animationChannelTargetPath
  90095. * @param useQuaternion
  90096. */
  90097. private static _DeduceInterpolation;
  90098. /**
  90099. * Adds an input tangent or output tangent to the output data
  90100. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90101. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90102. * @param outputs The animation data by keyframe
  90103. * @param animationChannelTargetPath The target animation channel
  90104. * @param interpolation The interpolation type
  90105. * @param keyFrame The key frame with the animation data
  90106. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90107. * @param useQuaternion Specifies if quaternions are used
  90108. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90109. */
  90110. private static AddSplineTangent;
  90111. /**
  90112. * Get the minimum and maximum key frames' frame values
  90113. * @param keyFrames animation key frames
  90114. * @returns the minimum and maximum key frame value
  90115. */
  90116. private static calculateMinMaxKeyFrames;
  90117. }
  90118. }
  90119. declare module BABYLON.GLTF2.Exporter {
  90120. /** @hidden */
  90121. export var textureTransformPixelShader: {
  90122. name: string;
  90123. shader: string;
  90124. };
  90125. }
  90126. declare module BABYLON.GLTF2.Exporter.Extensions {
  90127. /**
  90128. * @hidden
  90129. */
  90130. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90131. private _recordedTextures;
  90132. /** Name of this extension */
  90133. readonly name: string;
  90134. /** Defines whether this extension is enabled */
  90135. enabled: boolean;
  90136. /** Defines whether this extension is required */
  90137. required: boolean;
  90138. /** Reference to the glTF exporter */
  90139. private _wasUsed;
  90140. constructor(exporter: _Exporter);
  90141. dispose(): void;
  90142. /** @hidden */
  90143. get wasUsed(): boolean;
  90144. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90145. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90146. /**
  90147. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90148. * @param babylonTexture
  90149. * @param offset
  90150. * @param rotation
  90151. * @param scale
  90152. * @param scene
  90153. */
  90154. private _textureTransformTextureAsync;
  90155. }
  90156. }
  90157. declare module BABYLON.GLTF2.Exporter.Extensions {
  90158. /**
  90159. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90160. */
  90161. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90162. /** The name of this extension. */
  90163. readonly name: string;
  90164. /** Defines whether this extension is enabled. */
  90165. enabled: boolean;
  90166. /** Defines whether this extension is required */
  90167. required: boolean;
  90168. /** Reference to the glTF exporter */
  90169. private _exporter;
  90170. private _lights;
  90171. /** @hidden */
  90172. constructor(exporter: _Exporter);
  90173. /** @hidden */
  90174. dispose(): void;
  90175. /** @hidden */
  90176. get wasUsed(): boolean;
  90177. /** @hidden */
  90178. onExporting(): void;
  90179. /**
  90180. * Define this method to modify the default behavior when exporting a node
  90181. * @param context The context when exporting the node
  90182. * @param node glTF node
  90183. * @param babylonNode BabylonJS node
  90184. * @param nodeMap Node mapping of unique id to glTF node index
  90185. * @returns nullable INode promise
  90186. */
  90187. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90188. [key: number]: number;
  90189. }): Promise<Nullable<INode>>;
  90190. }
  90191. }
  90192. declare module BABYLON.GLTF2.Exporter.Extensions {
  90193. /**
  90194. * @hidden
  90195. */
  90196. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90197. /** Name of this extension */
  90198. readonly name: string;
  90199. /** Defines whether this extension is enabled */
  90200. enabled: boolean;
  90201. /** Defines whether this extension is required */
  90202. required: boolean;
  90203. /** Reference to the glTF exporter */
  90204. private _textureInfos;
  90205. private _exportedTextures;
  90206. private _wasUsed;
  90207. constructor(exporter: _Exporter);
  90208. dispose(): void;
  90209. /** @hidden */
  90210. get wasUsed(): boolean;
  90211. private _getTextureIndex;
  90212. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90213. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90214. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90215. }
  90216. }
  90217. declare module BABYLON.GLTF2.Exporter.Extensions {
  90218. /**
  90219. * @hidden
  90220. */
  90221. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90222. /** Name of this extension */
  90223. readonly name: string;
  90224. /** Defines whether this extension is enabled */
  90225. enabled: boolean;
  90226. /** Defines whether this extension is required */
  90227. required: boolean;
  90228. private _wasUsed;
  90229. constructor(exporter: _Exporter);
  90230. /** @hidden */
  90231. get wasUsed(): boolean;
  90232. dispose(): void;
  90233. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90234. }
  90235. }
  90236. declare module BABYLON {
  90237. /**
  90238. * Class for generating STL data from a Babylon scene.
  90239. */
  90240. export class STLExport {
  90241. /**
  90242. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90243. * @param meshes list defines the mesh to serialize
  90244. * @param download triggers the automatic download of the file.
  90245. * @param fileName changes the downloads fileName.
  90246. * @param binary changes the STL to a binary type.
  90247. * @param isLittleEndian toggle for binary type exporter.
  90248. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90249. * @returns the STL as UTF8 string
  90250. */
  90251. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90252. }
  90253. }
  90254. declare module "babylonjs-gltf2interface" {
  90255. export = BABYLON.GLTF2;
  90256. }
  90257. /**
  90258. * Module for glTF 2.0 Interface
  90259. */
  90260. declare module BABYLON.GLTF2 {
  90261. /**
  90262. * The datatype of the components in the attribute
  90263. */
  90264. const enum AccessorComponentType {
  90265. /**
  90266. * Byte
  90267. */
  90268. BYTE = 5120,
  90269. /**
  90270. * Unsigned Byte
  90271. */
  90272. UNSIGNED_BYTE = 5121,
  90273. /**
  90274. * Short
  90275. */
  90276. SHORT = 5122,
  90277. /**
  90278. * Unsigned Short
  90279. */
  90280. UNSIGNED_SHORT = 5123,
  90281. /**
  90282. * Unsigned Int
  90283. */
  90284. UNSIGNED_INT = 5125,
  90285. /**
  90286. * Float
  90287. */
  90288. FLOAT = 5126,
  90289. }
  90290. /**
  90291. * Specifies if the attirbute is a scalar, vector, or matrix
  90292. */
  90293. const enum AccessorType {
  90294. /**
  90295. * Scalar
  90296. */
  90297. SCALAR = "SCALAR",
  90298. /**
  90299. * Vector2
  90300. */
  90301. VEC2 = "VEC2",
  90302. /**
  90303. * Vector3
  90304. */
  90305. VEC3 = "VEC3",
  90306. /**
  90307. * Vector4
  90308. */
  90309. VEC4 = "VEC4",
  90310. /**
  90311. * Matrix2x2
  90312. */
  90313. MAT2 = "MAT2",
  90314. /**
  90315. * Matrix3x3
  90316. */
  90317. MAT3 = "MAT3",
  90318. /**
  90319. * Matrix4x4
  90320. */
  90321. MAT4 = "MAT4",
  90322. }
  90323. /**
  90324. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90325. */
  90326. const enum AnimationChannelTargetPath {
  90327. /**
  90328. * Translation
  90329. */
  90330. TRANSLATION = "translation",
  90331. /**
  90332. * Rotation
  90333. */
  90334. ROTATION = "rotation",
  90335. /**
  90336. * Scale
  90337. */
  90338. SCALE = "scale",
  90339. /**
  90340. * Weights
  90341. */
  90342. WEIGHTS = "weights",
  90343. }
  90344. /**
  90345. * Interpolation algorithm
  90346. */
  90347. const enum AnimationSamplerInterpolation {
  90348. /**
  90349. * The animated values are linearly interpolated between keyframes
  90350. */
  90351. LINEAR = "LINEAR",
  90352. /**
  90353. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90354. */
  90355. STEP = "STEP",
  90356. /**
  90357. * The animation's interpolation is computed using a cubic spline with specified tangents
  90358. */
  90359. CUBICSPLINE = "CUBICSPLINE",
  90360. }
  90361. /**
  90362. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90363. */
  90364. const enum CameraType {
  90365. /**
  90366. * A perspective camera containing properties to create a perspective projection matrix
  90367. */
  90368. PERSPECTIVE = "perspective",
  90369. /**
  90370. * An orthographic camera containing properties to create an orthographic projection matrix
  90371. */
  90372. ORTHOGRAPHIC = "orthographic",
  90373. }
  90374. /**
  90375. * The mime-type of the image
  90376. */
  90377. const enum ImageMimeType {
  90378. /**
  90379. * JPEG Mime-type
  90380. */
  90381. JPEG = "image/jpeg",
  90382. /**
  90383. * PNG Mime-type
  90384. */
  90385. PNG = "image/png",
  90386. }
  90387. /**
  90388. * The alpha rendering mode of the material
  90389. */
  90390. const enum MaterialAlphaMode {
  90391. /**
  90392. * The alpha value is ignored and the rendered output is fully opaque
  90393. */
  90394. OPAQUE = "OPAQUE",
  90395. /**
  90396. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90397. */
  90398. MASK = "MASK",
  90399. /**
  90400. * 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)
  90401. */
  90402. BLEND = "BLEND",
  90403. }
  90404. /**
  90405. * The type of the primitives to render
  90406. */
  90407. const enum MeshPrimitiveMode {
  90408. /**
  90409. * Points
  90410. */
  90411. POINTS = 0,
  90412. /**
  90413. * Lines
  90414. */
  90415. LINES = 1,
  90416. /**
  90417. * Line Loop
  90418. */
  90419. LINE_LOOP = 2,
  90420. /**
  90421. * Line Strip
  90422. */
  90423. LINE_STRIP = 3,
  90424. /**
  90425. * Triangles
  90426. */
  90427. TRIANGLES = 4,
  90428. /**
  90429. * Triangle Strip
  90430. */
  90431. TRIANGLE_STRIP = 5,
  90432. /**
  90433. * Triangle Fan
  90434. */
  90435. TRIANGLE_FAN = 6,
  90436. }
  90437. /**
  90438. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90439. */
  90440. const enum TextureMagFilter {
  90441. /**
  90442. * Nearest
  90443. */
  90444. NEAREST = 9728,
  90445. /**
  90446. * Linear
  90447. */
  90448. LINEAR = 9729,
  90449. }
  90450. /**
  90451. * Minification filter. All valid values correspond to WebGL enums
  90452. */
  90453. const enum TextureMinFilter {
  90454. /**
  90455. * Nearest
  90456. */
  90457. NEAREST = 9728,
  90458. /**
  90459. * Linear
  90460. */
  90461. LINEAR = 9729,
  90462. /**
  90463. * Nearest Mip-Map Nearest
  90464. */
  90465. NEAREST_MIPMAP_NEAREST = 9984,
  90466. /**
  90467. * Linear Mipmap Nearest
  90468. */
  90469. LINEAR_MIPMAP_NEAREST = 9985,
  90470. /**
  90471. * Nearest Mipmap Linear
  90472. */
  90473. NEAREST_MIPMAP_LINEAR = 9986,
  90474. /**
  90475. * Linear Mipmap Linear
  90476. */
  90477. LINEAR_MIPMAP_LINEAR = 9987,
  90478. }
  90479. /**
  90480. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90481. */
  90482. const enum TextureWrapMode {
  90483. /**
  90484. * Clamp to Edge
  90485. */
  90486. CLAMP_TO_EDGE = 33071,
  90487. /**
  90488. * Mirrored Repeat
  90489. */
  90490. MIRRORED_REPEAT = 33648,
  90491. /**
  90492. * Repeat
  90493. */
  90494. REPEAT = 10497,
  90495. }
  90496. /**
  90497. * glTF Property
  90498. */
  90499. interface IProperty {
  90500. /**
  90501. * Dictionary object with extension-specific objects
  90502. */
  90503. extensions?: {
  90504. [key: string]: any;
  90505. };
  90506. /**
  90507. * Application-Specific data
  90508. */
  90509. extras?: any;
  90510. }
  90511. /**
  90512. * glTF Child of Root Property
  90513. */
  90514. interface IChildRootProperty extends IProperty {
  90515. /**
  90516. * The user-defined name of this object
  90517. */
  90518. name?: string;
  90519. }
  90520. /**
  90521. * Indices of those attributes that deviate from their initialization value
  90522. */
  90523. interface IAccessorSparseIndices extends IProperty {
  90524. /**
  90525. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90526. */
  90527. bufferView: number;
  90528. /**
  90529. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90530. */
  90531. byteOffset?: number;
  90532. /**
  90533. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90534. */
  90535. componentType: AccessorComponentType;
  90536. }
  90537. /**
  90538. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90539. */
  90540. interface IAccessorSparseValues extends IProperty {
  90541. /**
  90542. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90543. */
  90544. bufferView: number;
  90545. /**
  90546. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90547. */
  90548. byteOffset?: number;
  90549. }
  90550. /**
  90551. * Sparse storage of attributes that deviate from their initialization value
  90552. */
  90553. interface IAccessorSparse extends IProperty {
  90554. /**
  90555. * The number of attributes encoded in this sparse accessor
  90556. */
  90557. count: number;
  90558. /**
  90559. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90560. */
  90561. indices: IAccessorSparseIndices;
  90562. /**
  90563. * 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
  90564. */
  90565. values: IAccessorSparseValues;
  90566. }
  90567. /**
  90568. * 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
  90569. */
  90570. interface IAccessor extends IChildRootProperty {
  90571. /**
  90572. * The index of the bufferview
  90573. */
  90574. bufferView?: number;
  90575. /**
  90576. * The offset relative to the start of the bufferView in bytes
  90577. */
  90578. byteOffset?: number;
  90579. /**
  90580. * The datatype of components in the attribute
  90581. */
  90582. componentType: AccessorComponentType;
  90583. /**
  90584. * Specifies whether integer data values should be normalized
  90585. */
  90586. normalized?: boolean;
  90587. /**
  90588. * The number of attributes referenced by this accessor
  90589. */
  90590. count: number;
  90591. /**
  90592. * Specifies if the attribute is a scalar, vector, or matrix
  90593. */
  90594. type: AccessorType;
  90595. /**
  90596. * Maximum value of each component in this attribute
  90597. */
  90598. max?: number[];
  90599. /**
  90600. * Minimum value of each component in this attribute
  90601. */
  90602. min?: number[];
  90603. /**
  90604. * Sparse storage of attributes that deviate from their initialization value
  90605. */
  90606. sparse?: IAccessorSparse;
  90607. }
  90608. /**
  90609. * Targets an animation's sampler at a node's property
  90610. */
  90611. interface IAnimationChannel extends IProperty {
  90612. /**
  90613. * The index of a sampler in this animation used to compute the value for the target
  90614. */
  90615. sampler: number;
  90616. /**
  90617. * The index of the node and TRS property to target
  90618. */
  90619. target: IAnimationChannelTarget;
  90620. }
  90621. /**
  90622. * The index of the node and TRS property that an animation channel targets
  90623. */
  90624. interface IAnimationChannelTarget extends IProperty {
  90625. /**
  90626. * The index of the node to target
  90627. */
  90628. node: number;
  90629. /**
  90630. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90631. */
  90632. path: AnimationChannelTargetPath;
  90633. }
  90634. /**
  90635. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90636. */
  90637. interface IAnimationSampler extends IProperty {
  90638. /**
  90639. * The index of an accessor containing keyframe input values, e.g., time
  90640. */
  90641. input: number;
  90642. /**
  90643. * Interpolation algorithm
  90644. */
  90645. interpolation?: AnimationSamplerInterpolation;
  90646. /**
  90647. * The index of an accessor, containing keyframe output values
  90648. */
  90649. output: number;
  90650. }
  90651. /**
  90652. * A keyframe animation
  90653. */
  90654. interface IAnimation extends IChildRootProperty {
  90655. /**
  90656. * An array of channels, each of which targets an animation's sampler at a node's property
  90657. */
  90658. channels: IAnimationChannel[];
  90659. /**
  90660. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90661. */
  90662. samplers: IAnimationSampler[];
  90663. }
  90664. /**
  90665. * Metadata about the glTF asset
  90666. */
  90667. interface IAsset extends IChildRootProperty {
  90668. /**
  90669. * A copyright message suitable for display to credit the content creator
  90670. */
  90671. copyright?: string;
  90672. /**
  90673. * Tool that generated this glTF model. Useful for debugging
  90674. */
  90675. generator?: string;
  90676. /**
  90677. * The glTF version that this asset targets
  90678. */
  90679. version: string;
  90680. /**
  90681. * The minimum glTF version that this asset targets
  90682. */
  90683. minVersion?: string;
  90684. }
  90685. /**
  90686. * A buffer points to binary geometry, animation, or skins
  90687. */
  90688. interface IBuffer extends IChildRootProperty {
  90689. /**
  90690. * 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
  90691. */
  90692. uri?: string;
  90693. /**
  90694. * The length of the buffer in bytes
  90695. */
  90696. byteLength: number;
  90697. }
  90698. /**
  90699. * A view into a buffer generally representing a subset of the buffer
  90700. */
  90701. interface IBufferView extends IChildRootProperty {
  90702. /**
  90703. * The index of the buffer
  90704. */
  90705. buffer: number;
  90706. /**
  90707. * The offset into the buffer in bytes
  90708. */
  90709. byteOffset?: number;
  90710. /**
  90711. * The lenth of the bufferView in bytes
  90712. */
  90713. byteLength: number;
  90714. /**
  90715. * The stride, in bytes
  90716. */
  90717. byteStride?: number;
  90718. }
  90719. /**
  90720. * An orthographic camera containing properties to create an orthographic projection matrix
  90721. */
  90722. interface ICameraOrthographic extends IProperty {
  90723. /**
  90724. * The floating-point horizontal magnification of the view. Must not be zero
  90725. */
  90726. xmag: number;
  90727. /**
  90728. * The floating-point vertical magnification of the view. Must not be zero
  90729. */
  90730. ymag: number;
  90731. /**
  90732. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90733. */
  90734. zfar: number;
  90735. /**
  90736. * The floating-point distance to the near clipping plane
  90737. */
  90738. znear: number;
  90739. }
  90740. /**
  90741. * A perspective camera containing properties to create a perspective projection matrix
  90742. */
  90743. interface ICameraPerspective extends IProperty {
  90744. /**
  90745. * The floating-point aspect ratio of the field of view
  90746. */
  90747. aspectRatio?: number;
  90748. /**
  90749. * The floating-point vertical field of view in radians
  90750. */
  90751. yfov: number;
  90752. /**
  90753. * The floating-point distance to the far clipping plane
  90754. */
  90755. zfar?: number;
  90756. /**
  90757. * The floating-point distance to the near clipping plane
  90758. */
  90759. znear: number;
  90760. }
  90761. /**
  90762. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90763. */
  90764. interface ICamera extends IChildRootProperty {
  90765. /**
  90766. * An orthographic camera containing properties to create an orthographic projection matrix
  90767. */
  90768. orthographic?: ICameraOrthographic;
  90769. /**
  90770. * A perspective camera containing properties to create a perspective projection matrix
  90771. */
  90772. perspective?: ICameraPerspective;
  90773. /**
  90774. * Specifies if the camera uses a perspective or orthographic projection
  90775. */
  90776. type: CameraType;
  90777. }
  90778. /**
  90779. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90780. */
  90781. interface IImage extends IChildRootProperty {
  90782. /**
  90783. * 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
  90784. */
  90785. uri?: string;
  90786. /**
  90787. * The image's MIME type
  90788. */
  90789. mimeType?: ImageMimeType;
  90790. /**
  90791. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90792. */
  90793. bufferView?: number;
  90794. }
  90795. /**
  90796. * Material Normal Texture Info
  90797. */
  90798. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90799. /**
  90800. * The scalar multiplier applied to each normal vector of the normal texture
  90801. */
  90802. scale?: number;
  90803. }
  90804. /**
  90805. * Material Occlusion Texture Info
  90806. */
  90807. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90808. /**
  90809. * A scalar multiplier controlling the amount of occlusion applied
  90810. */
  90811. strength?: number;
  90812. }
  90813. /**
  90814. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90815. */
  90816. interface IMaterialPbrMetallicRoughness {
  90817. /**
  90818. * The material's base color factor
  90819. */
  90820. baseColorFactor?: number[];
  90821. /**
  90822. * The base color texture
  90823. */
  90824. baseColorTexture?: ITextureInfo;
  90825. /**
  90826. * The metalness of the material
  90827. */
  90828. metallicFactor?: number;
  90829. /**
  90830. * The roughness of the material
  90831. */
  90832. roughnessFactor?: number;
  90833. /**
  90834. * The metallic-roughness texture
  90835. */
  90836. metallicRoughnessTexture?: ITextureInfo;
  90837. }
  90838. /**
  90839. * The material appearance of a primitive
  90840. */
  90841. interface IMaterial extends IChildRootProperty {
  90842. /**
  90843. * 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
  90844. */
  90845. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  90846. /**
  90847. * The normal map texture
  90848. */
  90849. normalTexture?: IMaterialNormalTextureInfo;
  90850. /**
  90851. * The occlusion map texture
  90852. */
  90853. occlusionTexture?: IMaterialOcclusionTextureInfo;
  90854. /**
  90855. * The emissive map texture
  90856. */
  90857. emissiveTexture?: ITextureInfo;
  90858. /**
  90859. * 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
  90860. */
  90861. emissiveFactor?: number[];
  90862. /**
  90863. * The alpha rendering mode of the material
  90864. */
  90865. alphaMode?: MaterialAlphaMode;
  90866. /**
  90867. * The alpha cutoff value of the material
  90868. */
  90869. alphaCutoff?: number;
  90870. /**
  90871. * Specifies whether the material is double sided
  90872. */
  90873. doubleSided?: boolean;
  90874. }
  90875. /**
  90876. * Geometry to be rendered with the given material
  90877. */
  90878. interface IMeshPrimitive extends IProperty {
  90879. /**
  90880. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  90881. */
  90882. attributes: {
  90883. [name: string]: number;
  90884. };
  90885. /**
  90886. * The index of the accessor that contains the indices
  90887. */
  90888. indices?: number;
  90889. /**
  90890. * The index of the material to apply to this primitive when rendering
  90891. */
  90892. material?: number;
  90893. /**
  90894. * The type of primitives to render. All valid values correspond to WebGL enums
  90895. */
  90896. mode?: MeshPrimitiveMode;
  90897. /**
  90898. * 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
  90899. */
  90900. targets?: {
  90901. [name: string]: number;
  90902. }[];
  90903. }
  90904. /**
  90905. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  90906. */
  90907. interface IMesh extends IChildRootProperty {
  90908. /**
  90909. * An array of primitives, each defining geometry to be rendered with a material
  90910. */
  90911. primitives: IMeshPrimitive[];
  90912. /**
  90913. * Array of weights to be applied to the Morph Targets
  90914. */
  90915. weights?: number[];
  90916. }
  90917. /**
  90918. * A node in the node hierarchy
  90919. */
  90920. interface INode extends IChildRootProperty {
  90921. /**
  90922. * The index of the camera referenced by this node
  90923. */
  90924. camera?: number;
  90925. /**
  90926. * The indices of this node's children
  90927. */
  90928. children?: number[];
  90929. /**
  90930. * The index of the skin referenced by this node
  90931. */
  90932. skin?: number;
  90933. /**
  90934. * A floating-point 4x4 transformation matrix stored in column-major order
  90935. */
  90936. matrix?: number[];
  90937. /**
  90938. * The index of the mesh in this node
  90939. */
  90940. mesh?: number;
  90941. /**
  90942. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  90943. */
  90944. rotation?: number[];
  90945. /**
  90946. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  90947. */
  90948. scale?: number[];
  90949. /**
  90950. * The node's translation along the x, y, and z axes
  90951. */
  90952. translation?: number[];
  90953. /**
  90954. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  90955. */
  90956. weights?: number[];
  90957. }
  90958. /**
  90959. * Texture sampler properties for filtering and wrapping modes
  90960. */
  90961. interface ISampler extends IChildRootProperty {
  90962. /**
  90963. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90964. */
  90965. magFilter?: TextureMagFilter;
  90966. /**
  90967. * Minification filter. All valid values correspond to WebGL enums
  90968. */
  90969. minFilter?: TextureMinFilter;
  90970. /**
  90971. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90972. */
  90973. wrapS?: TextureWrapMode;
  90974. /**
  90975. * T (V) wrapping mode. All valid values correspond to WebGL enums
  90976. */
  90977. wrapT?: TextureWrapMode;
  90978. }
  90979. /**
  90980. * The root nodes of a scene
  90981. */
  90982. interface IScene extends IChildRootProperty {
  90983. /**
  90984. * The indices of each root node
  90985. */
  90986. nodes: number[];
  90987. }
  90988. /**
  90989. * Joints and matrices defining a skin
  90990. */
  90991. interface ISkin extends IChildRootProperty {
  90992. /**
  90993. * 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
  90994. */
  90995. inverseBindMatrices?: number;
  90996. /**
  90997. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  90998. */
  90999. skeleton?: number;
  91000. /**
  91001. * 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)
  91002. */
  91003. joints: number[];
  91004. }
  91005. /**
  91006. * A texture and its sampler
  91007. */
  91008. interface ITexture extends IChildRootProperty {
  91009. /**
  91010. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91011. */
  91012. sampler?: number;
  91013. /**
  91014. * The index of the image used by this texture
  91015. */
  91016. source: number;
  91017. }
  91018. /**
  91019. * Reference to a texture
  91020. */
  91021. interface ITextureInfo extends IProperty {
  91022. /**
  91023. * The index of the texture
  91024. */
  91025. index: number;
  91026. /**
  91027. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91028. */
  91029. texCoord?: number;
  91030. }
  91031. /**
  91032. * The root object for a glTF asset
  91033. */
  91034. interface IGLTF extends IProperty {
  91035. /**
  91036. * An array of accessors. An accessor is a typed view into a bufferView
  91037. */
  91038. accessors?: IAccessor[];
  91039. /**
  91040. * An array of keyframe animations
  91041. */
  91042. animations?: IAnimation[];
  91043. /**
  91044. * Metadata about the glTF asset
  91045. */
  91046. asset: IAsset;
  91047. /**
  91048. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91049. */
  91050. buffers?: IBuffer[];
  91051. /**
  91052. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91053. */
  91054. bufferViews?: IBufferView[];
  91055. /**
  91056. * An array of cameras
  91057. */
  91058. cameras?: ICamera[];
  91059. /**
  91060. * Names of glTF extensions used somewhere in this asset
  91061. */
  91062. extensionsUsed?: string[];
  91063. /**
  91064. * Names of glTF extensions required to properly load this asset
  91065. */
  91066. extensionsRequired?: string[];
  91067. /**
  91068. * An array of images. An image defines data used to create a texture
  91069. */
  91070. images?: IImage[];
  91071. /**
  91072. * An array of materials. A material defines the appearance of a primitive
  91073. */
  91074. materials?: IMaterial[];
  91075. /**
  91076. * An array of meshes. A mesh is a set of primitives to be rendered
  91077. */
  91078. meshes?: IMesh[];
  91079. /**
  91080. * An array of nodes
  91081. */
  91082. nodes?: INode[];
  91083. /**
  91084. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91085. */
  91086. samplers?: ISampler[];
  91087. /**
  91088. * The index of the default scene
  91089. */
  91090. scene?: number;
  91091. /**
  91092. * An array of scenes
  91093. */
  91094. scenes?: IScene[];
  91095. /**
  91096. * An array of skins. A skin is defined by joints and matrices
  91097. */
  91098. skins?: ISkin[];
  91099. /**
  91100. * An array of textures
  91101. */
  91102. textures?: ITexture[];
  91103. }
  91104. /**
  91105. * The glTF validation results
  91106. * @ignore
  91107. */
  91108. interface IGLTFValidationResults {
  91109. info: {
  91110. generator: string;
  91111. hasAnimations: boolean;
  91112. hasDefaultScene: boolean;
  91113. hasMaterials: boolean;
  91114. hasMorphTargets: boolean;
  91115. hasSkins: boolean;
  91116. hasTextures: boolean;
  91117. maxAttributesUsed: number;
  91118. primitivesCount: number
  91119. };
  91120. issues: {
  91121. messages: Array<string>;
  91122. numErrors: number;
  91123. numHints: number;
  91124. numInfos: number;
  91125. numWarnings: number;
  91126. truncated: boolean
  91127. };
  91128. mimeType: string;
  91129. uri: string;
  91130. validatedAt: string;
  91131. validatorVersion: string;
  91132. }
  91133. /**
  91134. * The glTF validation options
  91135. */
  91136. interface IGLTFValidationOptions {
  91137. /** Uri to use */
  91138. uri?: string;
  91139. /** Function used to load external resources */
  91140. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91141. /** Boolean indicating that we need to validate accessor data */
  91142. validateAccessorData?: boolean;
  91143. /** max number of issues allowed */
  91144. maxIssues?: number;
  91145. /** Ignored issues */
  91146. ignoredIssues?: Array<string>;
  91147. /** Value to override severy settings */
  91148. severityOverrides?: Object;
  91149. }
  91150. /**
  91151. * The glTF validator object
  91152. * @ignore
  91153. */
  91154. interface IGLTFValidator {
  91155. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91156. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91157. }
  91158. /**
  91159. * Interfaces from the EXT_lights_image_based extension
  91160. */
  91161. /** @hidden */
  91162. interface IEXTLightsImageBased_LightReferenceImageBased {
  91163. light: number;
  91164. }
  91165. /** @hidden */
  91166. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91167. intensity: number;
  91168. rotation: number[];
  91169. specularImageSize: number;
  91170. specularImages: number[][];
  91171. irradianceCoefficients: number[][];
  91172. }
  91173. /** @hidden */
  91174. interface IEXTLightsImageBased {
  91175. lights: IEXTLightsImageBased_LightImageBased[];
  91176. }
  91177. /**
  91178. * Interfaces from the EXT_mesh_gpu_instancing extension
  91179. * !!! Experimental Extension Subject to Changes !!!
  91180. */
  91181. /** @hidden */
  91182. interface IEXTMeshGpuInstancing {
  91183. mesh?: number;
  91184. attributes: { [name: string]: number };
  91185. }
  91186. /**
  91187. * Interfaces from the KHR_draco_mesh_compression extension
  91188. */
  91189. /** @hidden */
  91190. interface IKHRDracoMeshCompression {
  91191. bufferView: number;
  91192. attributes: { [name: string]: number };
  91193. }
  91194. /**
  91195. * Interfaces from the KHR_lights_punctual extension
  91196. */
  91197. /** @hidden */
  91198. const enum IKHRLightsPunctual_LightType {
  91199. DIRECTIONAL = "directional",
  91200. POINT = "point",
  91201. SPOT = "spot"
  91202. }
  91203. /** @hidden */
  91204. interface IKHRLightsPunctual_LightReference {
  91205. light: number;
  91206. }
  91207. /** @hidden */
  91208. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91209. type: IKHRLightsPunctual_LightType;
  91210. color?: number[];
  91211. intensity?: number;
  91212. range?: number;
  91213. spot?: {
  91214. innerConeAngle?: number;
  91215. outerConeAngle?: number;
  91216. };
  91217. }
  91218. /** @hidden */
  91219. interface IKHRLightsPunctual {
  91220. lights: IKHRLightsPunctual_Light[];
  91221. }
  91222. /**
  91223. * Interfaces from the KHR_materials_clearcoat extension
  91224. * !!! Experimental Extension Subject to Changes !!!
  91225. */
  91226. /** @hidden */
  91227. interface IKHRMaterialsClearcoat {
  91228. clearcoatFactor: number;
  91229. clearcoatTexture: ITextureInfo;
  91230. clearcoatRoughnessFactor: number;
  91231. clearcoatRoughnessTexture: ITextureInfo;
  91232. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91233. }
  91234. /**
  91235. * Interfaces from the KHR_materials_ior extension
  91236. * !!! Experimental Extension Subject to Changes !!!
  91237. */
  91238. /** @hidden */
  91239. interface IKHRMaterialsIor {
  91240. ior: number;
  91241. }
  91242. /**
  91243. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91244. */
  91245. /** @hidden */
  91246. interface IKHRMaterialsPbrSpecularGlossiness {
  91247. diffuseFactor: number[];
  91248. diffuseTexture: ITextureInfo;
  91249. specularFactor: number[];
  91250. glossinessFactor: number;
  91251. specularGlossinessTexture: ITextureInfo;
  91252. }
  91253. /**
  91254. * Interfaces from the KHR_materials_sheen extension
  91255. * !!! Experimental Extension Subject to Changes !!!
  91256. */
  91257. /** @hidden */
  91258. interface IKHRMaterialsSheen {
  91259. sheenColorFactor?: number[];
  91260. sheenColorTexture?: ITextureInfo;
  91261. sheenRoughnessFactor?: number;
  91262. sheenRoughnessTexture?: ITextureInfo;
  91263. }
  91264. /**
  91265. * Interfaces from the KHR_materials_specular extension
  91266. * !!! Experimental Extension Subject to Changes !!!
  91267. */
  91268. /** @hidden */
  91269. interface IKHRMaterialsSpecular {
  91270. specularFactor: number;
  91271. specularColorFactor: number[];
  91272. specularTexture: ITextureInfo;
  91273. }
  91274. /**
  91275. * Interfaces from the KHR_materials_transmission extension
  91276. * !!! Experimental Extension Subject to Changes !!!
  91277. */
  91278. /** @hidden */
  91279. interface IKHRMaterialsTransmission {
  91280. transmissionFactor?: number;
  91281. transmissionTexture?: ITextureInfo;
  91282. }
  91283. /**
  91284. * Interfaces from the KHR_materials_translucency extension
  91285. * !!! Experimental Extension Subject to Changes !!!
  91286. */
  91287. /** @hidden */
  91288. interface IKHRMaterialsTranslucency {
  91289. translucencyFactor?: number;
  91290. translucencyTexture?: ITextureInfo;
  91291. }
  91292. /**
  91293. * Interfaces from the KHR_materials_variants extension
  91294. * !!! Experimental Extension Subject to Changes !!!
  91295. */
  91296. /** @hidden */
  91297. interface IKHRMaterialVariants_Mapping extends IProperty {
  91298. mappings: Array<{
  91299. variants: number[];
  91300. material: number;
  91301. }>;
  91302. }
  91303. /** @hidden */
  91304. interface IKHRMaterialVariants_Variant extends IProperty {
  91305. name: string;
  91306. }
  91307. /** @hidden */
  91308. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91309. variants: Array<IKHRMaterialVariants_Variant>;
  91310. }
  91311. /**
  91312. * Interfaces from the KHR_texture_basisu extension
  91313. * !!! Experimental Extension Subject to Changes !!!
  91314. */
  91315. /** @hidden */
  91316. interface IKHRTextureBasisU {
  91317. source: number;
  91318. }
  91319. /**
  91320. * Interfaces from the EXT_texture_webp extension
  91321. */
  91322. /** @hidden */
  91323. interface IEXTTextureWebP {
  91324. source: number;
  91325. }
  91326. /**
  91327. * Interfaces from the KHR_texture_transform extension
  91328. */
  91329. /** @hidden */
  91330. interface IKHRTextureTransform {
  91331. offset?: number[];
  91332. rotation?: number;
  91333. scale?: number[];
  91334. texCoord?: number;
  91335. }
  91336. /**
  91337. * Interfaces from the KHR_xmp_json_ld extension
  91338. * !!! Experimental Extension Subject to Changes !!!
  91339. */
  91340. /** @hidden */
  91341. interface IKHRXmpJsonLd_Gltf {
  91342. packets: Array<{
  91343. [key: string]: unknown;
  91344. }>;
  91345. }
  91346. /** @hidden */
  91347. interface IKHRXmpJsonLd_Node {
  91348. packet: number;
  91349. }
  91350. /**
  91351. * Interfaces from the MSFT_audio_emitter extension
  91352. */
  91353. /** @hidden */
  91354. interface IMSFTAudioEmitter_ClipReference {
  91355. clip: number;
  91356. weight?: number;
  91357. }
  91358. /** @hidden */
  91359. interface IMSFTAudioEmitter_EmittersReference {
  91360. emitters: number[];
  91361. }
  91362. /** @hidden */
  91363. const enum IMSFTAudioEmitter_DistanceModel {
  91364. linear = "linear",
  91365. inverse = "inverse",
  91366. exponential = "exponential",
  91367. }
  91368. /** @hidden */
  91369. interface IMSFTAudioEmitter_Emitter {
  91370. name?: string;
  91371. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91372. refDistance?: number;
  91373. maxDistance?: number;
  91374. rolloffFactor?: number;
  91375. innerAngle?: number;
  91376. outerAngle?: number;
  91377. loop?: boolean;
  91378. volume?: number;
  91379. clips: IMSFTAudioEmitter_ClipReference[];
  91380. }
  91381. /** @hidden */
  91382. const enum IMSFTAudioEmitter_AudioMimeType {
  91383. WAV = "audio/wav",
  91384. }
  91385. /** @hidden */
  91386. interface IMSFTAudioEmitter_Clip extends IProperty {
  91387. uri?: string;
  91388. bufferView?: number;
  91389. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91390. }
  91391. /** @hidden */
  91392. const enum IMSFTAudioEmitter_AnimationEventAction {
  91393. play = "play",
  91394. pause = "pause",
  91395. stop = "stop",
  91396. }
  91397. /** @hidden */
  91398. interface IMSFTAudioEmitter_AnimationEvent {
  91399. action: IMSFTAudioEmitter_AnimationEventAction;
  91400. emitter: number;
  91401. time: number;
  91402. startOffset?: number;
  91403. }
  91404. /**
  91405. * Interfaces from the MSFT_lod extension
  91406. */
  91407. /** @hidden */
  91408. interface IMSFTLOD {
  91409. ids: number[];
  91410. }
  91411. /**
  91412. * Interfaces from the EXT_meshopt_compression extension
  91413. */
  91414. /** @hidden */
  91415. interface IEXTMeshoptCompression {
  91416. buffer: number;
  91417. byteOffset?: number;
  91418. byteLength: number;
  91419. byteStride: number;
  91420. count: number;
  91421. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91422. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91423. }
  91424. }
  91425. declare module BABYLON {
  91426. /** @hidden */
  91427. export var cellPixelShader: {
  91428. name: string;
  91429. shader: string;
  91430. };
  91431. }
  91432. declare module BABYLON {
  91433. /** @hidden */
  91434. export var cellVertexShader: {
  91435. name: string;
  91436. shader: string;
  91437. };
  91438. }
  91439. declare module BABYLON {
  91440. export class CellMaterial extends BABYLON.PushMaterial {
  91441. private _diffuseTexture;
  91442. diffuseTexture: BABYLON.BaseTexture;
  91443. diffuseColor: BABYLON.Color3;
  91444. _computeHighLevel: boolean;
  91445. computeHighLevel: boolean;
  91446. private _disableLighting;
  91447. disableLighting: boolean;
  91448. private _maxSimultaneousLights;
  91449. maxSimultaneousLights: number;
  91450. constructor(name: string, scene: BABYLON.Scene);
  91451. needAlphaBlending(): boolean;
  91452. needAlphaTesting(): boolean;
  91453. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91454. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91455. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91456. getAnimatables(): BABYLON.IAnimatable[];
  91457. getActiveTextures(): BABYLON.BaseTexture[];
  91458. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91459. dispose(forceDisposeEffect?: boolean): void;
  91460. getClassName(): string;
  91461. clone(name: string): CellMaterial;
  91462. serialize(): any;
  91463. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91464. }
  91465. }
  91466. declare module BABYLON {
  91467. export class CustomShaderStructure {
  91468. FragmentStore: string;
  91469. VertexStore: string;
  91470. constructor();
  91471. }
  91472. export class ShaderSpecialParts {
  91473. constructor();
  91474. Fragment_Begin: string;
  91475. Fragment_Definitions: string;
  91476. Fragment_MainBegin: string;
  91477. Fragment_Custom_Diffuse: string;
  91478. Fragment_Before_Lights: string;
  91479. Fragment_Before_Fog: string;
  91480. Fragment_Custom_Alpha: string;
  91481. Fragment_Before_FragColor: string;
  91482. Vertex_Begin: string;
  91483. Vertex_Definitions: string;
  91484. Vertex_MainBegin: string;
  91485. Vertex_Before_PositionUpdated: string;
  91486. Vertex_Before_NormalUpdated: string;
  91487. Vertex_After_WorldPosComputed: string;
  91488. Vertex_MainEnd: string;
  91489. }
  91490. export class CustomMaterial extends BABYLON.StandardMaterial {
  91491. static ShaderIndexer: number;
  91492. CustomParts: ShaderSpecialParts;
  91493. _isCreatedShader: boolean;
  91494. _createdShaderName: string;
  91495. _customUniform: string[];
  91496. _newUniforms: string[];
  91497. _newUniformInstances: {
  91498. [name: string]: any;
  91499. };
  91500. _newSamplerInstances: {
  91501. [name: string]: BABYLON.Texture;
  91502. };
  91503. _customAttributes: string[];
  91504. FragmentShader: string;
  91505. VertexShader: string;
  91506. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91507. ReviewUniform(name: string, arr: string[]): string[];
  91508. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91509. constructor(name: string, scene: BABYLON.Scene);
  91510. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91511. AddAttribute(name: string): CustomMaterial;
  91512. Fragment_Begin(shaderPart: string): CustomMaterial;
  91513. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91514. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91515. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91516. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91517. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91518. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91519. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91520. Vertex_Begin(shaderPart: string): CustomMaterial;
  91521. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91522. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91523. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91524. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91525. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91526. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91527. }
  91528. }
  91529. declare module BABYLON {
  91530. export class ShaderAlebdoParts {
  91531. constructor();
  91532. Fragment_Begin: string;
  91533. Fragment_Definitions: string;
  91534. Fragment_MainBegin: string;
  91535. Fragment_Custom_Albedo: string;
  91536. Fragment_Before_Lights: string;
  91537. Fragment_Custom_MetallicRoughness: string;
  91538. Fragment_Custom_MicroSurface: string;
  91539. Fragment_Before_Fog: string;
  91540. Fragment_Custom_Alpha: string;
  91541. Fragment_Before_FragColor: string;
  91542. Vertex_Begin: string;
  91543. Vertex_Definitions: string;
  91544. Vertex_MainBegin: string;
  91545. Vertex_Before_PositionUpdated: string;
  91546. Vertex_Before_NormalUpdated: string;
  91547. Vertex_After_WorldPosComputed: string;
  91548. Vertex_MainEnd: string;
  91549. }
  91550. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91551. static ShaderIndexer: number;
  91552. CustomParts: ShaderAlebdoParts;
  91553. _isCreatedShader: boolean;
  91554. _createdShaderName: string;
  91555. _customUniform: string[];
  91556. _newUniforms: string[];
  91557. _newUniformInstances: {
  91558. [name: string]: any;
  91559. };
  91560. _newSamplerInstances: {
  91561. [name: string]: BABYLON.Texture;
  91562. };
  91563. _customAttributes: string[];
  91564. FragmentShader: string;
  91565. VertexShader: string;
  91566. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91567. ReviewUniform(name: string, arr: string[]): string[];
  91568. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91569. constructor(name: string, scene: BABYLON.Scene);
  91570. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91571. AddAttribute(name: string): PBRCustomMaterial;
  91572. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91573. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91574. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91575. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91576. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91577. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91578. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91579. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91580. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91581. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91582. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91583. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91584. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91585. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91586. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91587. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91588. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91589. }
  91590. }
  91591. declare module BABYLON {
  91592. /** @hidden */
  91593. export var firePixelShader: {
  91594. name: string;
  91595. shader: string;
  91596. };
  91597. }
  91598. declare module BABYLON {
  91599. /** @hidden */
  91600. export var fireVertexShader: {
  91601. name: string;
  91602. shader: string;
  91603. };
  91604. }
  91605. declare module BABYLON {
  91606. export class FireMaterial extends BABYLON.PushMaterial {
  91607. private _diffuseTexture;
  91608. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91609. private _distortionTexture;
  91610. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91611. private _opacityTexture;
  91612. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91613. diffuseColor: BABYLON.Color3;
  91614. speed: number;
  91615. private _scaledDiffuse;
  91616. private _lastTime;
  91617. constructor(name: string, scene: BABYLON.Scene);
  91618. needAlphaBlending(): boolean;
  91619. needAlphaTesting(): boolean;
  91620. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91621. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91622. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91623. getAnimatables(): BABYLON.IAnimatable[];
  91624. getActiveTextures(): BABYLON.BaseTexture[];
  91625. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91626. getClassName(): string;
  91627. dispose(forceDisposeEffect?: boolean): void;
  91628. clone(name: string): FireMaterial;
  91629. serialize(): any;
  91630. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91631. }
  91632. }
  91633. declare module BABYLON {
  91634. /** @hidden */
  91635. export var furPixelShader: {
  91636. name: string;
  91637. shader: string;
  91638. };
  91639. }
  91640. declare module BABYLON {
  91641. /** @hidden */
  91642. export var furVertexShader: {
  91643. name: string;
  91644. shader: string;
  91645. };
  91646. }
  91647. declare module BABYLON {
  91648. export class FurMaterial extends BABYLON.PushMaterial {
  91649. private _diffuseTexture;
  91650. diffuseTexture: BABYLON.BaseTexture;
  91651. private _heightTexture;
  91652. heightTexture: BABYLON.BaseTexture;
  91653. diffuseColor: BABYLON.Color3;
  91654. furLength: number;
  91655. furAngle: number;
  91656. furColor: BABYLON.Color3;
  91657. furOffset: number;
  91658. furSpacing: number;
  91659. furGravity: BABYLON.Vector3;
  91660. furSpeed: number;
  91661. furDensity: number;
  91662. furOcclusion: number;
  91663. furTexture: BABYLON.DynamicTexture;
  91664. private _disableLighting;
  91665. disableLighting: boolean;
  91666. private _maxSimultaneousLights;
  91667. maxSimultaneousLights: number;
  91668. highLevelFur: boolean;
  91669. _meshes: BABYLON.AbstractMesh[];
  91670. private _furTime;
  91671. constructor(name: string, scene: BABYLON.Scene);
  91672. get furTime(): number;
  91673. set furTime(furTime: number);
  91674. needAlphaBlending(): boolean;
  91675. needAlphaTesting(): boolean;
  91676. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91677. updateFur(): void;
  91678. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91679. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91680. getAnimatables(): BABYLON.IAnimatable[];
  91681. getActiveTextures(): BABYLON.BaseTexture[];
  91682. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91683. dispose(forceDisposeEffect?: boolean): void;
  91684. clone(name: string): FurMaterial;
  91685. serialize(): any;
  91686. getClassName(): string;
  91687. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91688. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91689. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91690. }
  91691. }
  91692. declare module BABYLON {
  91693. /** @hidden */
  91694. export var gradientPixelShader: {
  91695. name: string;
  91696. shader: string;
  91697. };
  91698. }
  91699. declare module BABYLON {
  91700. /** @hidden */
  91701. export var gradientVertexShader: {
  91702. name: string;
  91703. shader: string;
  91704. };
  91705. }
  91706. declare module BABYLON {
  91707. export class GradientMaterial extends BABYLON.PushMaterial {
  91708. private _maxSimultaneousLights;
  91709. maxSimultaneousLights: number;
  91710. topColor: BABYLON.Color3;
  91711. topColorAlpha: number;
  91712. bottomColor: BABYLON.Color3;
  91713. bottomColorAlpha: number;
  91714. offset: number;
  91715. scale: number;
  91716. smoothness: number;
  91717. private _disableLighting;
  91718. disableLighting: boolean;
  91719. constructor(name: string, scene: BABYLON.Scene);
  91720. needAlphaBlending(): boolean;
  91721. needAlphaTesting(): boolean;
  91722. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91723. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91724. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91725. getAnimatables(): BABYLON.IAnimatable[];
  91726. dispose(forceDisposeEffect?: boolean): void;
  91727. clone(name: string): GradientMaterial;
  91728. serialize(): any;
  91729. getClassName(): string;
  91730. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91731. }
  91732. }
  91733. declare module BABYLON {
  91734. /** @hidden */
  91735. export var gridPixelShader: {
  91736. name: string;
  91737. shader: string;
  91738. };
  91739. }
  91740. declare module BABYLON {
  91741. /** @hidden */
  91742. export var gridVertexShader: {
  91743. name: string;
  91744. shader: string;
  91745. };
  91746. }
  91747. declare module BABYLON {
  91748. /**
  91749. * The grid materials allows you to wrap any shape with a grid.
  91750. * Colors are customizable.
  91751. */
  91752. export class GridMaterial extends BABYLON.PushMaterial {
  91753. /**
  91754. * Main color of the grid (e.g. between lines)
  91755. */
  91756. mainColor: BABYLON.Color3;
  91757. /**
  91758. * Color of the grid lines.
  91759. */
  91760. lineColor: BABYLON.Color3;
  91761. /**
  91762. * The scale of the grid compared to unit.
  91763. */
  91764. gridRatio: number;
  91765. /**
  91766. * Allows setting an offset for the grid lines.
  91767. */
  91768. gridOffset: BABYLON.Vector3;
  91769. /**
  91770. * The frequency of thicker lines.
  91771. */
  91772. majorUnitFrequency: number;
  91773. /**
  91774. * The visibility of minor units in the grid.
  91775. */
  91776. minorUnitVisibility: number;
  91777. /**
  91778. * The grid opacity outside of the lines.
  91779. */
  91780. opacity: number;
  91781. /**
  91782. * Determine RBG output is premultiplied by alpha value.
  91783. */
  91784. preMultiplyAlpha: boolean;
  91785. private _opacityTexture;
  91786. opacityTexture: BABYLON.BaseTexture;
  91787. private _gridControl;
  91788. /**
  91789. * constructor
  91790. * @param name The name given to the material in order to identify it afterwards.
  91791. * @param scene The scene the material is used in.
  91792. */
  91793. constructor(name: string, scene: BABYLON.Scene);
  91794. /**
  91795. * Returns wehter or not the grid requires alpha blending.
  91796. */
  91797. needAlphaBlending(): boolean;
  91798. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91799. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91800. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91801. /**
  91802. * Dispose the material and its associated resources.
  91803. * @param forceDisposeEffect will also dispose the used effect when true
  91804. */
  91805. dispose(forceDisposeEffect?: boolean): void;
  91806. clone(name: string): GridMaterial;
  91807. serialize(): any;
  91808. getClassName(): string;
  91809. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91810. }
  91811. }
  91812. declare module BABYLON {
  91813. /** @hidden */
  91814. export var lavaPixelShader: {
  91815. name: string;
  91816. shader: string;
  91817. };
  91818. }
  91819. declare module BABYLON {
  91820. /** @hidden */
  91821. export var lavaVertexShader: {
  91822. name: string;
  91823. shader: string;
  91824. };
  91825. }
  91826. declare module BABYLON {
  91827. export class LavaMaterial extends BABYLON.PushMaterial {
  91828. private _diffuseTexture;
  91829. diffuseTexture: BABYLON.BaseTexture;
  91830. noiseTexture: BABYLON.BaseTexture;
  91831. fogColor: BABYLON.Color3;
  91832. speed: number;
  91833. movingSpeed: number;
  91834. lowFrequencySpeed: number;
  91835. fogDensity: number;
  91836. private _lastTime;
  91837. diffuseColor: BABYLON.Color3;
  91838. private _disableLighting;
  91839. disableLighting: boolean;
  91840. private _unlit;
  91841. unlit: boolean;
  91842. private _maxSimultaneousLights;
  91843. maxSimultaneousLights: number;
  91844. private _scaledDiffuse;
  91845. constructor(name: string, scene: BABYLON.Scene);
  91846. needAlphaBlending(): boolean;
  91847. needAlphaTesting(): boolean;
  91848. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91849. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91850. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91851. getAnimatables(): BABYLON.IAnimatable[];
  91852. getActiveTextures(): BABYLON.BaseTexture[];
  91853. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91854. dispose(forceDisposeEffect?: boolean): void;
  91855. clone(name: string): LavaMaterial;
  91856. serialize(): any;
  91857. getClassName(): string;
  91858. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  91859. }
  91860. }
  91861. declare module BABYLON {
  91862. /** @hidden */
  91863. export var mixPixelShader: {
  91864. name: string;
  91865. shader: string;
  91866. };
  91867. }
  91868. declare module BABYLON {
  91869. /** @hidden */
  91870. export var mixVertexShader: {
  91871. name: string;
  91872. shader: string;
  91873. };
  91874. }
  91875. declare module BABYLON {
  91876. export class MixMaterial extends BABYLON.PushMaterial {
  91877. /**
  91878. * Mix textures
  91879. */
  91880. private _mixTexture1;
  91881. mixTexture1: BABYLON.BaseTexture;
  91882. private _mixTexture2;
  91883. mixTexture2: BABYLON.BaseTexture;
  91884. /**
  91885. * Diffuse textures
  91886. */
  91887. private _diffuseTexture1;
  91888. diffuseTexture1: BABYLON.Texture;
  91889. private _diffuseTexture2;
  91890. diffuseTexture2: BABYLON.Texture;
  91891. private _diffuseTexture3;
  91892. diffuseTexture3: BABYLON.Texture;
  91893. private _diffuseTexture4;
  91894. diffuseTexture4: BABYLON.Texture;
  91895. private _diffuseTexture5;
  91896. diffuseTexture5: BABYLON.Texture;
  91897. private _diffuseTexture6;
  91898. diffuseTexture6: BABYLON.Texture;
  91899. private _diffuseTexture7;
  91900. diffuseTexture7: BABYLON.Texture;
  91901. private _diffuseTexture8;
  91902. diffuseTexture8: BABYLON.Texture;
  91903. /**
  91904. * Uniforms
  91905. */
  91906. diffuseColor: BABYLON.Color3;
  91907. specularColor: BABYLON.Color3;
  91908. specularPower: number;
  91909. private _disableLighting;
  91910. disableLighting: boolean;
  91911. private _maxSimultaneousLights;
  91912. maxSimultaneousLights: number;
  91913. constructor(name: string, scene: BABYLON.Scene);
  91914. needAlphaBlending(): boolean;
  91915. needAlphaTesting(): boolean;
  91916. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91917. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91918. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91919. getAnimatables(): BABYLON.IAnimatable[];
  91920. getActiveTextures(): BABYLON.BaseTexture[];
  91921. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91922. dispose(forceDisposeEffect?: boolean): void;
  91923. clone(name: string): MixMaterial;
  91924. serialize(): any;
  91925. getClassName(): string;
  91926. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  91927. }
  91928. }
  91929. declare module BABYLON {
  91930. /** @hidden */
  91931. export var normalPixelShader: {
  91932. name: string;
  91933. shader: string;
  91934. };
  91935. }
  91936. declare module BABYLON {
  91937. /** @hidden */
  91938. export var normalVertexShader: {
  91939. name: string;
  91940. shader: string;
  91941. };
  91942. }
  91943. declare module BABYLON {
  91944. export class NormalMaterial extends BABYLON.PushMaterial {
  91945. private _diffuseTexture;
  91946. diffuseTexture: BABYLON.BaseTexture;
  91947. diffuseColor: BABYLON.Color3;
  91948. private _disableLighting;
  91949. disableLighting: boolean;
  91950. private _maxSimultaneousLights;
  91951. maxSimultaneousLights: number;
  91952. constructor(name: string, scene: BABYLON.Scene);
  91953. needAlphaBlending(): boolean;
  91954. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91955. needAlphaTesting(): boolean;
  91956. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91957. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91958. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91959. getAnimatables(): BABYLON.IAnimatable[];
  91960. getActiveTextures(): BABYLON.BaseTexture[];
  91961. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91962. dispose(forceDisposeEffect?: boolean): void;
  91963. clone(name: string): NormalMaterial;
  91964. serialize(): any;
  91965. getClassName(): string;
  91966. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  91967. }
  91968. }
  91969. declare module BABYLON {
  91970. /** @hidden */
  91971. export var shadowOnlyPixelShader: {
  91972. name: string;
  91973. shader: string;
  91974. };
  91975. }
  91976. declare module BABYLON {
  91977. /** @hidden */
  91978. export var shadowOnlyVertexShader: {
  91979. name: string;
  91980. shader: string;
  91981. };
  91982. }
  91983. declare module BABYLON {
  91984. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  91985. private _activeLight;
  91986. private _needAlphaBlending;
  91987. constructor(name: string, scene: BABYLON.Scene);
  91988. shadowColor: BABYLON.Color3;
  91989. needAlphaBlending(): boolean;
  91990. needAlphaTesting(): boolean;
  91991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91992. get activeLight(): BABYLON.IShadowLight;
  91993. set activeLight(light: BABYLON.IShadowLight);
  91994. private _getFirstShadowLightForMesh;
  91995. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91996. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91997. clone(name: string): ShadowOnlyMaterial;
  91998. serialize(): any;
  91999. getClassName(): string;
  92000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92001. }
  92002. }
  92003. declare module BABYLON {
  92004. /** @hidden */
  92005. export var simplePixelShader: {
  92006. name: string;
  92007. shader: string;
  92008. };
  92009. }
  92010. declare module BABYLON {
  92011. /** @hidden */
  92012. export var simpleVertexShader: {
  92013. name: string;
  92014. shader: string;
  92015. };
  92016. }
  92017. declare module BABYLON {
  92018. export class SimpleMaterial extends BABYLON.PushMaterial {
  92019. private _diffuseTexture;
  92020. diffuseTexture: BABYLON.BaseTexture;
  92021. diffuseColor: BABYLON.Color3;
  92022. private _disableLighting;
  92023. disableLighting: boolean;
  92024. private _maxSimultaneousLights;
  92025. maxSimultaneousLights: number;
  92026. constructor(name: string, scene: BABYLON.Scene);
  92027. needAlphaBlending(): boolean;
  92028. needAlphaTesting(): boolean;
  92029. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92030. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92031. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92032. getAnimatables(): BABYLON.IAnimatable[];
  92033. getActiveTextures(): BABYLON.BaseTexture[];
  92034. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92035. dispose(forceDisposeEffect?: boolean): void;
  92036. clone(name: string): SimpleMaterial;
  92037. serialize(): any;
  92038. getClassName(): string;
  92039. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92040. }
  92041. }
  92042. declare module BABYLON {
  92043. /** @hidden */
  92044. export var skyPixelShader: {
  92045. name: string;
  92046. shader: string;
  92047. };
  92048. }
  92049. declare module BABYLON {
  92050. /** @hidden */
  92051. export var skyVertexShader: {
  92052. name: string;
  92053. shader: string;
  92054. };
  92055. }
  92056. declare module BABYLON {
  92057. /**
  92058. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92059. * @see https://doc.babylonjs.com/extensions/sky
  92060. */
  92061. export class SkyMaterial extends BABYLON.PushMaterial {
  92062. /**
  92063. * Defines the overall luminance of sky in interval ]0, 1[.
  92064. */
  92065. luminance: number;
  92066. /**
  92067. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92068. */
  92069. turbidity: number;
  92070. /**
  92071. * Defines the sky appearance (light intensity).
  92072. */
  92073. rayleigh: number;
  92074. /**
  92075. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92076. */
  92077. mieCoefficient: number;
  92078. /**
  92079. * Defines the amount of haze particles following the Mie scattering theory.
  92080. */
  92081. mieDirectionalG: number;
  92082. /**
  92083. * Defines the distance of the sun according to the active scene camera.
  92084. */
  92085. distance: number;
  92086. /**
  92087. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92088. * "inclined".
  92089. */
  92090. inclination: number;
  92091. /**
  92092. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92093. * an object direction and a reference direction.
  92094. */
  92095. azimuth: number;
  92096. /**
  92097. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92098. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92099. */
  92100. sunPosition: BABYLON.Vector3;
  92101. /**
  92102. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92103. * .sunPosition property.
  92104. */
  92105. useSunPosition: boolean;
  92106. /**
  92107. * Defines an offset vector used to get a horizon offset.
  92108. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92109. */
  92110. cameraOffset: BABYLON.Vector3;
  92111. private _cameraPosition;
  92112. /**
  92113. * Instantiates a new sky material.
  92114. * This material allows to create dynamic and texture free
  92115. * effects for skyboxes by taking care of the atmosphere state.
  92116. * @see https://doc.babylonjs.com/extensions/sky
  92117. * @param name Define the name of the material in the scene
  92118. * @param scene Define the scene the material belong to
  92119. */
  92120. constructor(name: string, scene: BABYLON.Scene);
  92121. /**
  92122. * Specifies if the material will require alpha blending
  92123. * @returns a boolean specifying if alpha blending is needed
  92124. */
  92125. needAlphaBlending(): boolean;
  92126. /**
  92127. * Specifies if this material should be rendered in alpha test mode
  92128. * @returns false as the sky material doesn't need alpha testing.
  92129. */
  92130. needAlphaTesting(): boolean;
  92131. /**
  92132. * Get the texture used for alpha test purpose.
  92133. * @returns null as the sky material has no texture.
  92134. */
  92135. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92136. /**
  92137. * Get if the submesh is ready to be used and all its information available.
  92138. * Child classes can use it to update shaders
  92139. * @param mesh defines the mesh to check
  92140. * @param subMesh defines which submesh to check
  92141. * @param useInstances specifies that instances should be used
  92142. * @returns a boolean indicating that the submesh is ready or not
  92143. */
  92144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92145. /**
  92146. * Binds the submesh to this material by preparing the effect and shader to draw
  92147. * @param world defines the world transformation matrix
  92148. * @param mesh defines the mesh containing the submesh
  92149. * @param subMesh defines the submesh to bind the material to
  92150. */
  92151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92152. /**
  92153. * Get the list of animatables in the material.
  92154. * @returns the list of animatables object used in the material
  92155. */
  92156. getAnimatables(): BABYLON.IAnimatable[];
  92157. /**
  92158. * Disposes the material
  92159. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92160. */
  92161. dispose(forceDisposeEffect?: boolean): void;
  92162. /**
  92163. * Makes a duplicate of the material, and gives it a new name
  92164. * @param name defines the new name for the duplicated material
  92165. * @returns the cloned material
  92166. */
  92167. clone(name: string): SkyMaterial;
  92168. /**
  92169. * Serializes this material in a JSON representation
  92170. * @returns the serialized material object
  92171. */
  92172. serialize(): any;
  92173. /**
  92174. * Gets the current class name of the material e.g. "SkyMaterial"
  92175. * Mainly use in serialization.
  92176. * @returns the class name
  92177. */
  92178. getClassName(): string;
  92179. /**
  92180. * Creates a sky material from parsed material data
  92181. * @param source defines the JSON representation of the material
  92182. * @param scene defines the hosting scene
  92183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92184. * @returns a new sky material
  92185. */
  92186. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92187. }
  92188. }
  92189. declare module BABYLON {
  92190. /** @hidden */
  92191. export var terrainPixelShader: {
  92192. name: string;
  92193. shader: string;
  92194. };
  92195. }
  92196. declare module BABYLON {
  92197. /** @hidden */
  92198. export var terrainVertexShader: {
  92199. name: string;
  92200. shader: string;
  92201. };
  92202. }
  92203. declare module BABYLON {
  92204. export class TerrainMaterial extends BABYLON.PushMaterial {
  92205. private _mixTexture;
  92206. mixTexture: BABYLON.BaseTexture;
  92207. private _diffuseTexture1;
  92208. diffuseTexture1: BABYLON.Texture;
  92209. private _diffuseTexture2;
  92210. diffuseTexture2: BABYLON.Texture;
  92211. private _diffuseTexture3;
  92212. diffuseTexture3: BABYLON.Texture;
  92213. private _bumpTexture1;
  92214. bumpTexture1: BABYLON.Texture;
  92215. private _bumpTexture2;
  92216. bumpTexture2: BABYLON.Texture;
  92217. private _bumpTexture3;
  92218. bumpTexture3: BABYLON.Texture;
  92219. diffuseColor: BABYLON.Color3;
  92220. specularColor: BABYLON.Color3;
  92221. specularPower: number;
  92222. private _disableLighting;
  92223. disableLighting: boolean;
  92224. private _maxSimultaneousLights;
  92225. maxSimultaneousLights: number;
  92226. constructor(name: string, scene: BABYLON.Scene);
  92227. needAlphaBlending(): boolean;
  92228. needAlphaTesting(): boolean;
  92229. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92230. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92231. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92232. getAnimatables(): BABYLON.IAnimatable[];
  92233. getActiveTextures(): BABYLON.BaseTexture[];
  92234. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92235. dispose(forceDisposeEffect?: boolean): void;
  92236. clone(name: string): TerrainMaterial;
  92237. serialize(): any;
  92238. getClassName(): string;
  92239. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92240. }
  92241. }
  92242. declare module BABYLON {
  92243. /** @hidden */
  92244. export var triplanarPixelShader: {
  92245. name: string;
  92246. shader: string;
  92247. };
  92248. }
  92249. declare module BABYLON {
  92250. /** @hidden */
  92251. export var triplanarVertexShader: {
  92252. name: string;
  92253. shader: string;
  92254. };
  92255. }
  92256. declare module BABYLON {
  92257. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92258. mixTexture: BABYLON.BaseTexture;
  92259. private _diffuseTextureX;
  92260. diffuseTextureX: BABYLON.BaseTexture;
  92261. private _diffuseTextureY;
  92262. diffuseTextureY: BABYLON.BaseTexture;
  92263. private _diffuseTextureZ;
  92264. diffuseTextureZ: BABYLON.BaseTexture;
  92265. private _normalTextureX;
  92266. normalTextureX: BABYLON.BaseTexture;
  92267. private _normalTextureY;
  92268. normalTextureY: BABYLON.BaseTexture;
  92269. private _normalTextureZ;
  92270. normalTextureZ: BABYLON.BaseTexture;
  92271. tileSize: number;
  92272. diffuseColor: BABYLON.Color3;
  92273. specularColor: BABYLON.Color3;
  92274. specularPower: number;
  92275. private _disableLighting;
  92276. disableLighting: boolean;
  92277. private _maxSimultaneousLights;
  92278. maxSimultaneousLights: number;
  92279. constructor(name: string, scene: BABYLON.Scene);
  92280. needAlphaBlending(): boolean;
  92281. needAlphaTesting(): boolean;
  92282. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92283. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92284. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92285. getAnimatables(): BABYLON.IAnimatable[];
  92286. getActiveTextures(): BABYLON.BaseTexture[];
  92287. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92288. dispose(forceDisposeEffect?: boolean): void;
  92289. clone(name: string): TriPlanarMaterial;
  92290. serialize(): any;
  92291. getClassName(): string;
  92292. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92293. }
  92294. }
  92295. declare module BABYLON {
  92296. /** @hidden */
  92297. export var waterPixelShader: {
  92298. name: string;
  92299. shader: string;
  92300. };
  92301. }
  92302. declare module BABYLON {
  92303. /** @hidden */
  92304. export var waterVertexShader: {
  92305. name: string;
  92306. shader: string;
  92307. };
  92308. }
  92309. declare module BABYLON {
  92310. export class WaterMaterial extends BABYLON.PushMaterial {
  92311. renderTargetSize: BABYLON.Vector2;
  92312. private _bumpTexture;
  92313. bumpTexture: BABYLON.BaseTexture;
  92314. diffuseColor: BABYLON.Color3;
  92315. specularColor: BABYLON.Color3;
  92316. specularPower: number;
  92317. private _disableLighting;
  92318. disableLighting: boolean;
  92319. private _maxSimultaneousLights;
  92320. maxSimultaneousLights: number;
  92321. /**
  92322. * Defines the wind force.
  92323. */
  92324. windForce: number;
  92325. /**
  92326. * Defines the direction of the wind in the plane (X, Z).
  92327. */
  92328. windDirection: BABYLON.Vector2;
  92329. /**
  92330. * Defines the height of the waves.
  92331. */
  92332. waveHeight: number;
  92333. /**
  92334. * Defines the bump height related to the bump map.
  92335. */
  92336. bumpHeight: number;
  92337. /**
  92338. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92339. */
  92340. private _bumpSuperimpose;
  92341. bumpSuperimpose: boolean;
  92342. /**
  92343. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92344. */
  92345. private _fresnelSeparate;
  92346. fresnelSeparate: boolean;
  92347. /**
  92348. * Defines wether or not bump Wwves modify the reflection.
  92349. */
  92350. private _bumpAffectsReflection;
  92351. bumpAffectsReflection: boolean;
  92352. /**
  92353. * Defines the water color blended with the refraction (near).
  92354. */
  92355. waterColor: BABYLON.Color3;
  92356. /**
  92357. * Defines the blend factor related to the water color.
  92358. */
  92359. colorBlendFactor: number;
  92360. /**
  92361. * Defines the water color blended with the reflection (far).
  92362. */
  92363. waterColor2: BABYLON.Color3;
  92364. /**
  92365. * Defines the blend factor related to the water color (reflection, far).
  92366. */
  92367. colorBlendFactor2: number;
  92368. /**
  92369. * Defines the maximum length of a wave.
  92370. */
  92371. waveLength: number;
  92372. /**
  92373. * Defines the waves speed.
  92374. */
  92375. waveSpeed: number;
  92376. /**
  92377. * 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.
  92378. */
  92379. waveCount: number;
  92380. /**
  92381. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92382. * will avoid calculating useless pixels in the pixel shader of the water material.
  92383. */
  92384. disableClipPlane: boolean;
  92385. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92386. private _mesh;
  92387. private _refractionRTT;
  92388. private _reflectionRTT;
  92389. private _reflectionTransform;
  92390. private _lastTime;
  92391. private _lastDeltaTime;
  92392. private _useLogarithmicDepth;
  92393. private _waitingRenderList;
  92394. private _imageProcessingConfiguration;
  92395. private _imageProcessingObserver;
  92396. /**
  92397. * Gets a boolean indicating that current material needs to register RTT
  92398. */
  92399. get hasRenderTargetTextures(): boolean;
  92400. /**
  92401. * Constructor
  92402. */
  92403. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92404. get useLogarithmicDepth(): boolean;
  92405. set useLogarithmicDepth(value: boolean);
  92406. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92407. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92408. addToRenderList(node: any): void;
  92409. enableRenderTargets(enable: boolean): void;
  92410. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92411. get renderTargetsEnabled(): boolean;
  92412. needAlphaBlending(): boolean;
  92413. needAlphaTesting(): boolean;
  92414. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92415. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92416. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92417. private _createRenderTargets;
  92418. getAnimatables(): BABYLON.IAnimatable[];
  92419. getActiveTextures(): BABYLON.BaseTexture[];
  92420. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92421. dispose(forceDisposeEffect?: boolean): void;
  92422. clone(name: string): WaterMaterial;
  92423. serialize(): any;
  92424. getClassName(): string;
  92425. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92426. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92427. }
  92428. }
  92429. declare module BABYLON {
  92430. /** @hidden */
  92431. export var asciiartPixelShader: {
  92432. name: string;
  92433. shader: string;
  92434. };
  92435. }
  92436. declare module BABYLON {
  92437. /**
  92438. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92439. *
  92440. * It basically takes care rendering the font front the given font size to a texture.
  92441. * This is used later on in the postprocess.
  92442. */
  92443. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92444. private _font;
  92445. private _text;
  92446. private _charSize;
  92447. /**
  92448. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92449. */
  92450. get charSize(): number;
  92451. /**
  92452. * Create a new instance of the Ascii Art FontTexture class
  92453. * @param name the name of the texture
  92454. * @param font the font to use, use the W3C CSS notation
  92455. * @param text the caracter set to use in the rendering.
  92456. * @param scene the scene that owns the texture
  92457. */
  92458. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92459. /**
  92460. * Gets the max char width of a font.
  92461. * @param font the font to use, use the W3C CSS notation
  92462. * @return the max char width
  92463. */
  92464. private getFontWidth;
  92465. /**
  92466. * Gets the max char height of a font.
  92467. * @param font the font to use, use the W3C CSS notation
  92468. * @return the max char height
  92469. */
  92470. private getFontHeight;
  92471. /**
  92472. * Clones the current AsciiArtTexture.
  92473. * @return the clone of the texture.
  92474. */
  92475. clone(): AsciiArtFontTexture;
  92476. /**
  92477. * Parses a json object representing the texture and returns an instance of it.
  92478. * @param source the source JSON representation
  92479. * @param scene the scene to create the texture for
  92480. * @return the parsed texture
  92481. */
  92482. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92483. }
  92484. /**
  92485. * Option available in the Ascii Art Post Process.
  92486. */
  92487. export interface IAsciiArtPostProcessOptions {
  92488. /**
  92489. * The font to use following the w3c font definition.
  92490. */
  92491. font?: string;
  92492. /**
  92493. * The character set to use in the postprocess.
  92494. */
  92495. characterSet?: string;
  92496. /**
  92497. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92498. * This number is defined between 0 and 1;
  92499. */
  92500. mixToTile?: number;
  92501. /**
  92502. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92503. * This number is defined between 0 and 1;
  92504. */
  92505. mixToNormal?: number;
  92506. }
  92507. /**
  92508. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92509. *
  92510. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92511. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92512. */
  92513. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92514. /**
  92515. * The font texture used to render the char in the post process.
  92516. */
  92517. private _asciiArtFontTexture;
  92518. /**
  92519. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92520. * This number is defined between 0 and 1;
  92521. */
  92522. mixToTile: number;
  92523. /**
  92524. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92525. * This number is defined between 0 and 1;
  92526. */
  92527. mixToNormal: number;
  92528. /**
  92529. * Instantiates a new Ascii Art Post Process.
  92530. * @param name the name to give to the postprocess
  92531. * @camera the camera to apply the post process to.
  92532. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92533. */
  92534. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92535. }
  92536. }
  92537. declare module BABYLON {
  92538. /** @hidden */
  92539. export var digitalrainPixelShader: {
  92540. name: string;
  92541. shader: string;
  92542. };
  92543. }
  92544. declare module BABYLON {
  92545. /**
  92546. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92547. *
  92548. * It basically takes care rendering the font front the given font size to a texture.
  92549. * This is used later on in the postprocess.
  92550. */
  92551. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92552. private _font;
  92553. private _text;
  92554. private _charSize;
  92555. /**
  92556. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92557. */
  92558. get charSize(): number;
  92559. /**
  92560. * Create a new instance of the Digital Rain FontTexture class
  92561. * @param name the name of the texture
  92562. * @param font the font to use, use the W3C CSS notation
  92563. * @param text the caracter set to use in the rendering.
  92564. * @param scene the scene that owns the texture
  92565. */
  92566. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92567. /**
  92568. * Gets the max char width of a font.
  92569. * @param font the font to use, use the W3C CSS notation
  92570. * @return the max char width
  92571. */
  92572. private getFontWidth;
  92573. /**
  92574. * Gets the max char height of a font.
  92575. * @param font the font to use, use the W3C CSS notation
  92576. * @return the max char height
  92577. */
  92578. private getFontHeight;
  92579. /**
  92580. * Clones the current DigitalRainFontTexture.
  92581. * @return the clone of the texture.
  92582. */
  92583. clone(): DigitalRainFontTexture;
  92584. /**
  92585. * Parses a json object representing the texture and returns an instance of it.
  92586. * @param source the source JSON representation
  92587. * @param scene the scene to create the texture for
  92588. * @return the parsed texture
  92589. */
  92590. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92591. }
  92592. /**
  92593. * Option available in the Digital Rain Post Process.
  92594. */
  92595. export interface IDigitalRainPostProcessOptions {
  92596. /**
  92597. * The font to use following the w3c font definition.
  92598. */
  92599. font?: string;
  92600. /**
  92601. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92602. * This number is defined between 0 and 1;
  92603. */
  92604. mixToTile?: number;
  92605. /**
  92606. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92607. * This number is defined between 0 and 1;
  92608. */
  92609. mixToNormal?: number;
  92610. }
  92611. /**
  92612. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92613. *
  92614. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92615. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92616. */
  92617. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92618. /**
  92619. * The font texture used to render the char in the post process.
  92620. */
  92621. private _digitalRainFontTexture;
  92622. /**
  92623. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92624. * This number is defined between 0 and 1;
  92625. */
  92626. mixToTile: number;
  92627. /**
  92628. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92629. * This number is defined between 0 and 1;
  92630. */
  92631. mixToNormal: number;
  92632. /**
  92633. * Instantiates a new Digital Rain Post Process.
  92634. * @param name the name to give to the postprocess
  92635. * @camera the camera to apply the post process to.
  92636. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92637. */
  92638. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92639. }
  92640. }
  92641. declare module BABYLON {
  92642. /** @hidden */
  92643. export var brickProceduralTexturePixelShader: {
  92644. name: string;
  92645. shader: string;
  92646. };
  92647. }
  92648. declare module BABYLON {
  92649. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92650. private _numberOfBricksHeight;
  92651. private _numberOfBricksWidth;
  92652. private _jointColor;
  92653. private _brickColor;
  92654. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92655. updateShaderUniforms(): void;
  92656. get numberOfBricksHeight(): number;
  92657. set numberOfBricksHeight(value: number);
  92658. get numberOfBricksWidth(): number;
  92659. set numberOfBricksWidth(value: number);
  92660. get jointColor(): BABYLON.Color3;
  92661. set jointColor(value: BABYLON.Color3);
  92662. get brickColor(): BABYLON.Color3;
  92663. set brickColor(value: BABYLON.Color3);
  92664. /**
  92665. * Serializes this brick procedural texture
  92666. * @returns a serialized brick procedural texture object
  92667. */
  92668. serialize(): any;
  92669. /**
  92670. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92671. * @param parsedTexture defines parsed texture data
  92672. * @param scene defines the current scene
  92673. * @param rootUrl defines the root URL containing brick procedural texture information
  92674. * @returns a parsed Brick Procedural BABYLON.Texture
  92675. */
  92676. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92677. }
  92678. }
  92679. declare module BABYLON {
  92680. /** @hidden */
  92681. export var cloudProceduralTexturePixelShader: {
  92682. name: string;
  92683. shader: string;
  92684. };
  92685. }
  92686. declare module BABYLON {
  92687. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92688. private _skyColor;
  92689. private _cloudColor;
  92690. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92691. updateShaderUniforms(): void;
  92692. get skyColor(): BABYLON.Color4;
  92693. set skyColor(value: BABYLON.Color4);
  92694. get cloudColor(): BABYLON.Color4;
  92695. set cloudColor(value: BABYLON.Color4);
  92696. /**
  92697. * Serializes this cloud procedural texture
  92698. * @returns a serialized cloud procedural texture object
  92699. */
  92700. serialize(): any;
  92701. /**
  92702. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92703. * @param parsedTexture defines parsed texture data
  92704. * @param scene defines the current scene
  92705. * @param rootUrl defines the root URL containing cloud procedural texture information
  92706. * @returns a parsed Cloud Procedural BABYLON.Texture
  92707. */
  92708. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92709. }
  92710. }
  92711. declare module BABYLON {
  92712. /** @hidden */
  92713. export var fireProceduralTexturePixelShader: {
  92714. name: string;
  92715. shader: string;
  92716. };
  92717. }
  92718. declare module BABYLON {
  92719. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92720. private _time;
  92721. private _speed;
  92722. private _autoGenerateTime;
  92723. private _fireColors;
  92724. private _alphaThreshold;
  92725. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92726. updateShaderUniforms(): void;
  92727. render(useCameraPostProcess?: boolean): void;
  92728. static get PurpleFireColors(): BABYLON.Color3[];
  92729. static get GreenFireColors(): BABYLON.Color3[];
  92730. static get RedFireColors(): BABYLON.Color3[];
  92731. static get BlueFireColors(): BABYLON.Color3[];
  92732. get autoGenerateTime(): boolean;
  92733. set autoGenerateTime(value: boolean);
  92734. get fireColors(): BABYLON.Color3[];
  92735. set fireColors(value: BABYLON.Color3[]);
  92736. get time(): number;
  92737. set time(value: number);
  92738. get speed(): BABYLON.Vector2;
  92739. set speed(value: BABYLON.Vector2);
  92740. get alphaThreshold(): number;
  92741. set alphaThreshold(value: number);
  92742. /**
  92743. * Serializes this fire procedural texture
  92744. * @returns a serialized fire procedural texture object
  92745. */
  92746. serialize(): any;
  92747. /**
  92748. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92749. * @param parsedTexture defines parsed texture data
  92750. * @param scene defines the current scene
  92751. * @param rootUrl defines the root URL containing fire procedural texture information
  92752. * @returns a parsed Fire Procedural BABYLON.Texture
  92753. */
  92754. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92755. }
  92756. }
  92757. declare module BABYLON {
  92758. /** @hidden */
  92759. export var grassProceduralTexturePixelShader: {
  92760. name: string;
  92761. shader: string;
  92762. };
  92763. }
  92764. declare module BABYLON {
  92765. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92766. private _grassColors;
  92767. private _groundColor;
  92768. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92769. updateShaderUniforms(): void;
  92770. get grassColors(): BABYLON.Color3[];
  92771. set grassColors(value: BABYLON.Color3[]);
  92772. get groundColor(): BABYLON.Color3;
  92773. set groundColor(value: BABYLON.Color3);
  92774. /**
  92775. * Serializes this grass procedural texture
  92776. * @returns a serialized grass procedural texture object
  92777. */
  92778. serialize(): any;
  92779. /**
  92780. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92781. * @param parsedTexture defines parsed texture data
  92782. * @param scene defines the current scene
  92783. * @param rootUrl defines the root URL containing grass procedural texture information
  92784. * @returns a parsed Grass Procedural BABYLON.Texture
  92785. */
  92786. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92787. }
  92788. }
  92789. declare module BABYLON {
  92790. /** @hidden */
  92791. export var marbleProceduralTexturePixelShader: {
  92792. name: string;
  92793. shader: string;
  92794. };
  92795. }
  92796. declare module BABYLON {
  92797. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92798. private _numberOfTilesHeight;
  92799. private _numberOfTilesWidth;
  92800. private _amplitude;
  92801. private _jointColor;
  92802. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92803. updateShaderUniforms(): void;
  92804. get numberOfTilesHeight(): number;
  92805. set numberOfTilesHeight(value: number);
  92806. get amplitude(): number;
  92807. set amplitude(value: number);
  92808. get numberOfTilesWidth(): number;
  92809. set numberOfTilesWidth(value: number);
  92810. get jointColor(): BABYLON.Color3;
  92811. set jointColor(value: BABYLON.Color3);
  92812. /**
  92813. * Serializes this marble procedural texture
  92814. * @returns a serialized marble procedural texture object
  92815. */
  92816. serialize(): any;
  92817. /**
  92818. * Creates a Marble Procedural BABYLON.Texture from parsed marble 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 marble procedural texture information
  92822. * @returns a parsed Marble Procedural BABYLON.Texture
  92823. */
  92824. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92825. }
  92826. }
  92827. declare module BABYLON {
  92828. /** @hidden */
  92829. export var normalMapProceduralTexturePixelShader: {
  92830. name: string;
  92831. shader: string;
  92832. };
  92833. }
  92834. declare module BABYLON {
  92835. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  92836. private _baseTexture;
  92837. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92838. updateShaderUniforms(): void;
  92839. render(useCameraPostProcess?: boolean): void;
  92840. resize(size: any, generateMipMaps: any): void;
  92841. isReady(): boolean;
  92842. get baseTexture(): BABYLON.Texture;
  92843. set baseTexture(texture: BABYLON.Texture);
  92844. /**
  92845. * Serializes this normal map procedural texture
  92846. * @returns a serialized normal map procedural texture object
  92847. */
  92848. serialize(): any;
  92849. /**
  92850. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  92851. * @param parsedTexture defines parsed texture data
  92852. * @param scene defines the current scene
  92853. * @param rootUrl defines the root URL containing normal map procedural texture information
  92854. * @returns a parsed Normal Map Procedural BABYLON.Texture
  92855. */
  92856. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  92857. }
  92858. }
  92859. declare module BABYLON {
  92860. /** @hidden */
  92861. export var perlinNoiseProceduralTexturePixelShader: {
  92862. name: string;
  92863. shader: string;
  92864. };
  92865. }
  92866. declare module BABYLON {
  92867. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  92868. time: number;
  92869. timeScale: number;
  92870. translationSpeed: number;
  92871. private _currentTranslation;
  92872. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92873. updateShaderUniforms(): void;
  92874. render(useCameraPostProcess?: boolean): void;
  92875. resize(size: any, generateMipMaps: any): void;
  92876. /**
  92877. * Serializes this perlin noise procedural texture
  92878. * @returns a serialized perlin noise procedural texture object
  92879. */
  92880. serialize(): any;
  92881. /**
  92882. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  92883. * @param parsedTexture defines parsed texture data
  92884. * @param scene defines the current scene
  92885. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  92886. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  92887. */
  92888. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  92889. }
  92890. }
  92891. declare module BABYLON {
  92892. /** @hidden */
  92893. export var roadProceduralTexturePixelShader: {
  92894. name: string;
  92895. shader: string;
  92896. };
  92897. }
  92898. declare module BABYLON {
  92899. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  92900. private _roadColor;
  92901. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92902. updateShaderUniforms(): void;
  92903. get roadColor(): BABYLON.Color3;
  92904. set roadColor(value: BABYLON.Color3);
  92905. /**
  92906. * Serializes this road procedural texture
  92907. * @returns a serialized road procedural texture object
  92908. */
  92909. serialize(): any;
  92910. /**
  92911. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  92912. * @param parsedTexture defines parsed texture data
  92913. * @param scene defines the current scene
  92914. * @param rootUrl defines the root URL containing road procedural texture information
  92915. * @returns a parsed Road Procedural BABYLON.Texture
  92916. */
  92917. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  92918. }
  92919. }
  92920. declare module BABYLON {
  92921. /** @hidden */
  92922. export var starfieldProceduralTexturePixelShader: {
  92923. name: string;
  92924. shader: string;
  92925. };
  92926. }
  92927. declare module BABYLON {
  92928. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  92929. private _time;
  92930. private _alpha;
  92931. private _beta;
  92932. private _zoom;
  92933. private _formuparam;
  92934. private _stepsize;
  92935. private _tile;
  92936. private _brightness;
  92937. private _darkmatter;
  92938. private _distfading;
  92939. private _saturation;
  92940. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92941. updateShaderUniforms(): void;
  92942. get time(): number;
  92943. set time(value: number);
  92944. get alpha(): number;
  92945. set alpha(value: number);
  92946. get beta(): number;
  92947. set beta(value: number);
  92948. get formuparam(): number;
  92949. set formuparam(value: number);
  92950. get stepsize(): number;
  92951. set stepsize(value: number);
  92952. get zoom(): number;
  92953. set zoom(value: number);
  92954. get tile(): number;
  92955. set tile(value: number);
  92956. get brightness(): number;
  92957. set brightness(value: number);
  92958. get darkmatter(): number;
  92959. set darkmatter(value: number);
  92960. get distfading(): number;
  92961. set distfading(value: number);
  92962. get saturation(): number;
  92963. set saturation(value: number);
  92964. /**
  92965. * Serializes this starfield procedural texture
  92966. * @returns a serialized starfield procedural texture object
  92967. */
  92968. serialize(): any;
  92969. /**
  92970. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  92971. * @param parsedTexture defines parsed texture data
  92972. * @param scene defines the current scene
  92973. * @param rootUrl defines the root URL containing startfield procedural texture information
  92974. * @returns a parsed Starfield Procedural BABYLON.Texture
  92975. */
  92976. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  92977. }
  92978. }
  92979. declare module BABYLON {
  92980. /** @hidden */
  92981. export var woodProceduralTexturePixelShader: {
  92982. name: string;
  92983. shader: string;
  92984. };
  92985. }
  92986. declare module BABYLON {
  92987. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  92988. private _ampScale;
  92989. private _woodColor;
  92990. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92991. updateShaderUniforms(): void;
  92992. get ampScale(): number;
  92993. set ampScale(value: number);
  92994. get woodColor(): BABYLON.Color3;
  92995. set woodColor(value: BABYLON.Color3);
  92996. /**
  92997. * Serializes this wood procedural texture
  92998. * @returns a serialized wood procedural texture object
  92999. */
  93000. serialize(): any;
  93001. /**
  93002. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93003. * @param parsedTexture defines parsed texture data
  93004. * @param scene defines the current scene
  93005. * @param rootUrl defines the root URL containing wood procedural texture information
  93006. * @returns a parsed Wood Procedural BABYLON.Texture
  93007. */
  93008. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93009. }
  93010. }